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

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

Issue 17104003: Improvements to fatal JavaScript extension errors: (1) include the extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: channel restriction Created 7 years, 6 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/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 base::Unretained(this))); 297 base::Unretained(this)));
298 RouteFunction("InIncognitoContext", 298 RouteFunction("InIncognitoContext",
299 base::Bind(&ProcessInfoNativeHandler::InIncognitoContext, 299 base::Bind(&ProcessInfoNativeHandler::InIncognitoContext,
300 base::Unretained(this))); 300 base::Unretained(this)));
301 RouteFunction("GetManifestVersion", 301 RouteFunction("GetManifestVersion",
302 base::Bind(&ProcessInfoNativeHandler::GetManifestVersion, 302 base::Bind(&ProcessInfoNativeHandler::GetManifestVersion,
303 base::Unretained(this))); 303 base::Unretained(this)));
304 RouteFunction("IsSendRequestDisabled", 304 RouteFunction("IsSendRequestDisabled",
305 base::Bind(&ProcessInfoNativeHandler::IsSendRequestDisabled, 305 base::Bind(&ProcessInfoNativeHandler::IsSendRequestDisabled,
306 base::Unretained(this))); 306 base::Unretained(this)));
307 RouteFunction("HasSwitch",
308 base::Bind(&ProcessInfoNativeHandler::HasSwitch,
309 base::Unretained(this)));
307 } 310 }
308 311
312 private:
309 void GetExtensionId(const v8::FunctionCallbackInfo<v8::Value>& args) { 313 void GetExtensionId(const v8::FunctionCallbackInfo<v8::Value>& args) {
310 args.GetReturnValue().Set(v8::String::New(extension_id_.c_str())); 314 args.GetReturnValue().Set(v8::String::New(extension_id_.c_str()));
311 } 315 }
312 316
313 void GetContextType(const v8::FunctionCallbackInfo<v8::Value>& args) { 317 void GetContextType(const v8::FunctionCallbackInfo<v8::Value>& args) {
314 args.GetReturnValue().Set(v8::String::New(context_type_.c_str())); 318 args.GetReturnValue().Set(v8::String::New(context_type_.c_str()));
315 } 319 }
316 320
317 void InIncognitoContext(const v8::FunctionCallbackInfo<v8::Value>& args) { 321 void InIncognitoContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
318 args.GetReturnValue().Set(is_incognito_context_); 322 args.GetReturnValue().Set(is_incognito_context_);
319 } 323 }
320 324
321 void GetManifestVersion(const v8::FunctionCallbackInfo<v8::Value>& args) { 325 void GetManifestVersion(const v8::FunctionCallbackInfo<v8::Value>& args) {
322 args.GetReturnValue().Set(static_cast<int32_t>(manifest_version_)); 326 args.GetReturnValue().Set(static_cast<int32_t>(manifest_version_));
323 } 327 }
324 328
325 void IsSendRequestDisabled(const v8::FunctionCallbackInfo<v8::Value>& args) { 329 void IsSendRequestDisabled(const v8::FunctionCallbackInfo<v8::Value>& args) {
326 if (send_request_disabled_) { 330 if (send_request_disabled_) {
327 args.GetReturnValue().Set(v8::String::New( 331 args.GetReturnValue().Set(v8::String::New(
328 "sendRequest and onRequest are obsolete." 332 "sendRequest and onRequest are obsolete."
329 " Please use sendMessage and onMessage instead.")); 333 " Please use sendMessage and onMessage instead."));
330 } 334 }
331 } 335 }
332 336
333 private: 337 void HasSwitch(const v8::FunctionCallbackInfo<v8::Value>& args) {
338 CHECK(args.Length() == 1 && args[0]->IsString());
339 bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch(
340 *v8::String::AsciiValue(args[0]));
341 args.GetReturnValue().Set(v8::Boolean::New(has_switch));
342 }
343
334 std::string extension_id_; 344 std::string extension_id_;
335 std::string context_type_; 345 std::string context_type_;
336 bool is_incognito_context_; 346 bool is_incognito_context_;
337 int manifest_version_; 347 int manifest_version_;
338 bool send_request_disabled_; 348 bool send_request_disabled_;
339 }; 349 };
340 350
341 void InstallAppBindings(ModuleSystem* module_system, 351 void InstallAppBindings(ModuleSystem* module_system,
342 v8::Handle<v8::Object> chrome) { 352 v8::Handle<v8::Object> chrome) {
343 module_system->SetLazyField(chrome, "app", "app", "chromeApp"); 353 module_system->SetLazyField(chrome, "app", "app", "chromeApp");
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 974
965 // Platform app sources that are not API-specific.. 975 // Platform app sources that are not API-specific..
966 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); 976 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS);
967 // Note: webView not webview so that this doesn't interfere with the 977 // Note: webView not webview so that this doesn't interfere with the
968 // chrome.webview API bindings. 978 // chrome.webview API bindings.
969 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS); 979 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS);
970 source_map_.RegisterSource("webViewExperimental", 980 source_map_.RegisterSource("webViewExperimental",
971 IDR_WEB_VIEW_EXPERIMENTAL_JS); 981 IDR_WEB_VIEW_EXPERIMENTAL_JS);
972 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); 982 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS);
973 source_map_.RegisterSource("adView", IDR_AD_VIEW_JS); 983 source_map_.RegisterSource("adView", IDR_AD_VIEW_JS);
974 if (CommandLine::ForCurrentProcess()->HasSwitch(
975 switches::kEnableAdviewSrcAttribute)) {
976 source_map_.RegisterSource("adViewCustom", IDR_AD_VIEW_CUSTOM_JS);
977 }
978 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS); 984 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS);
979 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); 985 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS);
980 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); 986 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS);
981 } 987 }
982 988
983 void Dispatcher::PopulateLazyBindingsMap() { 989 void Dispatcher::PopulateLazyBindingsMap() {
984 lazy_bindings_map_["app"] = InstallAppBindings; 990 lazy_bindings_map_["app"] = InstallAppBindings;
985 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; 991 lazy_bindings_map_["webstore"] = InstallWebstoreBindings;
986 } 992 }
987 993
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 } else { 1113 } else {
1108 module_system->Require("denyWebView"); 1114 module_system->Require("denyWebView");
1109 } 1115 }
1110 } 1116 }
1111 1117
1112 // Same comment as above for <adview> tag. 1118 // Same comment as above for <adview> tag.
1113 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && 1119 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
1114 is_within_platform_app) { 1120 is_within_platform_app) {
1115 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { 1121 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) {
1116 if (extension->HasAPIPermission(APIPermission::kAdView)) { 1122 if (extension->HasAPIPermission(APIPermission::kAdView)) {
1117 if (CommandLine::ForCurrentProcess()->HasSwitch(
1118 switches::kEnableAdviewSrcAttribute)) {
1119 module_system->Require("adViewCustom");
1120 }
1121 module_system->Require("adView"); 1123 module_system->Require("adView");
1122 } else { 1124 } else {
1123 module_system->Require("denyAdView"); 1125 module_system->Require("denyAdView");
1124 } 1126 }
1125 } 1127 }
1126 } 1128 }
1127 1129
1128 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); 1130 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size();
1129 } 1131 }
1130 1132
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 RenderView* background_view = 1507 RenderView* background_view =
1506 ExtensionHelper::GetBackgroundPage(extension_id); 1508 ExtensionHelper::GetBackgroundPage(extension_id);
1507 if (background_view) { 1509 if (background_view) {
1508 background_view->Send(new ExtensionHostMsg_EventAck( 1510 background_view->Send(new ExtensionHostMsg_EventAck(
1509 background_view->GetRoutingID())); 1511 background_view->GetRoutingID()));
1510 } 1512 }
1511 } 1513 }
1512 } 1514 }
1513 1515
1514 } // namespace extensions 1516 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context_set.cc ('k') | chrome/renderer/extensions/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698