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

Unified Diff: chrome/renderer/extensions/api_definitions_natives.cc

Issue 9918006: Split SchemaGeneratedBindings up into smaller, more targetted native handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/api_definitions_natives.h ('k') | chrome/renderer/extensions/event_bindings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/api_definitions_natives.cc
diff --git a/chrome/renderer/extensions/api_definitions_natives.cc b/chrome/renderer/extensions/api_definitions_natives.cc
new file mode 100644
index 0000000000000000000000000000000000000000..37621acda6a25193cf5156c401d6af66e482c4f8
--- /dev/null
+++ b/chrome/renderer/extensions/api_definitions_natives.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/api_definitions_natives.h"
+
+#include "chrome/common/extensions/api/extension_api.h"
+#include "chrome/renderer/extensions/user_script_slave.h"
+
+namespace extensions {
+
+ApiDefinitionsNatives::ApiDefinitionsNatives(
+ ExtensionDispatcher* extension_dispatcher)
+ : ChromeV8Extension(extension_dispatcher) {
+ RouteFunction("GetExtensionAPIDefinition",
+ base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinition,
+ base::Unretained(this)));
+}
+
+v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinition(
+ const v8::Arguments& args) {
+ ChromeV8Context* v8_context =
+ extension_dispatcher()->v8_context_set().GetCurrent();
+ CHECK(v8_context);
+
+ // TODO(kalman): This is being calculated twice, first in
+ // ExtensionDispatcher then again here. It might as well be a property of
+ // ChromeV8Context, however, this would require making ChromeV8Context take
+ // an Extension rather than an extension ID. In itself this is fine,
+ // however it does not play correctly with the "IsTestExtensionId" checks.
+ // We need to remove that first.
+ scoped_ptr<std::set<std::string> > apis;
+
+ const std::string& extension_id = v8_context->extension_id();
+ if (extension_dispatcher()->IsTestExtensionId(extension_id)) {
+ apis.reset(new std::set<std::string>());
+ // The minimal set of APIs that tests need.
+ apis->insert("extension");
+ } else {
+ apis = ExtensionAPI::GetSharedInstance()->GetAPIsForContext(
+ v8_context->context_type(),
+ extension_dispatcher()->extensions()->GetByID(extension_id),
+ UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame()));
+ }
+
+ return extension_dispatcher()->v8_schema_registry()->GetSchemas(*apis);
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/api_definitions_natives.h ('k') | chrome/renderer/extensions/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698