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.
5 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_FILTER_H_
6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_FILTER_H_
10 #include "extensions/common/features/feature.h"
11 #include "extensions/common/manifest.h"
16 class DictionaryValue
;
19 namespace extensions
{
23 // A SimpleFeatureFilter can be attached to SimpleFeature objects to provide
24 // additional parsing and availability filtering behavior.
25 class SimpleFeatureFilter
{
27 explicit SimpleFeatureFilter(SimpleFeature
* feature
);
28 virtual ~SimpleFeatureFilter();
30 SimpleFeature
* feature() const { return feature_
; }
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
);
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
,
43 Feature::Platform platform
) const;
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
,
50 Manifest::Location location
,
52 Feature::Platform platform
) const;
55 // The feature which owns this filter.
56 SimpleFeature
* feature_
;
58 DISALLOW_COPY_AND_ASSIGN(SimpleFeatureFilter
);
61 } // namespace extensions
63 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_FILTER_H_