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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 source_map_.RegisterSource("webRequestInternal", | 701 source_map_.RegisterSource("webRequestInternal", |
702 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); | 702 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
703 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 703 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
704 | 704 |
705 // Platform app sources that are not API-specific.. | 705 // Platform app sources that are not API-specific.. |
706 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 706 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
707 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); | 707 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); |
708 source_map_.RegisterSource("webview.experimental", | 708 source_map_.RegisterSource("webview.experimental", |
709 IDR_WEB_VIEW_EXPERIMENTAL_JS); | 709 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
710 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); | 710 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); |
| 711 source_map_.RegisterSource("adView", IDR_AD_VIEW_JS); |
| 712 source_map_.RegisterSource("adViewCustom", IDR_AD_VIEW_CUSTOM_JS); |
| 713 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS); |
711 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 714 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
712 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 715 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
713 } | 716 } |
714 | 717 |
715 void Dispatcher::PopulateLazyBindingsMap() { | 718 void Dispatcher::PopulateLazyBindingsMap() { |
716 lazy_bindings_map_["app"] = InstallAppBindings; | 719 lazy_bindings_map_["app"] = InstallAppBindings; |
717 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 720 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
718 } | 721 } |
719 | 722 |
720 void Dispatcher::InstallBindings(ModuleSystem* module_system, | 723 void Dispatcher::InstallBindings(ModuleSystem* module_system, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 | 843 |
841 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 844 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
842 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); | 845 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); |
843 module_system->Require(has_permission ? "webview" : "denyWebview"); | 846 module_system->Require(has_permission ? "webview" : "denyWebview"); |
844 if (has_permission && | 847 if (has_permission && |
845 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { | 848 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { |
846 module_system->Require("webview.experimental"); | 849 module_system->Require("webview.experimental"); |
847 } | 850 } |
848 } | 851 } |
849 | 852 |
| 853 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 854 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { |
| 855 if (extension->HasAPIPermission(APIPermission::kAdView)) { |
| 856 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 857 switches::kEnableAdviewSrcAttribute)) { |
| 858 module_system->Require("adViewCustom"); |
| 859 } |
| 860 module_system->Require("adView"); |
| 861 } else { |
| 862 module_system->Require("denyAdView"); |
| 863 } |
| 864 } |
| 865 } |
| 866 |
850 context->set_module_system(module_system.Pass()); | 867 context->set_module_system(module_system.Pass()); |
851 | 868 |
852 context->DispatchOnLoadEvent( | 869 context->DispatchOnLoadEvent( |
853 ChromeRenderProcessObserver::is_incognito_process(), | 870 ChromeRenderProcessObserver::is_incognito_process(), |
854 manifest_version); | 871 manifest_version); |
855 | 872 |
856 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 873 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
857 } | 874 } |
858 | 875 |
859 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { | 876 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1191 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
1175 v8::ThrowException( | 1192 v8::ThrowException( |
1176 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1193 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
1177 return false; | 1194 return false; |
1178 } | 1195 } |
1179 | 1196 |
1180 return true; | 1197 return true; |
1181 } | 1198 } |
1182 | 1199 |
1183 } // namespace extensions | 1200 } // namespace extensions |
OLD | NEW |