OLD | NEW |
---|---|
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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
837 source_map_.RegisterSource("binding", IDR_BINDING_JS); | 837 source_map_.RegisterSource("binding", IDR_BINDING_JS); |
838 | 838 |
839 // Platform app sources that are not API-specific.. | 839 // Platform app sources that are not API-specific.. |
840 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 840 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
841 // Note: webView not webview so that this doesn't interfere with the | 841 // Note: webView not webview so that this doesn't interfere with the |
842 // chrome.webview API bindings. | 842 // chrome.webview API bindings. |
843 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS); | 843 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS); |
844 source_map_.RegisterSource("webViewExperimental", | 844 source_map_.RegisterSource("webViewExperimental", |
845 IDR_WEB_VIEW_EXPERIMENTAL_JS); | 845 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
846 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); | 846 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); |
847 source_map_.RegisterSource("adView", IDR_AD_VIEW_JS); | |
848 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
849 switches::kEnableAdviewSrcAttribute)) { | |
850 source_map_.RegisterSource("adViewCustom", IDR_AD_VIEW_CUSTOM_JS); | |
851 } | |
852 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS); | |
847 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 853 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
848 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 854 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
849 } | 855 } |
850 | 856 |
851 void Dispatcher::PopulateLazyBindingsMap() { | 857 void Dispatcher::PopulateLazyBindingsMap() { |
852 lazy_bindings_map_["app"] = InstallAppBindings; | 858 lazy_bindings_map_["app"] = InstallAppBindings; |
853 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 859 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
854 } | 860 } |
855 | 861 |
856 void Dispatcher::InstallBindings(ModuleSystem* module_system, | 862 void Dispatcher::InstallBindings(ModuleSystem* module_system, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 // The API will be automatically set up when first used. | 987 // The API will be automatically set up when first used. |
982 if (extension->HasAPIPermission(APIPermission::kWebView)) { | 988 if (extension->HasAPIPermission(APIPermission::kWebView)) { |
983 module_system->Require("webView"); | 989 module_system->Require("webView"); |
984 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) | 990 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) |
985 module_system->Require("webViewExperimental"); | 991 module_system->Require("webViewExperimental"); |
986 } else { | 992 } else { |
987 module_system->Require("denyWebView"); | 993 module_system->Require("denyWebView"); |
988 } | 994 } |
989 } | 995 } |
990 | 996 |
997 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | |
Fady Samuel
2013/03/18 18:48:05
https://codereview.chromium.org/12496015/patch/300
| |
998 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { | |
999 if (extension->HasAPIPermission(APIPermission::kAdView)) { | |
1000 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
1001 switches::kEnableAdviewSrcAttribute)) { | |
1002 module_system->Require("adViewCustom"); | |
1003 } | |
1004 module_system->Require("adView"); | |
1005 } else { | |
1006 module_system->Require("denyAdView"); | |
1007 } | |
1008 } | |
1009 } | |
1010 | |
991 context->set_module_system(module_system.Pass()); | 1011 context->set_module_system(module_system.Pass()); |
992 | 1012 |
993 context->DispatchOnLoadEvent( | 1013 context->DispatchOnLoadEvent( |
994 ChromeRenderProcessObserver::is_incognito_process(), | 1014 ChromeRenderProcessObserver::is_incognito_process(), |
995 manifest_version); | 1015 manifest_version); |
996 | 1016 |
997 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 1017 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
998 } | 1018 } |
999 | 1019 |
1000 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { | 1020 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1316 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1336 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
1317 v8::ThrowException( | 1337 v8::ThrowException( |
1318 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1338 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
1319 return false; | 1339 return false; |
1320 } | 1340 } |
1321 | 1341 |
1322 return true; | 1342 return true; |
1323 } | 1343 } |
1324 | 1344 |
1325 } // namespace extensions | 1345 } // namespace extensions |
OLD | NEW |