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

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: fix koz bool thing 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
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?
Aaron Boodman 2012/03/06 01:17:21 What is the value in that. This should only be get
not at google - send to devlin 2012/03/06 03:53:00 Because it's getting called many times per context
Aaron Boodman 2012/03/06 08:18:12 Completely agree about removing IsAPIAllowed.
not at google - send to devlin 2012/03/06 11:36:46 Done. Also means that ContextInfoNativeHandler can
+ 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());
Aaron Boodman 2012/03/06 01:17:21 Not your bug, but we should just create one utilit
not at google - send to devlin 2012/03/06 03:53:00 Chatting to koz, he says it shouldn't be using Con
koz (OOO until 15th September) 2012/03/06 04:06:58 I'm not familiar with this usage of Context - isn'
Aaron Boodman 2012/03/06 08:18:12 Explained to kalman in irc.
not at google - send to devlin 2012/03/06 11:36:46 TODO added.
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;
}

Powered by Google App Engine
This is Rietveld 408576698