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

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

Issue 12463015: Enable <adview> tag for packaged apps. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Address asargent@ code review feedback. 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
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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (CommandLine::ForCurrentProcess()->HasSwitch(
713 switches::kEnableAdviewSrcAttribute)) {
714 source_map_.RegisterSource("adViewCustom", IDR_AD_VIEW_CUSTOM_JS);
715 }
716 source_map_.RegisterSource("denyAdView", IDR_AD_VIEW_DENY_JS);
711 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); 717 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS);
712 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); 718 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS);
713 } 719 }
714 720
715 void Dispatcher::PopulateLazyBindingsMap() { 721 void Dispatcher::PopulateLazyBindingsMap() {
716 lazy_bindings_map_["app"] = InstallAppBindings; 722 lazy_bindings_map_["app"] = InstallAppBindings;
717 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; 723 lazy_bindings_map_["webstore"] = InstallWebstoreBindings;
718 } 724 }
719 725
720 void Dispatcher::InstallBindings(ModuleSystem* module_system, 726 void Dispatcher::InstallBindings(ModuleSystem* module_system,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 846
841 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 847 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
842 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); 848 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView);
843 module_system->Require(has_permission ? "webview" : "denyWebview"); 849 module_system->Require(has_permission ? "webview" : "denyWebview");
844 if (has_permission && 850 if (has_permission &&
845 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { 851 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) {
846 module_system->Require("webview.experimental"); 852 module_system->Require("webview.experimental");
847 } 853 }
848 } 854 }
849 855
856 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
857 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) {
858 if (extension->HasAPIPermission(APIPermission::kAdView)) {
859 if (CommandLine::ForCurrentProcess()->HasSwitch(
860 switches::kEnableAdviewSrcAttribute)) {
861 module_system->Require("adViewCustom");
862 }
863 module_system->Require("adView");
864 } else {
865 module_system->Require("denyAdView");
866 }
867 }
868 }
869
850 context->set_module_system(module_system.Pass()); 870 context->set_module_system(module_system.Pass());
851 871
852 context->DispatchOnLoadEvent( 872 context->DispatchOnLoadEvent(
853 ChromeRenderProcessObserver::is_incognito_process(), 873 ChromeRenderProcessObserver::is_incognito_process(),
854 manifest_version); 874 manifest_version);
855 875
856 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); 876 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size();
857 } 877 }
858 878
859 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { 879 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); 1194 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str());
1175 v8::ThrowException( 1195 v8::ThrowException(
1176 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1196 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1177 return false; 1197 return false;
1178 } 1198 }
1179 1199
1180 return true; 1200 return true;
1181 } 1201 }
1182 1202
1183 } // namespace extensions 1203 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698