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

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: new 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 SimpleFeature : public Feature {
19 public:
20 SimpleFeature();
21 SimpleFeature(const SimpleFeature& other);
22 virtual ~SimpleFeature();
23
24 std::set<std::string>* whitelist() { return &whitelist_; }
25 std::set<Extension::Type>* extension_types() { return &extension_types_; }
26
27 std::set<Context>* contexts() { return &contexts_; }
28
29 // Parses the JSON representation of a feature into the fields of this object.
30 // Unspecified values in the JSON are not modified in the object. This allows
31 // us to implement inheritance by parsing one value after another.
32 void Parse(const DictionaryValue* value);
33
34 // Returns true if the feature contains the same values as another.
35 bool Equals(const SimpleFeature& other) const;
36
37 Location location() const { return location_; }
38 void set_location(Location location) { location_ = location; }
39
40 Platform platform() const { return platform_; }
41 void set_platform(Platform platform) { platform_ = platform; }
42
43 int min_manifest_version() const { return min_manifest_version_; }
44 void set_min_manifest_version(int min_manifest_version) {
45 min_manifest_version_ = min_manifest_version;
46 }
47
48 int max_manifest_version() const { return max_manifest_version_; }
49 void set_max_manifest_version(int max_manifest_version) {
50 max_manifest_version_ = max_manifest_version;
51 }
52
53 Availability IsAvailableToManifest(const std::string& extension_id,
54 Extension::Type type,
55 Location location,
56 int manifest_version) const {
57 return IsAvailableToManifest(extension_id, type, location, manifest_version,
58 GetCurrentPlatform());
59 }
60 Availability IsAvailableToContext(const Extension* extension,
61 Context context) const {
62 return IsAvailableToContext(extension, context, GetCurrentPlatform());
63 }
64
65 // extension::Feature:
66 virtual Availability IsAvailableToManifest(const std::string& extension_id,
67 Extension::Type type,
68 Location location,
69 int manifest_version,
70 Platform platform) const OVERRIDE;
71 virtual Availability IsAvailableToContext(const Extension* extension,
72 Context context,
73 Platform platform) const OVERRIDE;
74 virtual std::string GetAvailabilityMessage(
75 AvailabilityResult result, Extension::Type type) const OVERRIDE;
76
77 private:
78 // For clarify and consistency, we handle the default value of each of these
79 // members the same way: it matches everything. It is up to the higher level
80 // code that reads Features out of static data to validate that data and set
81 // sensible defaults.
82 std::set<std::string> whitelist_;
83 std::set<Extension::Type> extension_types_;
84 std::set<Context> contexts_;
85 Location location_; // we only care about component/not-component now
86 Platform platform_; // we only care about chromeos/not-chromeos now
87 int min_manifest_version_;
88 int max_manifest_version_;
89 chrome::VersionInfo::Channel channel_;
90
91 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context);
92 };
93
94 } // namespace extensions
95
96 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698