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

Side by Side Diff: extensions/common/features/feature.h

Issue 2116293003: extensions: Generate hash of extension ID at a higher level Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_H_
6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/crx_file/id_util.h"
12 #include "extensions/common/manifest.h" 13 #include "extensions/common/manifest.h"
13 14
15 using crx_file::id_util::HashedIdInHex;
16
14 class GURL; 17 class GURL;
15 18
16 namespace extensions { 19 namespace extensions {
17 20
18 class Extension; 21 class Extension;
19 22
20 // Represents a single feature accessible to an extension developer, such as a 23 // Represents a single feature accessible to an extension developer, such as a
21 // top-level manifest key, a permission, or a programmatic API. A feature can 24 // top-level manifest key, a permission, or a programmatic API. A feature can
22 // express requirements for where it can be accessed, and supports testing 25 // express requirements for where it can be accessed, and supports testing
23 // support for those requirements. If platforms are not specified, then feature 26 // support for those requirements. If platforms are not specified, then feature
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 113
111 // Tests whether this is an internal API or not. 114 // Tests whether this is an internal API or not.
112 virtual bool IsInternal() const = 0; 115 virtual bool IsInternal() const = 0;
113 116
114 // Returns true if the feature is available to be parsed into a new extension 117 // Returns true if the feature is available to be parsed into a new extension
115 // manifest. 118 // manifest.
116 Availability IsAvailableToManifest(const std::string& extension_id, 119 Availability IsAvailableToManifest(const std::string& extension_id,
117 Manifest::Type type, 120 Manifest::Type type,
118 Manifest::Location location, 121 Manifest::Location location,
119 int manifest_version) const { 122 int manifest_version) const {
120 return IsAvailableToManifest(extension_id, type, location, manifest_version, 123 return IsAvailableToManifest(extension_id, HashedIdInHex(extension_id),
124 type, location, manifest_version,
121 GetCurrentPlatform()); 125 GetCurrentPlatform());
122 } 126 }
123 virtual Availability IsAvailableToManifest(const std::string& extension_id, 127 virtual Availability IsAvailableToManifest(const std::string& extension_id,
128 const std::string& hashed_id,
124 Manifest::Type type, 129 Manifest::Type type,
125 Manifest::Location location, 130 Manifest::Location location,
126 int manifest_version, 131 int manifest_version,
127 Platform platform) const = 0; 132 Platform platform) const = 0;
128 133
129 // Returns true if the feature is available to |extension|. 134 // Returns true if the feature is available to |extension|.
130 Availability IsAvailableToExtension(const Extension* extension) const; 135 Availability IsAvailableToExtension(const Extension* extension) const;
131 136
132 // Returns true if the feature is available to be used in the specified 137 // Returns true if the feature is available to be used in the specified
133 // extension and context. 138 // extension and context.
(...skipping 16 matching lines...) Expand all
150 // without needing to know information about an Extension or any other 155 // without needing to know information about an Extension or any other
151 // contextual information. Typically used when the Feature is purely 156 // contextual information. Typically used when the Feature is purely
152 // configured by command line flags and/or Chrome channel. 157 // configured by command line flags and/or Chrome channel.
153 // 158 //
154 // Generally try not to use this function. Even if you don't think a Feature 159 // Generally try not to use this function. Even if you don't think a Feature
155 // relies on an Extension now - maybe it will, one day, so if there's an 160 // relies on an Extension now - maybe it will, one day, so if there's an
156 // Extension available (or a runtime context, etc) then use the more targeted 161 // Extension available (or a runtime context, etc) then use the more targeted
157 // method instead. 162 // method instead.
158 Availability IsAvailableToEnvironment() const; 163 Availability IsAvailableToEnvironment() const;
159 164
160 virtual bool IsIdInBlacklist(const std::string& extension_id) const = 0; 165 bool IsIdInBlacklist(const std::string& extension_id) {
161 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; 166 return IsIdInBlacklist(extension_id, HashedIdInHex(extension_id));
167 }
168
169 bool IsIdInWhitelist(const std::string& extension_id) {
170 return IsIdInWhitelist(extension_id, HashedIdInHex(extension_id));
171 }
172
173 virtual bool IsIdInBlacklist(const std::string& extension_id,
174 const std::string& hashed_id) const = 0;
175 virtual bool IsIdInWhitelist(const std::string& extension_id,
176 const std::string& hashed_id) const = 0;
162 177
163 protected: 178 protected:
164 std::string name_; 179 std::string name_;
165 bool no_parent_; 180 bool no_parent_;
166 }; 181 };
167 182
168 } // namespace extensions 183 } // namespace extensions
169 184
170 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 185 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_
OLDNEW
« no previous file with comments | « extensions/common/features/complex_feature_unittest.cc ('k') | extensions/common/features/feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698