diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 10:59:05 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 10:59:05 +0000 |
commit | ba1b0a360e4b03284b4fcfcd78377908b7eb5c55 (patch) | |
tree | 0b4a8e219be9f42d43cbc728a8717a22fc1ed4f3 /chrome/renderer/extensions | |
parent | 12f4fb9b3b5f32e9822375671225a5a3dd0ed628 (diff) | |
download | chromium_src-ba1b0a360e4b03284b4fcfcd78377908b7eb5c55.zip chromium_src-ba1b0a360e4b03284b4fcfcd78377908b7eb5c55.tar.gz chromium_src-ba1b0a360e4b03284b4fcfcd78377908b7eb5c55.tar.bz2 |
Revert 137388 - Move declarative API into events API
The motivation of this CL is to bring the declarative API and the rest of the
events mechanism closer together in the API documentation. To achive this, we
move the content of declarative.json and everything related to events from
extension.json into the events.json API definition. The new "events" namespace
is automatically provided to all extensions.
BUG=126497,112155
TEST=no
Review URL: https://chromiumcodereview.appspot.com/10392008
TBR=battre@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10389168
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/extensions')
4 files changed, 5 insertions, 37 deletions
diff --git a/chrome/renderer/extensions/api_definitions_natives.cc b/chrome/renderer/extensions/api_definitions_natives.cc index 2bcbc28..bc8b4b0 100644 --- a/chrome/renderer/extensions/api_definitions_natives.cc +++ b/chrome/renderer/extensions/api_definitions_natives.cc @@ -4,12 +4,6 @@ #include "chrome/renderer/extensions/api_definitions_natives.h" -#include <algorithm> - -namespace { -const char kInvalidExtensionNamespace[] = "Invalid extension namespace"; -} - namespace extensions { ApiDefinitionsNatives::ApiDefinitionsNatives( @@ -25,29 +19,8 @@ v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinition( ChromeV8Context* v8_context = extension_dispatcher()->v8_context_set().GetCurrent(); CHECK(v8_context); - - std::set<std::string> available_apis(v8_context->GetAvailableExtensionAPIs()); - if (args.Length() == 0) { - return extension_dispatcher()->v8_schema_registry()->GetSchemas( - available_apis); - } - // Build set of APIs requested by the user. - std::set<std::string> requested_apis; - for (int i = 0; i < args.Length(); ++i) { - if (!args[i]->IsString()) { - v8::ThrowException(v8::String::New(kInvalidExtensionNamespace)); - return v8::Undefined(); - } - requested_apis.insert(*v8::String::Utf8Value(args[i]->ToString())); - } - - // Filter those that are unknown. - std::set<std::string> apis_to_check; - std::set_intersection(requested_apis.begin(), requested_apis.end(), - available_apis.begin(), available_apis.end(), - std::inserter(apis_to_check, apis_to_check.begin())); return extension_dispatcher()->v8_schema_registry()->GetSchemas( - apis_to_check); + v8_context->GetAvailableExtensionAPIs()); } } // namespace extensions diff --git a/chrome/renderer/extensions/api_definitions_natives.h b/chrome/renderer/extensions/api_definitions_natives.h index 269728b..48a9abe 100644 --- a/chrome/renderer/extensions/api_definitions_natives.h +++ b/chrome/renderer/extensions/api_definitions_natives.h @@ -19,9 +19,8 @@ class ApiDefinitionsNatives : public ChromeV8Extension { explicit ApiDefinitionsNatives(ExtensionDispatcher* extension_dispatcher); private: - // Returns the list of schemas that are available to the calling context - // and have their names listed in |args|. If |args| is empty, returns the list - // of all schemas that are available to the calling context. + // Takes no arguments and returns the list of schemas that are available to + // the calling context. v8::Handle<v8::Value> GetExtensionAPIDefinition(const v8::Arguments& args); DISALLOW_COPY_AND_ASSIGN(ApiDefinitionsNatives); diff --git a/chrome/renderer/extensions/event_unittest.cc b/chrome/renderer/extensions/event_unittest.cc index 61fa9ca..ca1d9b04 100644 --- a/chrome/renderer/extensions/event_unittest.cc +++ b/chrome/renderer/extensions/event_unittest.cc @@ -14,7 +14,6 @@ class EventUnittest : public ModuleSystemTest { module_system_->RunString("chrome = {};", "setup-chrome"); RegisterModule("event", IDR_EVENT_BINDINGS_JS); - RegisterModule("utils", IDR_UTILS_JS); // Mock out the native handler for event_bindings. These mocks will fail if // any invariants maintained by the real event_bindings are broken. @@ -32,10 +31,6 @@ class EventUnittest : public ModuleSystemTest { OverrideNativeHandler("chrome_hidden", "var chromeHidden = {};" "exports.GetChromeHidden = function() { return chromeHidden; };"); - OverrideNativeHandler("sendRequest", - "exports.sendRequest = function() {};"); - OverrideNativeHandler("apiDefinitions", - "exports.GetExtensionAPIDefinition = function() {};"); } }; diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 32c0b1d..1d96259 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -508,7 +508,6 @@ void ExtensionDispatcher::PopulateSourceMap() { // Libraries. source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS); source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS); - source_map_.RegisterSource("utils", IDR_UTILS_JS); // Custom bindings. source_map_.RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS); @@ -518,6 +517,8 @@ void ExtensionDispatcher::PopulateSourceMap() { IDR_CONTENT_SETTINGS_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("contextMenus", IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS); + source_map_.RegisterSource("declarative", + IDR_DECLARATIVE_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("declarativeWebRequest", IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("devtools", IDR_DEVTOOLS_CUSTOM_BINDINGS_JS); |