Index: chrome/renderer/extensions/dispatcher.cc |
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc |
index 2272778418389b2f1542601b7299073f84bf41ec..ffa93a445a461c50883d1aa9a91772f415e295f5 100644 |
--- a/chrome/renderer/extensions/dispatcher.cc |
+++ b/chrome/renderer/extensions/dispatcher.cc |
@@ -41,6 +41,7 @@ |
#include "chrome/renderer/extensions/page_capture_custom_bindings.h" |
#include "chrome/renderer/extensions/request_sender.h" |
#include "chrome/renderer/extensions/runtime_custom_bindings.h" |
+#include "chrome/renderer/extensions/schema_generated_native_handler.h" |
#include "chrome/renderer/extensions/send_request_natives.h" |
#include "chrome/renderer/extensions/set_icon_natives.h" |
#include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" |
@@ -550,6 +551,41 @@ bool Dispatcher::AllowScriptExtension(WebFrame* frame, |
return true; |
} |
+void Dispatcher::RegisterSchemaGeneratedBindings( |
+ ModuleSystem* module_system, |
+ ChromeV8Context* context, |
+ v8::Handle<v8::Context> v8_context, |
+ Feature::Context feature_context) { |
+ // TODO: Change this to ExtensionAPI::GetAPIsForContext()? |
+ // const std::set<std::string>& apis = context->GetAvailableExtensionAPIs(); |
+ scoped_ptr<std::set<std::string> > apis = |
+ ExtensionAPI::GetSharedInstance()->GetAllAPINames(); |
+ for (std::set<std::string>::iterator it = apis->begin(); |
+ it != apis->end(); ++it) { |
+ const std::string& api_name = *it; |
+ // If there isn't already a custom binding for this API, we need to make |
+ // sure one exists to load the schema. Otherwise the custom binding will |
+ // need to do it itself. Either way, register it on the chrome object to be |
+ // loaded lazily. |
+ if (!module_system->HasNativeHandler(api_name)) { |
+ module_system->RegisterNativeHandler( |
+ api_name, |
+ scoped_ptr<NativeHandler>( |
+ new SchemaGeneratedNativeHandler(v8_schema_registry(), |
+ api_name, |
+ "schema"))); |
+ module_system->SetLazyField(GetOrCreateChrome(v8_context), |
+ api_name, |
+ "schema_binding_generator", |
+ "generate", |
+ api_name); |
+ } else { |
+ // TODO: Make this lazy. |
not at google - send to devlin
2012/12/13 22:26:40
Yep - the idea is to pull the SetLazyField out of
|
+ InstallBindings(module_system, v8_context, api_name); |
+ } |
+ } |
+} |
+ |
void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
ChromeV8Context* context) { |
module_system->RegisterNativeHandler("event_bindings", |
@@ -675,6 +711,8 @@ void Dispatcher::PopulateSourceMap() { |
source_map_.RegisterSource("webRequestInternal", |
IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
+ source_map_.RegisterSource("schema_binding_generator", |
+ IDR_SCHEMA_BINDING_GENERATOR_JS); |
// Platform app sources that are not API-specific.. |
source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
@@ -781,27 +819,26 @@ void Dispatcher::DidCreateScriptContext( |
// TODO(kalman): see comment below about ExtensionAPI. |
InstallBindings(module_system.get(), v8_context, "app"); |
InstallBindings(module_system.get(), v8_context, "webstore"); |
- break; |
+ // TODO: Move this back down to next case. |
not at google - send to devlin
2012/12/13 22:26:40
Why is it up here?
cduvall
2012/12/14 00:25:18
Just so I could make sure everything was working.
|
+ RegisterSchemaGeneratedBindings(module_system.get(), |
+ context, |
+ v8_context, |
+ context_type); |
+ break; |
case Feature::BLESSED_EXTENSION_CONTEXT: |
case Feature::UNBLESSED_EXTENSION_CONTEXT: |
case Feature::CONTENT_SCRIPT_CONTEXT: { |
CHECK(extension); |
if (!extension->is_platform_app()) |
module_system->Require("miscellaneous_bindings"); |
- module_system->Require("schema_generated_bindings"); |
+ // module_system->Require("schema_generated_bindings"); |
module_system->Require("apitest"); |
// TODO(kalman): move this code back out of the switch and execute it |
// regardless of |context_type|. ExtensionAPI knows how to return the |
// correct APIs, however, until it doesn't have a 2MB overhead we can't |
// load it in every process. |
- const std::set<std::string>& apis = context->GetAvailableExtensionAPIs(); |
- for (std::set<std::string>::const_iterator i = apis.begin(); |
- i != apis.end(); ++i) { |
- InstallBindings(module_system.get(), v8_context, *i); |
- } |
- |
break; |
} |
} |