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_SIMPLE_FEATURE_FILTER_H_ 6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_FILTER_H_ 7 8 #include <string> 9 10 #include "extensions/common/features/feature.h" 11 #include "extensions/common/manifest.h" 12 13 class GURL; 14 15 namespace base { 16 class DictionaryValue; 17 } 18 19 namespace extensions { 20 21 class SimpleFeature; 22 23 // A SimpleFeatureFilter can be attached to SimpleFeature objects to provide 24 // additional parsing and availability filtering behavior. 25 class SimpleFeatureFilter { 26 public: 27 explicit SimpleFeatureFilter(SimpleFeature* feature); 28 virtual ~SimpleFeatureFilter(); 29 30 SimpleFeature* feature() const { return feature_; } 31 32 // Parses any additional feature data that may be used by this filter. 33 // Returns an error string on failure or the empty string on success. 34 // The default implementation simply returns the empty string. 35 virtual std::string Parse(const base::DictionaryValue* value); 36 37 // Indicates whether or not the owning feature is available within a given 38 // extensions context. The default implementation only affirms availability. 39 virtual Feature::Availability IsAvailableToContext( 40 const Extension* extension, 41 Feature::Context context, 42 const GURL& url, 43 Feature::Platform platform) const; 44 45 // Indicates whether or not the owning feature is available to a given 46 // extension manifest. The default implementation only affirms availability. 47 virtual Feature::Availability IsAvailableToManifest( 48 const std::string& extension_id, 49 Manifest::Type type, 50 Manifest::Location location, 51 int manifest_version, 52 Feature::Platform platform) const; 53 54 private: 55 // The feature which owns this filter. 56 SimpleFeature* feature_; 57 58 DISALLOW_COPY_AND_ASSIGN(SimpleFeatureFilter); 59 }; 60 61 } // namespace extensions 62 63 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_FILTER_H_ 64