Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/common/extensions/features/simple_feature.h

Issue 11316164: Implement ComplexFeature to support permission features with multiple rules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments, cleanup Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_SIMPLE_FEATURE_H_
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/values.h"
12 #include "chrome/common/chrome_version_info.h"
13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/features/feature.h"
15
16 namespace extensions {
17
18 class ComplexFeature;
19
20 class SimpleFeature : public Feature {
21 public:
22 SimpleFeature();
23 SimpleFeature(const SimpleFeature& other);
24 virtual ~SimpleFeature();
25
26 std::set<std::string>* whitelist() { return &whitelist_; }
27 std::set<Extension::Type>* extension_types() { return &extension_types_; }
28
29 virtual std::set<Context>* contexts() OVERRIDE { return &contexts_; }
30
31 // Parses the JSON representation of a feature into the fields of this object.
32 // Unspecified values in the JSON are not modified in the object. This allows
33 // us to implement inheritance by parsing one value after another.
34 void Parse(const DictionaryValue* value);
35
36 // Returns true if the feature contains the same values as another.
37 bool Equals(const SimpleFeature& other) const;
38
39 Location location() const { return location_; }
40 void set_location(Location location) { location_ = location; }
41
42 Platform platform() const { return platform_; }
43 void set_platform(Platform platform) { platform_ = platform; }
44
45 int min_manifest_version() const { return min_manifest_version_; }
46 void set_min_manifest_version(int min_manifest_version) {
47 min_manifest_version_ = min_manifest_version;
48 }
49
50 int max_manifest_version() const { return max_manifest_version_; }
51 void set_max_manifest_version(int max_manifest_version) {
52 max_manifest_version_ = max_manifest_version;
53 }
54
55 Availability IsAvailableToContext(const Extension* extension,
56 Context context) const {
57 return IsAvailableToContext(extension, context, GetCurrentPlatform());
58 }
59
60 // extension::Feature:
61 virtual Availability IsAvailableToManifest(const std::string& extension_id,
62 Extension::Type type,
63 Location location,
64 int manifest_version,
65 Platform platform) const OVERRIDE;
66
67 virtual Availability IsAvailableToContext(const Extension* extension,
68 Context context,
69 Platform platform) const OVERRIDE;
70
71 virtual std::string GetAvailabilityMessage(
72 AvailabilityResult result, Extension::Type type) const OVERRIDE;
73
74 private:
75 // For clarity and consistency, we handle the default value of each of these
76 // members the same way: it matches everything. It is up to the higher level
77 // code that reads Features out of static data to validate that data and set
78 // sensible defaults.
79 std::set<std::string> whitelist_;
80 std::set<Extension::Type> extension_types_;
81 std::set<Context> contexts_;
82 Location location_; // we only care about component/not-component now
83 Platform platform_; // we only care about chromeos/not-chromeos now
84 int min_manifest_version_;
85 int max_manifest_version_;
86 chrome::VersionInfo::Channel channel_;
87
88 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context);
89 };
90
91 } // namespace extensions
92
93 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698