summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 03:14:39 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 03:14:39 +0000
commitcce6098f7f1bf24fecf648e3cdb6c1f23db42ef8 (patch)
treef414f043dee276f6a4e153251ccff4369a2d4ccb /extensions
parent8204ede6262a8d7aa0c76f399c6c435babd0855b (diff)
downloadchromium_src-cce6098f7f1bf24fecf648e3cdb6c1f23db42ef8.zip
chromium_src-cce6098f7f1bf24fecf648e3cdb6c1f23db42ef8.tar.gz
chromium_src-cce6098f7f1bf24fecf648e3cdb6c1f23db42ef8.tar.bz2
Move extension API schema registration to ExtensionsClient.
BUG=368334 Review URL: https://codereview.chromium.org/296133011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/DEPS1
-rw-r--r--extensions/common/extension_api.cc30
-rw-r--r--extensions/common/extension_api.h3
-rw-r--r--extensions/common/extensions_client.h7
-rw-r--r--extensions/test/test_extensions_client.cc3
-rw-r--r--extensions/test/test_extensions_client.h1
6 files changed, 14 insertions, 31 deletions
diff --git a/extensions/DEPS b/extensions/DEPS
index 0fc52ca..f919975 100644
--- a/extensions/DEPS
+++ b/extensions/DEPS
@@ -13,7 +13,6 @@ include_rules = [
#
# TODO(jamescook): Remove these. http://crbug.com/162530
"!chrome/browser/chrome_notification_types.h",
- '!grit/extensions_api_resources.h',
# This is needed for renderer JS sources which should eventually move to
# the extensions_resources target.
"!grit/renderer_resources.h",
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index 4d6b6ec..9e284f2 100644
--- a/extensions/common/extension_api.cc
+++ b/extensions/common/extension_api.cc
@@ -22,7 +22,6 @@
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
-#include "grit/extensions_api_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
@@ -227,34 +226,7 @@ void ExtensionAPI::InitDefaultConfiguration() {
for (size_t i = 0; i < arraysize(names); ++i)
RegisterDependencyProvider(names[i], FeatureProvider::GetByName(names[i]));
- // Schemas to be loaded from resources.
- CHECK(unloaded_schemas_.empty());
- RegisterSchemaResource("accessibilityPrivate",
- IDR_EXTENSION_API_JSON_ACCESSIBILITYPRIVATE);
- RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP);
- RegisterSchemaResource("browserAction", IDR_EXTENSION_API_JSON_BROWSERACTION);
- RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS);
- RegisterSchemaResource("declarativeContent",
- IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT);
- RegisterSchemaResource("declarativeWebRequest",
- IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST);
- RegisterSchemaResource("fileBrowserHandler",
- IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER);
- RegisterSchemaResource("inputMethodPrivate",
- IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE);
- RegisterSchemaResource("pageAction", IDR_EXTENSION_API_JSON_PAGEACTION);
- RegisterSchemaResource("pageActions", IDR_EXTENSION_API_JSON_PAGEACTIONS);
- RegisterSchemaResource("privacy", IDR_EXTENSION_API_JSON_PRIVACY);
- RegisterSchemaResource("processes", IDR_EXTENSION_API_JSON_PROCESSES);
- RegisterSchemaResource("proxy", IDR_EXTENSION_API_JSON_PROXY);
- RegisterSchemaResource("scriptBadge", IDR_EXTENSION_API_JSON_SCRIPTBADGE);
- RegisterSchemaResource("ttsEngine", IDR_EXTENSION_API_JSON_TTSENGINE);
- RegisterSchemaResource("tts", IDR_EXTENSION_API_JSON_TTS);
- RegisterSchemaResource("types", IDR_EXTENSION_API_JSON_TYPES);
- RegisterSchemaResource("types.private", IDR_EXTENSION_API_JSON_TYPES_PRIVATE);
- RegisterSchemaResource("webstore", IDR_EXTENSION_API_JSON_WEBSTORE);
- RegisterSchemaResource("webViewRequest",
- IDR_EXTENSION_API_JSON_WEBVIEW_REQUEST);
+ ExtensionsClient::Get()->RegisterAPISchemaResources(this);
default_configuration_initialized_ = true;
}
diff --git a/extensions/common/extension_api.h b/extensions/common/extension_api.h
index bd2e315..e16d401 100644
--- a/extensions/common/extension_api.h
+++ b/extensions/common/extension_api.h
@@ -60,8 +60,11 @@ class ExtensionAPI {
ExtensionAPI();
virtual ~ExtensionAPI();
+ // Add a (non-generated) API schema resource.
void RegisterSchemaResource(const std::string& api_name, int resource_id);
+ // Add a FeatureProvider for APIs. The features are used to specify
+ // dependencies and constraints on the availability of APIs.
void RegisterDependencyProvider(const std::string& name,
const FeatureProvider* provider);
diff --git a/extensions/common/extensions_client.h b/extensions/common/extensions_client.h
index f0bdc8c..9f4ebf9 100644
--- a/extensions/common/extensions_client.h
+++ b/extensions/common/extensions_client.h
@@ -18,6 +18,7 @@ namespace extensions {
class APIPermissionSet;
class Extension;
+class ExtensionAPI;
class FeatureProvider;
class JSONFeatureProviderSource;
class ManifestPermissionSet;
@@ -82,9 +83,13 @@ class ExtensionsClient {
// Returns true iff a schema named |name| is generated.
virtual bool IsAPISchemaGenerated(const std::string& name) const = 0;
- // Gets the API schema named |name|.
+ // Gets the generated API schema named |name|.
virtual base::StringPiece GetAPISchema(const std::string& name) const = 0;
+ // Register non-generated API schema resources with the global ExtensionAPI.
+ // Called when the ExtensionAPI is lazily initialized.
+ virtual void RegisterAPISchemaResources(ExtensionAPI* api) const = 0;
+
// Determines if certain fatal extensions errors should be surpressed
// (i.e., only logged) or allowed (i.e., logged before crashing).
virtual bool ShouldSuppressFatalErrors() const = 0;
diff --git a/extensions/test/test_extensions_client.cc b/extensions/test/test_extensions_client.cc
index 7ef0277..8cee49a 100644
--- a/extensions/test/test_extensions_client.cc
+++ b/extensions/test/test_extensions_client.cc
@@ -85,6 +85,9 @@ base::StringPiece TestExtensionsClient::GetAPISchema(
return base::StringPiece();
}
+void TestExtensionsClient::RegisterAPISchemaResources(ExtensionAPI* api) const {
+}
+
bool TestExtensionsClient::ShouldSuppressFatalErrors() const {
return true;
}
diff --git a/extensions/test/test_extensions_client.h b/extensions/test/test_extensions_client.h
index 399f43f..be2acd7 100644
--- a/extensions/test/test_extensions_client.h
+++ b/extensions/test/test_extensions_client.h
@@ -38,6 +38,7 @@ class TestExtensionsClient : public ExtensionsClient {
virtual bool IsAPISchemaGenerated(const std::string& name) const OVERRIDE;
virtual base::StringPiece GetAPISchema(
const std::string& name) const OVERRIDE;
+ virtual void RegisterAPISchemaResources(ExtensionAPI* api) const OVERRIDE;
virtual bool ShouldSuppressFatalErrors() const OVERRIDE;
// A whitelist of extensions that can script anywhere. Do not add to this