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

Side by Side Diff: chrome/common/extensions/api/extension_api.h

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // content scripts, or other low-privileged contexts. 81 // content scripts, or other low-privileged contexts.
82 bool IsPrivileged(const std::string& name); 82 bool IsPrivileged(const std::string& name);
83 83
84 // Gets the schema for the extension API with namespace |full_name|. 84 // Gets the schema for the extension API with namespace |full_name|.
85 // Ownership remains with this object. 85 // Ownership remains with this object.
86 const base::DictionaryValue* GetSchema(const std::string& full_name); 86 const base::DictionaryValue* GetSchema(const std::string& full_name);
87 87
88 // Gets the APIs available to |context| given an |extension| and |url|. The 88 // Gets the APIs available to |context| given an |extension| and |url|. The
89 // extension or URL may not be relevant to all contexts, and may be left 89 // extension or URL may not be relevant to all contexts, and may be left
90 // NULL/empty. 90 // NULL/empty.
91 scoped_ptr<std::set<std::string> > GetAPIsForContext( 91 std::set<std::string> GetAPIsForContext(
92 Feature::Context context, const Extension* extension, const GURL& url); 92 Feature::Context context, const Extension* extension, const GURL& url);
93 93
94 std::set<std::string> GetAllAPINames();
95
94 // Gets a Feature object describing the API with the specified |full_name|. 96 // Gets a Feature object describing the API with the specified |full_name|.
95 // This can be either an API namespace (like history, or 97 // This can be either an API namespace (like history, or
96 // experimental.bookmarks), or it can be an individual function or event. 98 // experimental.bookmarks), or it can be an individual function or event.
97 virtual Feature* GetFeature(const std::string& full_name) OVERRIDE; 99 virtual Feature* GetFeature(const std::string& full_name) OVERRIDE;
98 100
99 // Splits a full name from the extension API into its API and child name 101 // Splits a full name from the extension API into its API and child name
100 // parts. Some examples: 102 // parts. Some examples:
101 // 103 //
102 // "bookmarks.create" -> ("bookmarks", "create") 104 // "bookmarks.create" -> ("bookmarks", "create")
103 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") 105 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp")
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // "extension" which has unprivileged components. 153 // "extension" which has unprivileged components.
152 void RemovePrivilegedAPIs(std::set<std::string>* apis); 154 void RemovePrivilegedAPIs(std::set<std::string>* apis);
153 155
154 // Adds an APIs that match |url| to |out|. 156 // Adds an APIs that match |url| to |out|.
155 // NOTE: This only works for non-feature-controlled APIs. 157 // NOTE: This only works for non-feature-controlled APIs.
156 // TODO(aa): Remove this when all APIs are converted to the feature system. 158 // TODO(aa): Remove this when all APIs are converted to the feature system.
157 void GetAPIsMatchingURL(const GURL& url, std::set<std::string>* out); 159 void GetAPIsMatchingURL(const GURL& url, std::set<std::string>* out);
158 160
159 // Map from each API that hasn't been loaded yet to the schema which defines 161 // Map from each API that hasn't been loaded yet to the schema which defines
160 // it. Note that there may be multiple APIs per schema. 162 // it. Note that there may be multiple APIs per schema.
161 std::map<std::string, base::StringPiece> unloaded_schemas_; 163 typedef std::map<std::string, base::StringPiece> UnloadedSchemaMap;
164 UnloadedSchemaMap unloaded_schemas_;
162 165
163 // Schemas for each namespace. 166 // Schemas for each namespace.
164 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap; 167 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap;
165 SchemaMap schemas_; 168 SchemaMap schemas_;
166 169
167 // APIs that are entirely unprivileged. 170 // APIs that are entirely unprivileged.
168 std::set<std::string> completely_unprivileged_apis_; 171 std::set<std::string> completely_unprivileged_apis_;
169 172
170 // APIs that are not entirely unprivileged, but have unprivileged components. 173 // APIs that are not entirely unprivileged, but have unprivileged components.
171 std::set<std::string> partially_unprivileged_apis_; 174 std::set<std::string> partially_unprivileged_apis_;
172 175
173 // APIs that have URL matching permissions. 176 // APIs that have URL matching permissions.
174 std::map<std::string, URLPatternSet> url_matching_apis_; 177 std::map<std::string, URLPatternSet> url_matching_apis_;
175 178
176 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; 179 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap;
177 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap; 180 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap;
178 APIFeatureMap features_; 181 APIFeatureMap features_;
179 182
180 // FeatureProviders used for resolving dependencies. 183 // FeatureProviders used for resolving dependencies.
181 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; 184 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap;
182 FeatureProviderMap dependency_providers_; 185 FeatureProviderMap dependency_providers_;
183 186
184 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); 187 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
185 }; 188 };
186 189
187 } // extensions 190 } // extensions
188 191
189 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ 192 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698