OLD | NEW |
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 #include "extensions/common/extension_api.h" | 5 #include "extensions/common/extension_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
20 #include "extensions/common/extensions_client.h" | 20 #include "extensions/common/extensions_client.h" |
21 #include "extensions/common/features/feature.h" | 21 #include "extensions/common/features/feature.h" |
22 #include "extensions/common/features/feature_provider.h" | 22 #include "extensions/common/features/feature_provider.h" |
23 #include "extensions/common/permissions/permission_set.h" | 23 #include "extensions/common/permissions/permission_set.h" |
24 #include "extensions/common/permissions/permissions_data.h" | 24 #include "extensions/common/permissions/permissions_data.h" |
25 #include "grit/extensions_api_resources.h" | |
26 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
28 | 27 |
29 namespace extensions { | 28 namespace extensions { |
30 | 29 |
31 namespace { | 30 namespace { |
32 | 31 |
33 const char* kChildKinds[] = { | 32 const char* kChildKinds[] = { |
34 "functions", | 33 "functions", |
35 "events" | 34 "events" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 219 } |
221 | 220 |
222 ExtensionAPI::~ExtensionAPI() { | 221 ExtensionAPI::~ExtensionAPI() { |
223 } | 222 } |
224 | 223 |
225 void ExtensionAPI::InitDefaultConfiguration() { | 224 void ExtensionAPI::InitDefaultConfiguration() { |
226 const char* names[] = {"api", "manifest", "permission"}; | 225 const char* names[] = {"api", "manifest", "permission"}; |
227 for (size_t i = 0; i < arraysize(names); ++i) | 226 for (size_t i = 0; i < arraysize(names); ++i) |
228 RegisterDependencyProvider(names[i], FeatureProvider::GetByName(names[i])); | 227 RegisterDependencyProvider(names[i], FeatureProvider::GetByName(names[i])); |
229 | 228 |
230 // Schemas to be loaded from resources. | 229 ExtensionsClient::Get()->RegisterAPISchemaResources(this); |
231 CHECK(unloaded_schemas_.empty()); | |
232 RegisterSchemaResource("accessibilityPrivate", | |
233 IDR_EXTENSION_API_JSON_ACCESSIBILITYPRIVATE); | |
234 RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP); | |
235 RegisterSchemaResource("browserAction", IDR_EXTENSION_API_JSON_BROWSERACTION); | |
236 RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS); | |
237 RegisterSchemaResource("declarativeContent", | |
238 IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT); | |
239 RegisterSchemaResource("declarativeWebRequest", | |
240 IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST); | |
241 RegisterSchemaResource("fileBrowserHandler", | |
242 IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER); | |
243 RegisterSchemaResource("inputMethodPrivate", | |
244 IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE); | |
245 RegisterSchemaResource("pageAction", IDR_EXTENSION_API_JSON_PAGEACTION); | |
246 RegisterSchemaResource("pageActions", IDR_EXTENSION_API_JSON_PAGEACTIONS); | |
247 RegisterSchemaResource("privacy", IDR_EXTENSION_API_JSON_PRIVACY); | |
248 RegisterSchemaResource("processes", IDR_EXTENSION_API_JSON_PROCESSES); | |
249 RegisterSchemaResource("proxy", IDR_EXTENSION_API_JSON_PROXY); | |
250 RegisterSchemaResource("scriptBadge", IDR_EXTENSION_API_JSON_SCRIPTBADGE); | |
251 RegisterSchemaResource("ttsEngine", IDR_EXTENSION_API_JSON_TTSENGINE); | |
252 RegisterSchemaResource("tts", IDR_EXTENSION_API_JSON_TTS); | |
253 RegisterSchemaResource("types", IDR_EXTENSION_API_JSON_TYPES); | |
254 RegisterSchemaResource("types.private", IDR_EXTENSION_API_JSON_TYPES_PRIVATE); | |
255 RegisterSchemaResource("webstore", IDR_EXTENSION_API_JSON_WEBSTORE); | |
256 RegisterSchemaResource("webViewRequest", | |
257 IDR_EXTENSION_API_JSON_WEBVIEW_REQUEST); | |
258 | 230 |
259 default_configuration_initialized_ = true; | 231 default_configuration_initialized_ = true; |
260 } | 232 } |
261 | 233 |
262 void ExtensionAPI::RegisterSchemaResource(const std::string& name, | 234 void ExtensionAPI::RegisterSchemaResource(const std::string& name, |
263 int resource_id) { | 235 int resource_id) { |
264 unloaded_schemas_[name] = resource_id; | 236 unloaded_schemas_[name] = resource_id; |
265 } | 237 } |
266 | 238 |
267 void ExtensionAPI::RegisterDependencyProvider(const std::string& name, | 239 void ExtensionAPI::RegisterDependencyProvider(const std::string& name, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 break; | 384 break; |
413 | 385 |
414 api_name_candidate = api_name_candidate.substr(0, last_dot_index); | 386 api_name_candidate = api_name_candidate.substr(0, last_dot_index); |
415 } | 387 } |
416 | 388 |
417 *child_name = ""; | 389 *child_name = ""; |
418 return std::string(); | 390 return std::string(); |
419 } | 391 } |
420 | 392 |
421 } // namespace extensions | 393 } // namespace extensions |
OLD | NEW |