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

Side by Side Diff: chrome/renderer/extensions/dispatcher.cc

Issue 12522004: Lazily load extension API schemas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 BackgroundInfo::HasLazyBackgroundPage(extension)); 943 BackgroundInfo::HasLazyBackgroundPage(extension));
944 module_system->RegisterNativeHandler("process", 944 module_system->RegisterNativeHandler("process",
945 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( 945 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
946 this, v8_context, context->GetExtensionID(), 946 this, v8_context, context->GetExtensionID(),
947 context->GetContextTypeDescription(), 947 context->GetContextTypeDescription(),
948 ChromeRenderProcessObserver::is_incognito_process(), 948 ChromeRenderProcessObserver::is_incognito_process(),
949 manifest_version, send_request_disabled))); 949 manifest_version, send_request_disabled)));
950 950
951 GetOrCreateChrome(v8_context); 951 GetOrCreateChrome(v8_context);
952 952
953 // Loading JavaScript is expensive, so only run the full API bindings 953 if (extension && !extension->is_platform_app())
not at google - send to devlin 2013/03/22 18:13:48 I'm happy every time I see this!
954 // generation mechanisms in extension pages (NOT all web pages). 954 module_system->Require("miscellaneous_bindings");
955 switch (context_type) { 955 module_system->Require("json"); // see paranoid comment in json.js
not at google - send to devlin 2013/03/22 18:13:48 hm, this might end up being a problem. maybe. I ju
cduvall 2013/03/22 20:26:45 Done.
956 case Feature::UNSPECIFIED_CONTEXT: 956 RegisterSchemaGeneratedBindings(module_system.get(),
957 case Feature::WEB_PAGE_CONTEXT: 957 context,
958 // TODO(kalman): see comment below about ExtensionAPI. 958 v8_context);
959 InstallBindings(module_system.get(), v8_context, "app"); 959 InstallBindings(module_system.get(), v8_context, "app");
960 InstallBindings(module_system.get(), v8_context, "webstore"); 960 InstallBindings(module_system.get(), v8_context, "webstore");
not at google - send to devlin 2013/03/22 18:13:48 with this patch these two lines might actually be
cduvall 2013/03/22 20:26:45 Done.
961 break;
962 case Feature::BLESSED_EXTENSION_CONTEXT:
963 case Feature::UNBLESSED_EXTENSION_CONTEXT:
964 case Feature::CONTENT_SCRIPT_CONTEXT: {
965 if (extension && !extension->is_platform_app())
966 module_system->Require("miscellaneous_bindings");
967 module_system->Require("json"); // see paranoid comment in json.js
968
969 // TODO(kalman): move this code back out of the switch and execute it
970 // regardless of |context_type|. ExtensionAPI knows how to return the
971 // correct APIs, however, until it doesn't have a 2MB overhead we can't
972 // load it in every process.
973 RegisterSchemaGeneratedBindings(module_system.get(),
974 context,
975 v8_context);
976 break;
977 }
978 }
979 961
980 bool is_within_platform_app = IsWithinPlatformApp(frame); 962 bool is_within_platform_app = IsWithinPlatformApp(frame);
981 // Inject custom JS into the platform app context. 963 // Inject custom JS into the platform app context.
982 if (is_within_platform_app) 964 if (is_within_platform_app)
983 module_system->Require("platformApp"); 965 module_system->Require("platformApp");
984 966
985 // Only platform apps support the <webview> tag, because the "webView" and 967 // Only platform apps support the <webview> tag, because the "webView" and
986 // "denyWebView" modules will affect the performance of DOM modifications 968 // "denyWebView" modules will affect the performance of DOM modifications
987 // (http://crbug.com/196453). 969 // (http://crbug.com/196453).
988 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && 970 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); 1308 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str());
1327 v8::ThrowException( 1309 v8::ThrowException(
1328 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1310 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1329 return false; 1311 return false;
1330 } 1312 }
1331 1313
1332 return true; 1314 return true;
1333 } 1315 }
1334 1316
1335 } // namespace extensions 1317 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698