1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ 6 #define EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/memory/scoped_vector.h" 12 #include "extensions/common/extension.h" 13 #include "extensions/common/features/feature.h" 14 #include "extensions/common/manifest.h" 15 16 namespace extensions { 17 18 // A ComplexFeature is composed of one or many Features. A ComplexFeature 19 // is available if any Feature (i.e. permission rule) that composes it is 20 // available, but not if only some combination of Features is available. 21 class ComplexFeature : public Feature { 22 public: 23 typedef ScopedVector<Feature> FeatureList; 24 25 explicit ComplexFeature(scoped_ptr<FeatureList> features); 26 virtual ~ComplexFeature(); 27 28 // extensions::Feature: 29 virtual Availability IsAvailableToManifest(const std::string& extension_id, 30 Manifest::Type type, 31 Manifest::Location location, 32 int manifest_version, 33 Platform platform) const OVERRIDE; 34 35 virtual Availability IsAvailableToContext(const Extension* extension, 36 Context context, 37 const GURL& url, 38 Platform platform) const OVERRIDE; 39 40 virtual bool IsIdInBlacklist(const std::string& extension_id) const OVERRIDE; 41 virtual bool IsIdInWhitelist(const std::string& extension_id) const OVERRIDE; 42 virtual bool IsBlockedInServiceWorker() const OVERRIDE; 43 44 protected: 45 // extensions::Feature: 46 virtual std::string GetAvailabilityMessage( 47 AvailabilityResult result, 48 Manifest::Type type, 49 const GURL& url, 50 Context context) const OVERRIDE; 51 52 virtual std::set<Context>* GetContexts() OVERRIDE; 53 54 virtual bool IsInternal() const OVERRIDE; 55 56 private: 57 FeatureList features_; 58 59 DISALLOW_COPY_AND_ASSIGN(ComplexFeature); 60 }; 61 62 } // namespace extensions 63 64 #endif // EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ 65