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

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: Merge fix. 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // The API will be automatically set up when first used. 997 // The API will be automatically set up when first used.
992 if (extension->HasAPIPermission(APIPermission::kWebView)) { 998 if (extension->HasAPIPermission(APIPermission::kWebView)) {
993 module_system->Require("webView"); 999 module_system->Require("webView");
994 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) 1000 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV)
995 module_system->Require("webViewExperimental"); 1001 module_system->Require("webViewExperimental");
996 } else { 1002 } else {
997 module_system->Require("denyWebView"); 1003 module_system->Require("denyWebView");
998 } 1004 }
999 } 1005 }
1000 1006
1007 // Same comment as above for <adview> tag.
1008 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
1009 is_within_platform_app) {
1010 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) {
1011 if (extension->HasAPIPermission(APIPermission::kAdView)) {
1012 if (CommandLine::ForCurrentProcess()->HasSwitch(
1013 switches::kEnableAdviewSrcAttribute)) {
1014 module_system->Require("adViewCustom");
1015 }
1016 module_system->Require("adView");
1017 } else {
1018 module_system->Require("denyAdView");
1019 }
1020 }
1021 }
1022
1001 context->set_module_system(module_system.Pass()); 1023 context->set_module_system(module_system.Pass());
1002 1024
1003 context->DispatchOnLoadEvent( 1025 context->DispatchOnLoadEvent(
1004 ChromeRenderProcessObserver::is_incognito_process(), 1026 ChromeRenderProcessObserver::is_incognito_process(),
1005 manifest_version); 1027 manifest_version);
1006 1028
1007 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); 1029 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size();
1008 } 1030 }
1009 1031
1010 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { 1032 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); 1348 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str());
1327 v8::ThrowException( 1349 v8::ThrowException(
1328 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1350 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1329 return false; 1351 return false;
1330 } 1352 }
1331 1353
1332 return true; 1354 return true;
1333 } 1355 }
1334 1356
1335 } // namespace extensions 1357 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | chrome/renderer/resources/extensions/ad_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698