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

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

Issue 9653022: Revert 125811 - Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/extension_dispatcher.cc ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/schema_generated_bindings.cc
===================================================================
--- chrome/renderer/extensions/schema_generated_bindings.cc (revision 125812)
+++ chrome/renderer/extensions/schema_generated_bindings.cc (working copy)
@@ -118,32 +118,30 @@
ChromeV8Context* v8_context = dispatcher->v8_context_set().GetCurrent();
CHECK(v8_context);
- // TODO(kalman): can we just cache this in the ChromeV8Context instance?
- scoped_ptr<std::set<std::string> > apis;
+ std::string extension_id = v8_context->extension_id();
+ ExtensionAPI::SchemaMap schemas;
+ ExtensionAPI::GetSchemasFilter filter =
+ dispatcher->is_extension_process() ?
+ ExtensionAPI::ALL : ExtensionAPI::ONLY_UNPRIVILEGED;
- const std::string& extension_id = v8_context->extension_id();
if (dispatcher->IsTestExtensionId(extension_id)) {
- apis.reset(new std::set<std::string>());
- // The minimal set of APIs that tests need.
- apis->insert("extension");
+ ExtensionAPI::GetInstance()->GetDefaultSchemas(filter, &schemas);
} else {
- apis = ExtensionAPI::GetInstance()->GetAPIsForContext(
- v8_context->context_type(),
- dispatcher->extensions()->GetByID(extension_id),
- UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame()));
+ const ::Extension* extension =
+ dispatcher->extensions()->GetByID(extension_id);
+ CHECK(extension) << extension_id << " not found";
+ ExtensionAPI::GetInstance()->GetSchemasForExtension(
+ *extension, filter, &schemas);
}
v8::Persistent<v8::Context> context(v8::Context::New());
v8::Context::Scope context_scope(context);
- v8::Handle<v8::Array> api(v8::Array::New(apis->size()));
+ v8::Handle<v8::Array> api(v8::Array::New(schemas.size()));
size_t api_index = 0;
- for (std::set<std::string>::iterator i = apis->begin(); i != apis->end();
- ++i) {
- // TODO(kalman): this caching is actually useless now, because
- // SchemaGeneratedBindings is per-context not per-process. We should
- // (e.g.) hang a SchemaRegistry off ExtensionDispatcher (which maintains
- // a *single* v8::Context rather than multiple ones as here).
- api->Set(api_index, GetV8SchemaForAPI(self, context, *i));
+ for (ExtensionAPI::SchemaMap::iterator it = schemas.begin();
+ it != schemas.end(); ++it) {
+ std::string api_name = it->first;
+ api->Set(api_index, GetV8SchemaForAPI(self, context, api_name));
++api_index;
}
@@ -325,7 +323,6 @@
namespace extensions {
-// static
ChromeV8Extension* SchemaGeneratedBindings::Get(
ExtensionDispatcher* extension_dispatcher) {
return new ExtensionImpl(extension_dispatcher);
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698