Chromium Code Reviews| Index: chrome/renderer/extensions/extension_dispatcher.cc |
| diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc |
| index 1833d64cfa85c23499ccefccec4af4b16bba2fd4..84e41a0ca7d4d0342c9646021ee63dd7cde2f226 100644 |
| --- a/chrome/renderer/extensions/extension_dispatcher.cc |
| +++ b/chrome/renderer/extensions/extension_dispatcher.cc |
| @@ -118,6 +118,24 @@ class PrintNativeHandler : public NativeHandler { |
| } |
| }; |
| +void InstallAppBindings(ModuleSystem* module_system, |
| + v8::Handle<v8::Object> chrome, |
| + v8::Handle<v8::Object> chrome_hidden) { |
| + module_system->SetLazyField(chrome, "app", "app", "chromeApp"); |
| + module_system->SetLazyField(chrome, "appNotifications", "app", |
|
not at google - send to devlin
2012/03/25 22:42:58
add TODO to pull appNotifications out into its own
koz (OOO until 15th September)
2012/03/26 01:36:09
The 'app' module has variables in it that are shar
not at google - send to devlin
2012/03/26 02:29:49
I don't think they do really; rather I think that
koz (OOO until 15th September)
2012/03/26 03:58:59
Ah, true. Though looking at the code I see that th
|
| + "chromeAppNotifications"); |
| + module_system->SetLazyField(chrome_hidden, "app", "app", |
| + "chromeHiddenApp"); |
| +} |
| + |
| +void InstallWebstoreBindings(ModuleSystem* module_system, |
| + v8::Handle<v8::Object> chrome, |
| + v8::Handle<v8::Object> chrome_hidden) { |
| + module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore"); |
| + module_system->SetLazyField(chrome_hidden, "webstore", "webstore", |
| + "chromeHiddenWebstore"); |
| +} |
|
not at google - send to devlin
2012/03/25 22:42:58
I guess this isn't scalable to arbitrary APIs.
No
koz (OOO until 15th September)
2012/03/26 01:36:09
You mean being able to make arbitrary modules lazy
not at google - send to devlin
2012/03/26 02:29:49
Yeah agreed.
|
| + |
| } |
| ExtensionDispatcher::ExtensionDispatcher() |
| @@ -471,6 +489,10 @@ void ExtensionDispatcher::DidCreateScriptContext( |
| if (extension) |
| manifest_version = extension->manifest_version(); |
|
not at google - send to devlin
2012/03/25 22:42:58
could just have the typedef here?
koz (OOO until 15th September)
2012/03/26 01:36:09
Done.
|
| + std::map<std::string, BindingInstaller> optimized_bindings; |
| + optimized_bindings["app"] = InstallAppBindings; |
| + optimized_bindings["webstore"] = InstallWebstoreBindings; |
|
not at google - send to devlin
2012/03/25 22:42:58
lazy_bindings?
koz (OOO until 15th September)
2012/03/26 01:36:09
Nice. Done.
|
| + |
| // Create the 'chrome' variable if it doesn't already exist. |
| { |
| v8::HandleScope handle_scope; |
| @@ -513,6 +535,15 @@ void ExtensionDispatcher::DidCreateScriptContext( |
| for (std::set<std::string>::iterator i = apis->begin(); i != apis->end(); |
| ++i) { |
| + if (optimized_bindings.count(*i) > 0) { |
|
not at google - send to devlin
2012/03/25 22:42:58
nit: use find() here, ->second below.
koz (OOO until 15th September)
2012/03/26 01:36:09
Done.
|
| + v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); |
| + v8::Handle<v8::Object> chrome = |
| + global->Get(v8::String::New("chrome"))->ToObject(); |
|
not at google - send to devlin
2012/03/25 22:42:58
re-use the reference to "chrome" from the one crea
koz (OOO until 15th September)
2012/03/26 01:36:09
I think better to not. This method is already way
|
| + v8::Handle<v8::Object> chrome_hidden = |
| + ChromeV8Context::GetOrCreateChromeHidden(v8_context)->ToObject(); |
| + optimized_bindings[*i](module_system.get(), chrome, chrome_hidden); |
| + continue; |
| + } |
|
not at google - send to devlin
2012/03/25 22:42:58
nit: else not continue
koz (OOO until 15th September)
2012/03/26 01:36:09
Done.
|
| module_system->Require(*i); |
| } |