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

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

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with koz patch! Created 8 years, 10 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
diff --git a/chrome/renderer/extensions/schema_generated_bindings.cc b/chrome/renderer/extensions/schema_generated_bindings.cc
index 0af9c0e145afd0218543cd7de9cfdc8bfabc0f0c..b1102ca372c27b3d2a21ecb0cd7300e258a31cc6 100644
--- a/chrome/renderer/extensions/schema_generated_bindings.cc
+++ b/chrome/renderer/extensions/schema_generated_bindings.cc
@@ -118,30 +118,28 @@ class ExtensionImpl : public ChromeV8Extension {
ChromeV8Context* v8_context = dispatcher->v8_context_set().GetCurrent();
CHECK(v8_context);
- std::string extension_id = v8_context->extension_id();
- ExtensionAPI::SchemaMap schemas;
- ExtensionAPI::GetSchemasFilter filter =
- dispatcher->is_extension_process() ?
- ExtensionAPI::ALL : ExtensionAPI::ONLY_UNPRIVILEGED;
+ // TODO(kalman): can we just cache this in the ChromeV8Context instance?
not at google - send to devlin 2012/03/05 07:46:54 I added this TODO for the duration of the code rev
+ scoped_ptr<std::set<std::string> > apis;
+ const std::string& extension_id = v8_context->extension_id();
if (dispatcher->IsTestExtensionId(extension_id)) {
- ExtensionAPI::GetInstance()->GetDefaultSchemas(filter, &schemas);
+ apis.reset(new std::set<std::string>());
+ // The minimal set of APIs that tests need.
+ apis->insert("extension");
} else {
- const ::Extension* extension =
- dispatcher->extensions()->GetByID(extension_id);
- CHECK(extension) << extension_id << " not found";
- ExtensionAPI::GetInstance()->GetSchemasForExtension(
- *extension, filter, &schemas);
+ apis = ExtensionAPI::GetInstance()->GetAPIsForContext(
+ v8_context->context_type(),
+ dispatcher->extensions()->GetByID(extension_id),
+ UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame()));
}
v8::Persistent<v8::Context> context(v8::Context::New());
v8::Context::Scope context_scope(context);
- v8::Handle<v8::Array> api(v8::Array::New(schemas.size()));
+ v8::Handle<v8::Array> api(v8::Array::New(apis->size()));
size_t api_index = 0;
- 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));
+ for (std::set<std::string>::iterator i = apis->begin(); i != apis->end();
+ ++i) {
+ api->Set(api_index, GetV8SchemaForAPI(self, context, *i));
++api_index;
}
« 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