Index: chrome/renderer/extensions/dispatcher.cc |
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc |
index 30b65258abc6a3f7e837b3fc2debe53143140be5..8da074ce0c68621cf28033ef757625135aa0c87d 100644 |
--- a/chrome/renderer/extensions/dispatcher.cc |
+++ b/chrome/renderer/extensions/dispatcher.cc |
@@ -1028,13 +1028,29 @@ void Dispatcher::DidCreateScriptContext( |
GetOrCreateChrome(v8_context); |
- // TODO(kalman): see comment below about ExtensionAPI. |
- if (extension && !extension->is_platform_app()) |
- module_system->Require("miscellaneous_bindings"); |
- if (context_type != Feature::WEB_PAGE_CONTEXT) |
- module_system->Require("json"); // see paranoid comment in json.js |
- |
- RegisterSchemaGeneratedBindings(module_system.get(), context); |
+ // Loading JavaScript is expensive, so only run the full API bindings |
+ // generation mechanisms in extension pages (NOT all web pages). |
+ switch (context_type) { |
+ case Feature::UNSPECIFIED_CONTEXT: |
+ case Feature::WEB_PAGE_CONTEXT: |
+ // TODO(kalman): see comment below about ExtensionAPI. |
+ InstallBindings(module_system.get(), v8_context, "app"); |
+ InstallBindings(module_system.get(), v8_context, "webstore"); |
+ break; |
+ case Feature::BLESSED_EXTENSION_CONTEXT: |
+ case Feature::UNBLESSED_EXTENSION_CONTEXT: |
+ case Feature::CONTENT_SCRIPT_CONTEXT: |
+ if (extension && !extension->is_platform_app()) |
+ module_system->Require("miscellaneous_bindings"); |
+ module_system->Require("json"); // see paranoid comment in json.js |
+ |
+ // 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. |
+ RegisterSchemaGeneratedBindings(module_system.get(), context); |
+ break; |
+ } |
bool is_within_platform_app = IsWithinPlatformApp(frame); |
// Inject custom JS into the platform app context. |