Home | History | Annotate | Download | only in features
      1 // Copyright (c) 2012 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 CHROME_COMMON_EXTENSIONS_FEATURES_COMPLEX_FEATURE_H_
      6 #define CHROME_COMMON_EXTENSIONS_FEATURES_COMPLEX_FEATURE_H_
      7 
      8 #include <string>
      9 
     10 #include "base/memory/scoped_vector.h"
     11 #include "chrome/common/extensions/extension.h"
     12 #include "chrome/common/extensions/features/feature.h"
     13 #include "chrome/common/extensions/manifest.h"
     14 
     15 namespace extensions {
     16 
     17 // A ComplexFeature is composed of one or many Features. A ComplexFeature
     18 // is available if any Feature (i.e. permission rule) that composes it is
     19 // available, but not if only some combination of Features is available.
     20 class ComplexFeature : public Feature {
     21  public:
     22   typedef ScopedVector<Feature> FeatureList;
     23 
     24   explicit ComplexFeature(scoped_ptr<FeatureList> features);
     25   virtual ~ComplexFeature();
     26 
     27   // extensions::Feature:
     28   virtual Availability IsAvailableToManifest(const std::string& extension_id,
     29                                              Manifest::Type type,
     30                                              Location location,
     31                                              int manifest_version,
     32                                              Platform platform) const OVERRIDE;
     33 
     34   virtual Availability IsAvailableToContext(const Extension* extension,
     35                                             Context context,
     36                                             const GURL& url,
     37                                             Platform platform) const OVERRIDE;
     38 
     39   virtual bool IsIdInWhitelist(const std::string& extension_id) const OVERRIDE;
     40 
     41  protected:
     42   // extensions::Feature:
     43   virtual std::string GetAvailabilityMessage(
     44       AvailabilityResult result,
     45       Manifest::Type type,
     46       const GURL& url) const OVERRIDE;
     47 
     48   virtual std::set<Context>* GetContexts() OVERRIDE;
     49 
     50   virtual bool IsInternal() const OVERRIDE;
     51 
     52  private:
     53   FeatureList features_;
     54 
     55   DISALLOW_COPY_AND_ASSIGN(ComplexFeature);
     56 };
     57 
     58 }  // namespace extensions
     59 
     60 #endif  // CHROME_COMMON_EXTENSIONS_FEATURES_COMPLEX_FEATURE_H_
     61