Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / common / features / simple_feature_filter.h
blobc325250b6b1235938a6fe6972d78bd475bbfebcd
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_
8 #include <string>
10 #include "extensions/common/features/feature.h"
11 #include "extensions/common/manifest.h"
13 class GURL;
15 namespace base {
16 class DictionaryValue;
19 namespace extensions {
21 class SimpleFeature;
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();
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,
42 const GURL& url,
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,
49 Manifest::Type type,
50 Manifest::Location location,
51 int manifest_version,
52 Feature::Platform platform) const;
54 private:
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_