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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 source_map_.RegisterSource("binding", IDR_BINDING_JS); | 842 source_map_.RegisterSource("binding", IDR_BINDING_JS); |
843 | 843 |
844 // Platform app sources that are not API-specific.. | 844 // Platform app sources that are not API-specific.. |
845 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 845 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
846 // Note: webView not webview so that this doesn't interfere with the | 846 // Note: webView not webview so that this doesn't interfere with the |
847 // chrome.webview API bindings. | 847 // chrome.webview API bindings. |
848 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS); | 848 source_map_.RegisterSource("webView", IDR_WEB_VIEW_JS); |
849 source_map_.RegisterSource("webViewExperimental", | 849 source_map_.RegisterSource("webViewExperimental", |
850 IDR_WEB_VIEW_EXPERIMENTAL_JS); | 850 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
851 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); | 851 source_map_.RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); |
| 852 source_map_.RegisterSource("adView", IDR_AD_VIEW_JS); |
| 853 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 854 switches::kEnableAdviewSrcAttribute)) { |
| 855 source_map_.RegisterSource("adViewCustom", IDR_AD_VIEW_CUSTOM_JS); |
| 856 } |
| 857 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS); |
852 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 858 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
853 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 859 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
854 } | 860 } |
855 | 861 |
856 void Dispatcher::PopulateLazyBindingsMap() { | 862 void Dispatcher::PopulateLazyBindingsMap() { |
857 lazy_bindings_map_["app"] = InstallAppBindings; | 863 lazy_bindings_map_["app"] = InstallAppBindings; |
858 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 864 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
859 } | 865 } |
860 | 866 |
861 void Dispatcher::InstallBindings(ModuleSystem* module_system, | 867 void Dispatcher::InstallBindings(ModuleSystem* module_system, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 // The API will be automatically set up when first used. | 992 // The API will be automatically set up when first used. |
987 if (extension->HasAPIPermission(APIPermission::kWebView)) { | 993 if (extension->HasAPIPermission(APIPermission::kWebView)) { |
988 module_system->Require("webView"); | 994 module_system->Require("webView"); |
989 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) | 995 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) |
990 module_system->Require("webViewExperimental"); | 996 module_system->Require("webViewExperimental"); |
991 } else { | 997 } else { |
992 module_system->Require("denyWebView"); | 998 module_system->Require("denyWebView"); |
993 } | 999 } |
994 } | 1000 } |
995 | 1001 |
| 1002 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 1003 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { |
| 1004 if (extension->HasAPIPermission(APIPermission::kAdView)) { |
| 1005 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1006 switches::kEnableAdviewSrcAttribute)) { |
| 1007 module_system->Require("adViewCustom"); |
| 1008 } |
| 1009 module_system->Require("adView"); |
| 1010 } else { |
| 1011 module_system->Require("denyAdView"); |
| 1012 } |
| 1013 } |
| 1014 } |
| 1015 |
996 context->set_module_system(module_system.Pass()); | 1016 context->set_module_system(module_system.Pass()); |
997 | 1017 |
998 context->DispatchOnLoadEvent( | 1018 context->DispatchOnLoadEvent( |
999 ChromeRenderProcessObserver::is_incognito_process(), | 1019 ChromeRenderProcessObserver::is_incognito_process(), |
1000 manifest_version); | 1020 manifest_version); |
1001 | 1021 |
1002 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 1022 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
1003 } | 1023 } |
1004 | 1024 |
1005 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { | 1025 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1341 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
1322 v8::ThrowException( | 1342 v8::ThrowException( |
1323 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1343 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
1324 return false; | 1344 return false; |
1325 } | 1345 } |
1326 | 1346 |
1327 return true; | 1347 return true; |
1328 } | 1348 } |
1329 | 1349 |
1330 } // namespace extensions | 1350 } // namespace extensions |
OLD | NEW |