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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Test updates Created 4 years, 1 month 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/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 #include "content/public/common/content_switches.h" 168 #include "content/public/common/content_switches.h"
169 #include "content/public/common/sandbox_type.h" 169 #include "content/public/common/sandbox_type.h"
170 #include "content/public/common/service_manager_connection.h" 170 #include "content/public/common/service_manager_connection.h"
171 #include "content/public/common/service_names.h" 171 #include "content/public/common/service_names.h"
172 #include "content/public/common/url_utils.h" 172 #include "content/public/common/url_utils.h"
173 #include "content/public/common/web_preferences.h" 173 #include "content/public/common/web_preferences.h"
174 #include "device/bluetooth/adapter_factory.h" 174 #include "device/bluetooth/adapter_factory.h"
175 #include "device/bluetooth/public/interfaces/adapter.mojom.h" 175 #include "device/bluetooth/public/interfaces/adapter.mojom.h"
176 #include "device/usb/public/interfaces/chooser_service.mojom.h" 176 #include "device/usb/public/interfaces/chooser_service.mojom.h"
177 #include "device/usb/public/interfaces/device_manager.mojom.h" 177 #include "device/usb/public/interfaces/device_manager.mojom.h"
178 #include "extensions/features/features.h"
178 #include "gin/v8_initializer.h" 179 #include "gin/v8_initializer.h"
179 #include "net/base/mime_util.h" 180 #include "net/base/mime_util.h"
180 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 181 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
181 #include "net/cookies/canonical_cookie.h" 182 #include "net/cookies/canonical_cookie.h"
182 #include "net/cookies/cookie_options.h" 183 #include "net/cookies/cookie_options.h"
183 #include "net/ssl/ssl_cert_request_info.h" 184 #include "net/ssl/ssl_cert_request_info.h"
184 #include "ppapi/host/ppapi_host.h" 185 #include "ppapi/host/ppapi_host.h"
185 #include "printing/features/features.h" 186 #include "printing/features/features.h"
186 #include "services/service_manager/public/cpp/interface_provider.h" 187 #include "services/service_manager/public/cpp/interface_provider.h"
187 #include "services/service_manager/public/cpp/interface_registry.h" 188 #include "services/service_manager/public/cpp/interface_registry.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 #endif 282 #endif
282 283
283 #if !defined(DISABLE_NACL) 284 #if !defined(DISABLE_NACL)
284 #include "components/nacl/browser/nacl_browser.h" 285 #include "components/nacl/browser/nacl_browser.h"
285 #include "components/nacl/browser/nacl_host_message_filter.h" 286 #include "components/nacl/browser/nacl_host_message_filter.h"
286 #include "components/nacl/browser/nacl_process_host.h" 287 #include "components/nacl/browser/nacl_process_host.h"
287 #include "components/nacl/common/nacl_process_type.h" 288 #include "components/nacl/common/nacl_process_type.h"
288 #include "components/nacl/common/nacl_switches.h" 289 #include "components/nacl/common/nacl_switches.h"
289 #endif 290 #endif
290 291
291 #if defined(ENABLE_EXTENSIONS) 292 #if BUILDFLAG(ENABLE_EXTENSIONS)
292 #include "chrome/browser/accessibility/animation_policy_prefs.h" 293 #include "chrome/browser/accessibility/animation_policy_prefs.h"
293 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par t.h" 294 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par t.h"
294 #include "chrome/browser/media/cast_transport_host_filter.h" 295 #include "chrome/browser/media/cast_transport_host_filter.h"
295 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" 296 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
296 #include "components/guest_view/browser/guest_view_base.h" 297 #include "components/guest_view/browser/guest_view_base.h"
297 #include "components/guest_view/browser/guest_view_manager.h" 298 #include "components/guest_view/browser/guest_view_manager.h"
298 #include "extensions/browser/extension_navigation_throttle.h" 299 #include "extensions/browser/extension_navigation_throttle.h"
299 #include "extensions/browser/extension_registry.h" 300 #include "extensions/browser/extension_registry.h"
300 #include "extensions/browser/extension_util.h" 301 #include "extensions/browser/extension_util.h"
301 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 302 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 using content::SiteInstance; 364 using content::SiteInstance;
364 using content::WebContents; 365 using content::WebContents;
365 using content::WebPreferences; 366 using content::WebPreferences;
366 using message_center::NotifierId; 367 using message_center::NotifierId;
367 using security_interstitials::SSLErrorUI; 368 using security_interstitials::SSLErrorUI;
368 369
369 #if defined(OS_POSIX) 370 #if defined(OS_POSIX)
370 using content::FileDescriptorInfo; 371 using content::FileDescriptorInfo;
371 #endif 372 #endif
372 373
373 #if defined(ENABLE_EXTENSIONS) 374 #if BUILDFLAG(ENABLE_EXTENSIONS)
374 using extensions::APIPermission; 375 using extensions::APIPermission;
375 using extensions::ChromeContentBrowserClientExtensionsPart; 376 using extensions::ChromeContentBrowserClientExtensionsPart;
376 using extensions::Extension; 377 using extensions::Extension;
377 using extensions::InfoMap; 378 using extensions::InfoMap;
378 using extensions::Manifest; 379 using extensions::Manifest;
379 #endif 380 #endif
380 381
381 #if defined(ENABLE_PLUGINS) 382 #if defined(ENABLE_PLUGINS)
382 using plugins::ChromeContentBrowserClientPluginsPart; 383 using plugins::ChromeContentBrowserClientPluginsPart;
383 #endif 384 #endif
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 if (minWidth >= kWidthForMaxFSM) 701 if (minWidth >= kWidthForMaxFSM)
701 return kMaxFSM; 702 return kMaxFSM;
702 703
703 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. 704 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM.
704 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / 705 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) /
705 (kWidthForMaxFSM - kWidthForMinFSM); 706 (kWidthForMaxFSM - kWidthForMinFSM);
706 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; 707 return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
707 } 708 }
708 #endif // defined(OS_ANDROID) 709 #endif // defined(OS_ANDROID)
709 710
710 #if defined(ENABLE_EXTENSIONS) 711 #if BUILDFLAG(ENABLE_EXTENSIONS)
711 // By default, JavaScript, images and autoplay are enabled in guest content. 712 // By default, JavaScript, images and autoplay are enabled in guest content.
712 void GetGuestViewDefaultContentSettingRules( 713 void GetGuestViewDefaultContentSettingRules(
713 bool incognito, 714 bool incognito,
714 RendererContentSettingRules* rules) { 715 RendererContentSettingRules* rules) {
715 rules->image_rules.push_back( 716 rules->image_rules.push_back(
716 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), 717 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
717 ContentSettingsPattern::Wildcard(), 718 ContentSettingsPattern::Wildcard(),
718 CONTENT_SETTING_ALLOW, 719 CONTENT_SETTING_ALLOW,
719 std::string(), 720 std::string(),
720 incognito)); 721 incognito));
721 722
722 rules->script_rules.push_back( 723 rules->script_rules.push_back(
723 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), 724 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
724 ContentSettingsPattern::Wildcard(), 725 ContentSettingsPattern::Wildcard(),
725 CONTENT_SETTING_ALLOW, 726 CONTENT_SETTING_ALLOW,
726 std::string(), 727 std::string(),
727 incognito)); 728 incognito));
728 rules->autoplay_rules.push_back( 729 rules->autoplay_rules.push_back(
729 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), 730 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
730 ContentSettingsPattern::Wildcard(), 731 ContentSettingsPattern::Wildcard(),
731 CONTENT_SETTING_ALLOW, 732 CONTENT_SETTING_ALLOW,
732 std::string(), 733 std::string(),
733 incognito)); 734 incognito));
734 } 735 }
735 #endif // defined(ENABLE_EXTENSIONS) 736 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
736 737
737 void CreateUsbDeviceManager( 738 void CreateUsbDeviceManager(
738 RenderFrameHost* render_frame_host, 739 RenderFrameHost* render_frame_host,
739 mojo::InterfaceRequest<device::usb::DeviceManager> request) { 740 mojo::InterfaceRequest<device::usb::DeviceManager> request) {
740 WebContents* web_contents = 741 WebContents* web_contents =
741 WebContents::FromRenderFrameHost(render_frame_host); 742 WebContents::FromRenderFrameHost(render_frame_host);
742 if (!web_contents) { 743 if (!web_contents) {
743 NOTREACHED(); 744 NOTREACHED();
744 return; 745 return;
745 } 746 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 822 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
822 823
823 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); 824 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart);
824 #endif 825 #endif
825 826
826 #if !defined(OS_ANDROID) 827 #if !defined(OS_ANDROID)
827 TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance(); 828 TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance();
828 TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine); 829 TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine);
829 #endif 830 #endif
830 831
831 #if defined(ENABLE_EXTENSIONS) 832 #if BUILDFLAG(ENABLE_EXTENSIONS)
832 extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart); 833 extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart);
833 #endif 834 #endif
834 } 835 }
835 836
836 ChromeContentBrowserClient::~ChromeContentBrowserClient() { 837 ChromeContentBrowserClient::~ChromeContentBrowserClient() {
837 for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i) 838 for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i)
838 delete extra_parts_[i]; 839 delete extra_parts_[i];
839 extra_parts_.clear(); 840 extra_parts_.clear();
840 } 841 }
841 842
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 932
932 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( 933 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite(
933 content::BrowserContext* browser_context, 934 content::BrowserContext* browser_context,
934 const GURL& site) { 935 const GURL& site) {
935 std::string partition_id; 936 std::string partition_id;
936 937
937 // The partition ID for webview guest processes is the string value of its 938 // The partition ID for webview guest processes is the string value of its
938 // SiteInstance URL - "chrome-guest://app_id/persist?partition". 939 // SiteInstance URL - "chrome-guest://app_id/persist?partition".
939 if (site.SchemeIs(content::kGuestScheme)) 940 if (site.SchemeIs(content::kGuestScheme))
940 partition_id = site.spec(); 941 partition_id = site.spec();
941 #if defined(ENABLE_EXTENSIONS) 942 #if BUILDFLAG(ENABLE_EXTENSIONS)
942 // The partition ID for extensions with isolated storage is treated similarly 943 // The partition ID for extensions with isolated storage is treated similarly
943 // to the above. 944 // to the above.
944 else if (site.SchemeIs(extensions::kExtensionScheme) && 945 else if (site.SchemeIs(extensions::kExtensionScheme) &&
945 extensions::util::SiteHasIsolatedStorage(site, browser_context)) 946 extensions::util::SiteHasIsolatedStorage(site, browser_context))
946 partition_id = site.spec(); 947 partition_id = site.spec();
947 #endif 948 #endif
948 949
949 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); 950 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
950 return partition_id; 951 return partition_id;
951 } 952 }
(...skipping 14 matching lines...) Expand all
966 bool can_be_default, 967 bool can_be_default,
967 std::string* partition_domain, 968 std::string* partition_domain,
968 std::string* partition_name, 969 std::string* partition_name,
969 bool* in_memory) { 970 bool* in_memory) {
970 // Default to the browser-wide storage partition and override based on |site| 971 // Default to the browser-wide storage partition and override based on |site|
971 // below. 972 // below.
972 partition_domain->clear(); 973 partition_domain->clear();
973 partition_name->clear(); 974 partition_name->clear();
974 *in_memory = false; 975 *in_memory = false;
975 976
976 #if defined(ENABLE_EXTENSIONS) 977 #if BUILDFLAG(ENABLE_EXTENSIONS)
977 bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( 978 bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite(
978 site, partition_domain, partition_name, in_memory); 979 site, partition_domain, partition_name, in_memory);
979 980
980 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { 981 if (!success && site.SchemeIs(extensions::kExtensionScheme)) {
981 // If |can_be_default| is false, the caller is stating that the |site| 982 // If |can_be_default| is false, the caller is stating that the |site|
982 // should be parsed as if it had isolated storage. In particular it is 983 // should be parsed as if it had isolated storage. In particular it is
983 // important to NOT check ExtensionService for the is_storage_isolated() 984 // important to NOT check ExtensionService for the is_storage_isolated()
984 // attribute because this code path is run during Extension uninstall 985 // attribute because this code path is run during Extension uninstall
985 // to do cleanup after the Extension has already been unloaded from the 986 // to do cleanup after the Extension has already been unloaded from the
986 // ExtensionService. 987 // ExtensionService.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 1019
1019 void ChromeContentBrowserClient::RenderProcessWillLaunch( 1020 void ChromeContentBrowserClient::RenderProcessWillLaunch(
1020 content::RenderProcessHost* host) { 1021 content::RenderProcessHost* host) {
1021 int id = host->GetID(); 1022 int id = host->GetID();
1022 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 1023 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
1023 net::URLRequestContextGetter* context = 1024 net::URLRequestContextGetter* context =
1024 host->GetStoragePartition()->GetURLRequestContext(); 1025 host->GetStoragePartition()->GetURLRequestContext();
1025 1026
1026 host->AddFilter(new ChromeRenderMessageFilter( 1027 host->AddFilter(new ChromeRenderMessageFilter(
1027 id, profile, host->GetStoragePartition()->GetServiceWorkerContext())); 1028 id, profile, host->GetStoragePartition()->GetServiceWorkerContext()));
1028 #if defined(ENABLE_EXTENSIONS) 1029 #if BUILDFLAG(ENABLE_EXTENSIONS)
1029 host->AddFilter(new cast::CastTransportHostFilter); 1030 host->AddFilter(new cast::CastTransportHostFilter);
1030 #endif 1031 #endif
1031 #if BUILDFLAG(ENABLE_PRINTING) 1032 #if BUILDFLAG(ENABLE_PRINTING)
1032 host->AddFilter(new printing::PrintingMessageFilter(id, profile)); 1033 host->AddFilter(new printing::PrintingMessageFilter(id, profile));
1033 #endif 1034 #endif
1034 #if defined(ENABLE_SPELLCHECK) 1035 #if defined(ENABLE_SPELLCHECK)
1035 host->AddFilter(new SpellCheckMessageFilter(id)); 1036 host->AddFilter(new SpellCheckMessageFilter(id));
1036 #endif 1037 #endif
1037 #if defined(USE_BROWSER_SPELLCHECKER) 1038 #if defined(USE_BROWSER_SPELLCHECKER)
1038 host->AddFilter(new SpellCheckMessageFilterPlatform(id)); 1039 host->AddFilter(new SpellCheckMessageFilterPlatform(id));
(...skipping 29 matching lines...) Expand all
1068 #endif 1069 #endif
1069 1070
1070 host->Send(new ChromeViewMsg_SetIsIncognitoProcess( 1071 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
1071 profile->IsOffTheRecord())); 1072 profile->IsOffTheRecord()));
1072 1073
1073 for (size_t i = 0; i < extra_parts_.size(); ++i) 1074 for (size_t i = 0; i < extra_parts_.size(); ++i)
1074 extra_parts_[i]->RenderProcessWillLaunch(host); 1075 extra_parts_[i]->RenderProcessWillLaunch(host);
1075 1076
1076 RendererContentSettingRules rules; 1077 RendererContentSettingRules rules;
1077 if (host->IsForGuestsOnly()) { 1078 if (host->IsForGuestsOnly()) {
1078 #if defined(ENABLE_EXTENSIONS) 1079 #if BUILDFLAG(ENABLE_EXTENSIONS)
1079 GetGuestViewDefaultContentSettingRules(profile->IsOffTheRecord(), &rules); 1080 GetGuestViewDefaultContentSettingRules(profile->IsOffTheRecord(), &rules);
1080 #else 1081 #else
1081 NOTREACHED(); 1082 NOTREACHED();
1082 #endif 1083 #endif
1083 } else { 1084 } else {
1084 GetRendererContentSettingRules( 1085 GetRendererContentSettingRules(
1085 HostContentSettingsMapFactory::GetForProfile(profile), &rules); 1086 HostContentSettingsMapFactory::GetForProfile(profile), &rules);
1086 } 1087 }
1087 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); 1088 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
1088 } 1089 }
1089 1090
1090 GURL ChromeContentBrowserClient::GetEffectiveURL( 1091 GURL ChromeContentBrowserClient::GetEffectiveURL(
1091 content::BrowserContext* browser_context, const GURL& url) { 1092 content::BrowserContext* browser_context, const GURL& url) {
1092 Profile* profile = Profile::FromBrowserContext(browser_context); 1093 Profile* profile = Profile::FromBrowserContext(browser_context);
1093 if (!profile) 1094 if (!profile)
1094 return url; 1095 return url;
1095 1096
1096 // If the input |url| should be assigned to the Instant renderer, make its 1097 // If the input |url| should be assigned to the Instant renderer, make its
1097 // effective URL distinct from other URLs on the search provider's domain. 1098 // effective URL distinct from other URLs on the search provider's domain.
1098 if (search::ShouldAssignURLToInstantRenderer(url, profile)) 1099 if (search::ShouldAssignURLToInstantRenderer(url, profile))
1099 return search::GetEffectiveURLForInstant(url, profile); 1100 return search::GetEffectiveURLForInstant(url, profile);
1100 1101
1101 #if defined(ENABLE_EXTENSIONS) 1102 #if BUILDFLAG(ENABLE_EXTENSIONS)
1102 return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL( 1103 return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL(
1103 profile, url); 1104 profile, url);
1104 #else 1105 #else
1105 return url; 1106 return url;
1106 #endif 1107 #endif
1107 } 1108 }
1108 1109
1109 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( 1110 bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
1110 content::BrowserContext* browser_context, const GURL& effective_url) { 1111 content::BrowserContext* browser_context, const GURL& effective_url) {
1111 // Non-extension, non-Instant URLs should generally use 1112 // Non-extension, non-Instant URLs should generally use
1112 // process-per-site-instance. Because we expect to use the effective URL, 1113 // process-per-site-instance. Because we expect to use the effective URL,
1113 // URLs for hosted apps (apart from bookmark apps) should have an extension 1114 // URLs for hosted apps (apart from bookmark apps) should have an extension
1114 // scheme by now. 1115 // scheme by now.
1115 1116
1116 Profile* profile = Profile::FromBrowserContext(browser_context); 1117 Profile* profile = Profile::FromBrowserContext(browser_context);
1117 if (!profile) 1118 if (!profile)
1118 return false; 1119 return false;
1119 1120
1120 if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) 1121 if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile))
1121 return true; 1122 return true;
1122 1123
1123 #if defined(ENABLE_EXTENSIONS) 1124 #if BUILDFLAG(ENABLE_EXTENSIONS)
1124 return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( 1125 return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite(
1125 profile, effective_url); 1126 profile, effective_url);
1126 #else 1127 #else
1127 return false; 1128 return false;
1128 #endif 1129 #endif
1129 } 1130 }
1130 1131
1131 bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess( 1132 bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess(
1132 content::BrowserContext* browser_context, 1133 content::BrowserContext* browser_context,
1133 const GURL& effective_site_url) { 1134 const GURL& effective_site_url) {
1134 #if defined(ENABLE_EXTENSIONS) 1135 #if BUILDFLAG(ENABLE_EXTENSIONS)
1135 if (ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess( 1136 if (ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess(
1136 browser_context, effective_site_url)) { 1137 browser_context, effective_site_url)) {
1137 return true; 1138 return true;
1138 } 1139 }
1139 #endif 1140 #endif
1140 return false; 1141 return false;
1141 } 1142 }
1142 1143
1143 // TODO(creis, nick): https://crbug.com/160576 describes a weakness in our 1144 // TODO(creis, nick): https://crbug.com/160576 describes a weakness in our
1144 // origin-lock enforcement, where we don't have a way to efficiently know 1145 // origin-lock enforcement, where we don't have a way to efficiently know
1145 // effective URLs on the IO thread, and wind up killing processes that e.g. 1146 // effective URLs on the IO thread, and wind up killing processes that e.g.
1146 // request cookies for their actual URL. This whole function (and its 1147 // request cookies for their actual URL. This whole function (and its
1147 // ExtensionsPart) should be removed once we add that ability to the IO thread. 1148 // ExtensionsPart) should be removed once we add that ability to the IO thread.
1148 bool ChromeContentBrowserClient::ShouldLockToOrigin( 1149 bool ChromeContentBrowserClient::ShouldLockToOrigin(
1149 content::BrowserContext* browser_context, 1150 content::BrowserContext* browser_context,
1150 const GURL& effective_site_url) { 1151 const GURL& effective_site_url) {
1151 // Origin lock to the search scheme would kill processes upon legitimate 1152 // Origin lock to the search scheme would kill processes upon legitimate
1152 // requests for cookies from the search engine's domain. 1153 // requests for cookies from the search engine's domain.
1153 if (effective_site_url.SchemeIs(chrome::kChromeSearchScheme)) 1154 if (effective_site_url.SchemeIs(chrome::kChromeSearchScheme))
1154 return false; 1155 return false;
1155 1156
1156 #if defined(ENABLE_EXTENSIONS) 1157 #if BUILDFLAG(ENABLE_EXTENSIONS)
1157 // Disable origin lock if this is an extension/app that applies effective URL 1158 // Disable origin lock if this is an extension/app that applies effective URL
1158 // mappings. 1159 // mappings.
1159 if (!ChromeContentBrowserClientExtensionsPart::ShouldLockToOrigin( 1160 if (!ChromeContentBrowserClientExtensionsPart::ShouldLockToOrigin(
1160 browser_context, effective_site_url)) { 1161 browser_context, effective_site_url)) {
1161 return false; 1162 return false;
1162 } 1163 }
1163 #endif 1164 #endif
1164 return true; 1165 return true;
1165 } 1166 }
1166 1167
1167 // These are treated as WebUI schemes but do not get WebUI bindings. Also, 1168 // These are treated as WebUI schemes but do not get WebUI bindings. Also,
1168 // view-source is allowed for these schemes. 1169 // view-source is allowed for these schemes.
1169 void ChromeContentBrowserClient::GetAdditionalWebUISchemes( 1170 void ChromeContentBrowserClient::GetAdditionalWebUISchemes(
1170 std::vector<std::string>* additional_schemes) { 1171 std::vector<std::string>* additional_schemes) {
1171 additional_schemes->push_back(chrome::kChromeSearchScheme); 1172 additional_schemes->push_back(chrome::kChromeSearchScheme);
1172 additional_schemes->push_back(dom_distiller::kDomDistillerScheme); 1173 additional_schemes->push_back(dom_distiller::kDomDistillerScheme);
1173 } 1174 }
1174 1175
1175 bool ChromeContentBrowserClient::LogWebUIUrl(const GURL& web_ui_url) const { 1176 bool ChromeContentBrowserClient::LogWebUIUrl(const GURL& web_ui_url) const {
1176 return webui::LogWebUIUrl(web_ui_url); 1177 return webui::LogWebUIUrl(web_ui_url);
1177 } 1178 }
1178 1179
1179 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { 1180 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
1180 return ProfileIOData::IsHandledURL(url); 1181 return ProfileIOData::IsHandledURL(url);
1181 } 1182 }
1182 1183
1183 bool ChromeContentBrowserClient::CanCommitURL( 1184 bool ChromeContentBrowserClient::CanCommitURL(
1184 content::RenderProcessHost* process_host, 1185 content::RenderProcessHost* process_host,
1185 const GURL& url) { 1186 const GURL& url) {
1186 #if defined(ENABLE_EXTENSIONS) 1187 #if BUILDFLAG(ENABLE_EXTENSIONS)
1187 return ChromeContentBrowserClientExtensionsPart::CanCommitURL( 1188 return ChromeContentBrowserClientExtensionsPart::CanCommitURL(
1188 process_host, url); 1189 process_host, url);
1189 #else 1190 #else
1190 return true; 1191 return true;
1191 #endif 1192 #endif
1192 } 1193 }
1193 1194
1194 bool ChromeContentBrowserClient::ShouldAllowOpenURL( 1195 bool ChromeContentBrowserClient::ShouldAllowOpenURL(
1195 content::SiteInstance* site_instance, const GURL& url) { 1196 content::SiteInstance* site_instance, const GURL& url) {
1196 #if defined(ENABLE_EXTENSIONS) 1197 #if BUILDFLAG(ENABLE_EXTENSIONS)
1197 bool result; 1198 bool result;
1198 if (ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL( 1199 if (ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL(
1199 site_instance, url, &result)) 1200 site_instance, url, &result))
1200 return result; 1201 return result;
1201 #endif 1202 #endif
1202 1203
1203 // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since 1204 // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since
1204 // the signin page may host untrusted web content. 1205 // the signin page may host untrusted web content.
1205 GURL from_url = site_instance->GetSiteURL(); 1206 GURL from_url = site_instance->GetSiteURL();
1206 if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL && 1207 if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL &&
(...skipping 24 matching lines...) Expand all
1231 site_instance->GetSiteURL().host() == 1232 site_instance->GetSiteURL().host() ==
1232 chrome::kChromeSearchLocalNtpHost) && 1233 chrome::kChromeSearchLocalNtpHost) &&
1233 ui::PageTransitionCoreTypeIs(*transition, ui::PAGE_TRANSITION_LINK)) { 1234 ui::PageTransitionCoreTypeIs(*transition, ui::PAGE_TRANSITION_LINK)) {
1234 // Use AUTO_BOOKMARK for clicks on tiles of the new tab page, consistently 1235 // Use AUTO_BOOKMARK for clicks on tiles of the new tab page, consistently
1235 // with native implementations like Android's. 1236 // with native implementations like Android's.
1236 *transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK; 1237 *transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK;
1237 *is_renderer_initiated = false; 1238 *is_renderer_initiated = false;
1238 *referrer = content::Referrer(); 1239 *referrer = content::Referrer();
1239 } 1240 }
1240 1241
1241 #if defined(ENABLE_EXTENSIONS) 1242 #if BUILDFLAG(ENABLE_EXTENSIONS)
1242 ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams( 1243 ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams(
1243 site_instance, transition, is_renderer_initiated, referrer); 1244 site_instance, transition, is_renderer_initiated, referrer);
1244 #endif 1245 #endif
1245 } 1246 }
1246 1247
1247 bool ChromeContentBrowserClient::IsSuitableHost( 1248 bool ChromeContentBrowserClient::IsSuitableHost(
1248 content::RenderProcessHost* process_host, 1249 content::RenderProcessHost* process_host,
1249 const GURL& site_url) { 1250 const GURL& site_url) {
1250 Profile* profile = 1251 Profile* profile =
1251 Profile::FromBrowserContext(process_host->GetBrowserContext()); 1252 Profile::FromBrowserContext(process_host->GetBrowserContext());
1252 // This may be NULL during tests. In that case, just assume any site can 1253 // This may be NULL during tests. In that case, just assume any site can
1253 // share any host. 1254 // share any host.
1254 if (!profile) 1255 if (!profile)
1255 return true; 1256 return true;
1256 1257
1257 // Instant URLs should only be in the instant process and instant process 1258 // Instant URLs should only be in the instant process and instant process
1258 // should only have Instant URLs. 1259 // should only have Instant URLs.
1259 InstantService* instant_service = 1260 InstantService* instant_service =
1260 InstantServiceFactory::GetForProfile(profile); 1261 InstantServiceFactory::GetForProfile(profile);
1261 if (instant_service) { 1262 if (instant_service) {
1262 bool is_instant_process = instant_service->IsInstantProcess( 1263 bool is_instant_process = instant_service->IsInstantProcess(
1263 process_host->GetID()); 1264 process_host->GetID());
1264 bool should_be_in_instant_process = 1265 bool should_be_in_instant_process =
1265 search::ShouldAssignURLToInstantRenderer(site_url, profile); 1266 search::ShouldAssignURLToInstantRenderer(site_url, profile);
1266 if (is_instant_process || should_be_in_instant_process) 1267 if (is_instant_process || should_be_in_instant_process)
1267 return is_instant_process && should_be_in_instant_process; 1268 return is_instant_process && should_be_in_instant_process;
1268 } 1269 }
1269 1270
1270 #if defined(ENABLE_EXTENSIONS) 1271 #if BUILDFLAG(ENABLE_EXTENSIONS)
1271 return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( 1272 return ChromeContentBrowserClientExtensionsPart::IsSuitableHost(
1272 profile, process_host, site_url); 1273 profile, process_host, site_url);
1273 #else 1274 #else
1274 return true; 1275 return true;
1275 #endif 1276 #endif
1276 } 1277 }
1277 1278
1278 bool ChromeContentBrowserClient::MayReuseHost( 1279 bool ChromeContentBrowserClient::MayReuseHost(
1279 content::RenderProcessHost* process_host) { 1280 content::RenderProcessHost* process_host) {
1280 // If there is currently a prerender in progress for the host provided, 1281 // If there is currently a prerender in progress for the host provided,
1281 // it may not be shared. We require prerenders to be by themselves in a 1282 // it may not be shared. We require prerenders to be by themselves in a
1282 // separate process so that we can monitor their resource usage. 1283 // separate process so that we can monitor their resource usage.
1283 prerender::PrerenderManager* prerender_manager = 1284 prerender::PrerenderManager* prerender_manager =
1284 prerender::PrerenderManagerFactory::GetForBrowserContext( 1285 prerender::PrerenderManagerFactory::GetForBrowserContext(
1285 process_host->GetBrowserContext()); 1286 process_host->GetBrowserContext());
1286 if (prerender_manager && 1287 if (prerender_manager &&
1287 !prerender_manager->MayReuseProcessHost(process_host)) { 1288 !prerender_manager->MayReuseProcessHost(process_host)) {
1288 return false; 1289 return false;
1289 } 1290 }
1290 1291
1291 return true; 1292 return true;
1292 } 1293 }
1293 1294
1294 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( 1295 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
1295 content::BrowserContext* browser_context, const GURL& url) { 1296 content::BrowserContext* browser_context, const GURL& url) {
1296 // It has to be a valid URL for us to check for an extension. 1297 // It has to be a valid URL for us to check for an extension.
1297 if (!url.is_valid()) 1298 if (!url.is_valid())
1298 return false; 1299 return false;
1299 1300
1300 #if defined(ENABLE_EXTENSIONS) 1301 #if BUILDFLAG(ENABLE_EXTENSIONS)
1301 Profile* profile = Profile::FromBrowserContext(browser_context); 1302 Profile* profile = Profile::FromBrowserContext(browser_context);
1302 return ChromeContentBrowserClientExtensionsPart:: 1303 return ChromeContentBrowserClientExtensionsPart::
1303 ShouldTryToUseExistingProcessHost( 1304 ShouldTryToUseExistingProcessHost(
1304 profile, url); 1305 profile, url);
1305 #else 1306 #else
1306 return false; 1307 return false;
1307 #endif 1308 #endif
1308 } 1309 }
1309 1310
1310 void ChromeContentBrowserClient::SiteInstanceGotProcess( 1311 void ChromeContentBrowserClient::SiteInstanceGotProcess(
(...skipping 25 matching lines...) Expand all
1336 return; 1337 return;
1337 1338
1338 for (size_t i = 0; i < extra_parts_.size(); ++i) 1339 for (size_t i = 0; i < extra_parts_.size(); ++i)
1339 extra_parts_[i]->SiteInstanceDeleting(site_instance); 1340 extra_parts_[i]->SiteInstanceDeleting(site_instance);
1340 } 1341 }
1341 1342
1342 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( 1343 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
1343 SiteInstance* site_instance, 1344 SiteInstance* site_instance,
1344 const GURL& current_url, 1345 const GURL& current_url,
1345 const GURL& new_url) { 1346 const GURL& new_url) {
1346 #if defined(ENABLE_EXTENSIONS) 1347 #if BUILDFLAG(ENABLE_EXTENSIONS)
1347 return ChromeContentBrowserClientExtensionsPart:: 1348 return ChromeContentBrowserClientExtensionsPart::
1348 ShouldSwapBrowsingInstancesForNavigation( 1349 ShouldSwapBrowsingInstancesForNavigation(
1349 site_instance, current_url, new_url); 1350 site_instance, current_url, new_url);
1350 #else 1351 #else
1351 return false; 1352 return false;
1352 #endif 1353 #endif
1353 } 1354 }
1354 1355
1355 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 1356 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1356 content::BrowserContext* browser_context, 1357 content::BrowserContext* browser_context,
1357 const GURL& current_url, 1358 const GURL& current_url,
1358 const GURL& new_url) { 1359 const GURL& new_url) {
1359 #if defined(ENABLE_EXTENSIONS) 1360 #if BUILDFLAG(ENABLE_EXTENSIONS)
1360 return ChromeContentBrowserClientExtensionsPart:: 1361 return ChromeContentBrowserClientExtensionsPart::
1361 ShouldSwapProcessesForRedirect(browser_context, current_url, new_url); 1362 ShouldSwapProcessesForRedirect(browser_context, current_url, new_url);
1362 #else 1363 #else
1363 return false; 1364 return false;
1364 #endif 1365 #endif
1365 } 1366 }
1366 1367
1367 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { 1368 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) {
1368 return !url.SchemeIs(chrome::kChromeNativeScheme); 1369 return !url.SchemeIs(chrome::kChromeNativeScheme);
1369 } 1370 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 #if defined(OS_ANDROID) 1674 #if defined(OS_ANDROID)
1674 autofill::switches::kDisableAccessorySuggestionView, 1675 autofill::switches::kDisableAccessorySuggestionView,
1675 autofill::switches::kEnableAccessorySuggestionView, 1676 autofill::switches::kEnableAccessorySuggestionView,
1676 #endif 1677 #endif
1677 autofill::switches::kDisablePasswordGeneration, 1678 autofill::switches::kDisablePasswordGeneration,
1678 autofill::switches::kEnablePasswordGeneration, 1679 autofill::switches::kEnablePasswordGeneration,
1679 autofill::switches::kEnableSingleClickAutofill, 1680 autofill::switches::kEnableSingleClickAutofill,
1680 autofill::switches::kEnableSuggestionsWithSubstringMatch, 1681 autofill::switches::kEnableSuggestionsWithSubstringMatch,
1681 autofill::switches::kIgnoreAutocompleteOffForAutofill, 1682 autofill::switches::kIgnoreAutocompleteOffForAutofill,
1682 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration, 1683 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration,
1683 #if defined(ENABLE_EXTENSIONS) 1684 #if BUILDFLAG(ENABLE_EXTENSIONS)
1684 extensions::switches::kAllowHTTPBackgroundPage, 1685 extensions::switches::kAllowHTTPBackgroundPage,
1685 extensions::switches::kAllowLegacyExtensionManifests, 1686 extensions::switches::kAllowLegacyExtensionManifests,
1686 extensions::switches::kEnableAppWindowControls, 1687 extensions::switches::kEnableAppWindowControls,
1687 extensions::switches::kEnableEmbeddedExtensionOptions, 1688 extensions::switches::kEnableEmbeddedExtensionOptions,
1688 extensions::switches::kEnableExperimentalExtensionApis, 1689 extensions::switches::kEnableExperimentalExtensionApis,
1689 extensions::switches::kExtensionsOnChromeURLs, 1690 extensions::switches::kExtensionsOnChromeURLs,
1690 extensions::switches::kIsolateExtensions, 1691 extensions::switches::kIsolateExtensions,
1691 extensions::switches::kWhitelistedExtensionID, 1692 extensions::switches::kWhitelistedExtensionID,
1692 #endif 1693 #endif
1693 switches::kAllowInsecureLocalhost, 1694 switches::kAllowInsecureLocalhost,
(...skipping 26 matching lines...) Expand all
1720 switches::kProfilingFile, 1721 switches::kProfilingFile,
1721 switches::kProfilingFlush, 1722 switches::kProfilingFlush,
1722 switches::kReaderModeHeuristics, 1723 switches::kReaderModeHeuristics,
1723 switches::kUnsafelyTreatInsecureOriginAsSecure, 1724 switches::kUnsafelyTreatInsecureOriginAsSecure,
1724 translate::switches::kTranslateSecurityOrigin, 1725 translate::switches::kTranslateSecurityOrigin,
1725 }; 1726 };
1726 1727
1727 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, 1728 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1728 arraysize(kSwitchNames)); 1729 arraysize(kSwitchNames));
1729 } else if (process_type == switches::kUtilityProcess) { 1730 } else if (process_type == switches::kUtilityProcess) {
1730 #if defined(ENABLE_EXTENSIONS) 1731 #if BUILDFLAG(ENABLE_EXTENSIONS)
1731 static const char* const kSwitchNames[] = { 1732 static const char* const kSwitchNames[] = {
1732 extensions::switches::kAllowHTTPBackgroundPage, 1733 extensions::switches::kAllowHTTPBackgroundPage,
1733 extensions::switches::kEnableExperimentalExtensionApis, 1734 extensions::switches::kEnableExperimentalExtensionApis,
1734 extensions::switches::kExtensionsOnChromeURLs, 1735 extensions::switches::kExtensionsOnChromeURLs,
1735 extensions::switches::kWhitelistedExtensionID, 1736 extensions::switches::kWhitelistedExtensionID,
1736 }; 1737 };
1737 1738
1738 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, 1739 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1739 arraysize(kSwitchNames)); 1740 arraysize(kSwitchNames));
1740 #endif 1741 #endif
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 } 1811 }
1811 1812
1812 bool ChromeContentBrowserClient::AllowServiceWorker( 1813 bool ChromeContentBrowserClient::AllowServiceWorker(
1813 const GURL& scope, 1814 const GURL& scope,
1814 const GURL& first_party_url, 1815 const GURL& first_party_url,
1815 content::ResourceContext* context, 1816 content::ResourceContext* context,
1816 int render_process_id, 1817 int render_process_id,
1817 int render_frame_id) { 1818 int render_frame_id) {
1818 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1819 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1819 1820
1820 #if defined(ENABLE_EXTENSIONS) 1821 #if BUILDFLAG(ENABLE_EXTENSIONS)
1821 // Check if this is an extension-related service worker, and, if so, if it's 1822 // Check if this is an extension-related service worker, and, if so, if it's
1822 // allowed (this can return false if, e.g., the extension is disabled). 1823 // allowed (this can return false if, e.g., the extension is disabled).
1823 // If it's not allowed, return immediately. We deliberately do *not* report 1824 // If it's not allowed, return immediately. We deliberately do *not* report
1824 // to the TabSpecificContentSettings, since the service worker is blocked 1825 // to the TabSpecificContentSettings, since the service worker is blocked
1825 // because of the extension, rather than because of the user's content 1826 // because of the extension, rather than because of the user's content
1826 // settings. 1827 // settings.
1827 if (!ChromeContentBrowserClientExtensionsPart::AllowServiceWorker( 1828 if (!ChromeContentBrowserClientExtensionsPart::AllowServiceWorker(
1828 scope, first_party_url, context, render_process_id, 1829 scope, first_party_url, context, render_process_id,
1829 render_frame_id)) { 1830 render_frame_id)) {
1830 return false; 1831 return false;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 const GURL& url, 1920 const GURL& url,
1920 content::ResourceContext* context, 1921 content::ResourceContext* context,
1921 const std::vector<std::pair<int, int> >& render_frames, 1922 const std::vector<std::pair<int, int> >& render_frames,
1922 base::Callback<void(bool)> callback) { 1923 base::Callback<void(bool)> callback) {
1923 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1924 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1924 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1925 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1925 content_settings::CookieSettings* cookie_settings = 1926 content_settings::CookieSettings* cookie_settings =
1926 io_data->GetCookieSettings(); 1927 io_data->GetCookieSettings();
1927 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); 1928 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1928 1929
1929 #if defined(ENABLE_EXTENSIONS) 1930 #if BUILDFLAG(ENABLE_EXTENSIONS)
1930 GuestPermissionRequestHelper(url, render_frames, callback, allow); 1931 GuestPermissionRequestHelper(url, render_frames, callback, allow);
1931 #else 1932 #else
1932 FileSystemAccessed(url, render_frames, callback, allow); 1933 FileSystemAccessed(url, render_frames, callback, allow);
1933 #endif 1934 #endif
1934 } 1935 }
1935 1936
1936 #if defined(ENABLE_EXTENSIONS) 1937 #if BUILDFLAG(ENABLE_EXTENSIONS)
1937 void ChromeContentBrowserClient::GuestPermissionRequestHelper( 1938 void ChromeContentBrowserClient::GuestPermissionRequestHelper(
1938 const GURL& url, 1939 const GURL& url,
1939 const std::vector<std::pair<int, int> >& render_frames, 1940 const std::vector<std::pair<int, int> >& render_frames,
1940 base::Callback<void(bool)> callback, 1941 base::Callback<void(bool)> callback,
1941 bool allow) { 1942 bool allow) {
1942 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1943 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1943 std::vector<std::pair<int, int> >::const_iterator i; 1944 std::vector<std::pair<int, int> >::const_iterator i;
1944 std::map<int, int> process_map; 1945 std::map<int, int> process_map;
1945 std::map<int, int>::const_iterator it; 1946 std::map<int, int>::const_iterator it;
1946 bool has_web_view_guest = false; 1947 bool has_web_view_guest = false;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 2089
2089 std::string ChromeContentBrowserClient::GetWebBluetoothBlacklist() { 2090 std::string ChromeContentBrowserClient::GetWebBluetoothBlacklist() {
2090 return variations::GetVariationParamValue("WebBluetoothBlacklist", 2091 return variations::GetVariationParamValue("WebBluetoothBlacklist",
2091 "blacklist_additions"); 2092 "blacklist_additions");
2092 } 2093 }
2093 2094
2094 net::URLRequestContext* 2095 net::URLRequestContext*
2095 ChromeContentBrowserClient::OverrideRequestContextForURL( 2096 ChromeContentBrowserClient::OverrideRequestContextForURL(
2096 const GURL& url, content::ResourceContext* context) { 2097 const GURL& url, content::ResourceContext* context) {
2097 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2098 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2098 #if defined(ENABLE_EXTENSIONS) 2099 #if BUILDFLAG(ENABLE_EXTENSIONS)
2099 if (url.SchemeIs(extensions::kExtensionScheme)) { 2100 if (url.SchemeIs(extensions::kExtensionScheme)) {
2100 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2101 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2101 return io_data->extensions_request_context(); 2102 return io_data->extensions_request_context();
2102 } 2103 }
2103 #endif 2104 #endif
2104 2105
2105 return NULL; 2106 return NULL;
2106 } 2107 }
2107 2108
2108 QuotaPermissionContext* 2109 QuotaPermissionContext*
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 int opener_render_view_id, 2252 int opener_render_view_id,
2252 int opener_render_frame_id, 2253 int opener_render_frame_id,
2253 bool* no_javascript_access) { 2254 bool* no_javascript_access) {
2254 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2255 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2255 2256
2256 *no_javascript_access = false; 2257 *no_javascript_access = false;
2257 2258
2258 // If the opener is trying to create a background window but doesn't have 2259 // If the opener is trying to create a background window but doesn't have
2259 // the appropriate permission, fail the attempt. 2260 // the appropriate permission, fail the attempt.
2260 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 2261 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
2261 #if defined(ENABLE_EXTENSIONS) 2262 #if BUILDFLAG(ENABLE_EXTENSIONS)
2262 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2263 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2263 InfoMap* map = io_data->GetExtensionInfoMap(); 2264 InfoMap* map = io_data->GetExtensionInfoMap();
2264 if (!map->SecurityOriginHasAPIPermission( 2265 if (!map->SecurityOriginHasAPIPermission(
2265 source_origin, 2266 source_origin,
2266 render_process_id, 2267 render_process_id,
2267 APIPermission::kBackground)) { 2268 APIPermission::kBackground)) {
2268 return false; 2269 return false;
2269 } 2270 }
2270 2271
2271 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may 2272 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
2272 // return a recently installed Extension even if this CanCreateWindow call 2273 // return a recently installed Extension even if this CanCreateWindow call
2273 // was made by an old copy of the page in a normal web process. That's ok, 2274 // was made by an old copy of the page in a normal web process. That's ok,
2274 // because the permission check above would have caused an early return 2275 // because the permission check above would have caused an early return
2275 // already. We must use the full URL to find hosted apps, though, and not 2276 // already. We must use the full URL to find hosted apps, though, and not
2276 // just the origin. 2277 // just the origin.
2277 const Extension* extension = 2278 const Extension* extension =
2278 map->extensions().GetExtensionOrAppByURL(opener_url); 2279 map->extensions().GetExtensionOrAppByURL(opener_url);
2279 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) 2280 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension))
2280 *no_javascript_access = true; 2281 *no_javascript_access = true;
2281 #endif 2282 #endif
2282 2283
2283 return true; 2284 return true;
2284 } 2285 }
2285 2286
2286 #if defined(ENABLE_EXTENSIONS) 2287 #if BUILDFLAG(ENABLE_EXTENSIONS)
2287 if (extensions::WebViewRendererState::GetInstance()->IsGuest( 2288 if (extensions::WebViewRendererState::GetInstance()->IsGuest(
2288 render_process_id)) { 2289 render_process_id)) {
2289 return true; 2290 return true;
2290 } 2291 }
2291 2292
2292 if (target_url.SchemeIs(extensions::kExtensionScheme) || 2293 if (target_url.SchemeIs(extensions::kExtensionScheme) ||
2293 target_url.SchemeIs(extensions::kExtensionResourceScheme)) { 2294 target_url.SchemeIs(extensions::kExtensionResourceScheme)) {
2294 // Intentionally duplicating |io_data| and |map| code from above because we 2295 // Intentionally duplicating |io_data| and |map| code from above because we
2295 // want to reduce calls to retrieve them as this function is a SYNC IPC 2296 // want to reduce calls to retrieve them as this function is a SYNC IPC
2296 // handler. 2297 // handler.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 prefs->GetBoolean(prefs::kWebKitPasswordEchoEnabled); 2477 prefs->GetBoolean(prefs::kWebKitPasswordEchoEnabled);
2477 #else 2478 #else
2478 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled; 2479 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
2479 #endif 2480 #endif
2480 2481
2481 web_prefs->text_areas_are_resizable = 2482 web_prefs->text_areas_are_resizable =
2482 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); 2483 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
2483 web_prefs->hyperlink_auditing_enabled = 2484 web_prefs->hyperlink_auditing_enabled =
2484 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); 2485 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
2485 2486
2486 #if defined(ENABLE_EXTENSIONS) 2487 #if BUILDFLAG(ENABLE_EXTENSIONS)
2487 std::string image_animation_policy = 2488 std::string image_animation_policy =
2488 prefs->GetString(prefs::kAnimationPolicy); 2489 prefs->GetString(prefs::kAnimationPolicy);
2489 if (image_animation_policy == kAnimationPolicyOnce) 2490 if (image_animation_policy == kAnimationPolicyOnce)
2490 web_prefs->animation_policy = 2491 web_prefs->animation_policy =
2491 content::IMAGE_ANIMATION_POLICY_ANIMATION_ONCE; 2492 content::IMAGE_ANIMATION_POLICY_ANIMATION_ONCE;
2492 else if (image_animation_policy == kAnimationPolicyNone) 2493 else if (image_animation_policy == kAnimationPolicyNone)
2493 web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_NO_ANIMATION; 2494 web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_NO_ANIMATION;
2494 else 2495 else
2495 web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_ALLOWED; 2496 web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_ALLOWED;
2496 #endif 2497 #endif
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 return views::WindowManagerConnection::Get()->gpu_service(); 2682 return views::WindowManagerConnection::Get()->gpu_service();
2682 #endif 2683 #endif
2683 return nullptr; 2684 return nullptr;
2684 } 2685 }
2685 2686
2686 bool ChromeContentBrowserClient::AllowPepperSocketAPI( 2687 bool ChromeContentBrowserClient::AllowPepperSocketAPI(
2687 content::BrowserContext* browser_context, 2688 content::BrowserContext* browser_context,
2688 const GURL& url, 2689 const GURL& url,
2689 bool private_api, 2690 bool private_api,
2690 const content::SocketPermissionRequest* params) { 2691 const content::SocketPermissionRequest* params) {
2691 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) 2692 #if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
2692 return ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI( 2693 return ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI(
2693 browser_context, url, private_api, params, allowed_socket_origins_); 2694 browser_context, url, private_api, params, allowed_socket_origins_);
2694 #else 2695 #else
2695 return false; 2696 return false;
2696 #endif 2697 #endif
2697 } 2698 }
2698 2699
2699 bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed( 2700 bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed(
2700 content::BrowserContext* browser_context, 2701 content::BrowserContext* browser_context,
2701 const GURL& url) { 2702 const GURL& url) {
2702 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) 2703 #if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
2703 return ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed( 2704 return ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed(
2704 browser_context, url); 2705 browser_context, url);
2705 #else 2706 #else
2706 return false; 2707 return false;
2707 #endif 2708 #endif
2708 } 2709 }
2709 2710
2710 std::unique_ptr<content::VpnServiceProxy> 2711 std::unique_ptr<content::VpnServiceProxy>
2711 ChromeContentBrowserClient::GetVpnServiceProxy( 2712 ChromeContentBrowserClient::GetVpnServiceProxy(
2712 content::BrowserContext* browser_context) { 2713 content::BrowserContext* browser_context) {
2713 #if defined(ENABLE_EXTENSIONS) 2714 #if BUILDFLAG(ENABLE_EXTENSIONS)
2714 return ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy( 2715 return ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy(
2715 browser_context); 2716 browser_context);
2716 #else 2717 #else
2717 return nullptr; 2718 return nullptr;
2718 #endif 2719 #endif
2719 } 2720 }
2720 2721
2721 ui::SelectFilePolicy* ChromeContentBrowserClient::CreateSelectFilePolicy( 2722 ui::SelectFilePolicy* ChromeContentBrowserClient::CreateSelectFilePolicy(
2722 WebContents* web_contents) { 2723 WebContents* web_contents) {
2723 return new ChromeSelectFilePolicy(web_contents); 2724 return new ChromeSelectFilePolicy(web_contents);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 #if defined(ENABLE_MOJO_MEDIA) 2920 #if defined(ENABLE_MOJO_MEDIA)
2920 registry->AddInterface( 2921 registry->AddInterface(
2921 base::Bind(&OutputProtectionImpl::Create, render_frame_host)); 2922 base::Bind(&OutputProtectionImpl::Create, render_frame_host));
2922 #endif // defined(ENABLE_MOJO_MEDIA) 2923 #endif // defined(ENABLE_MOJO_MEDIA)
2923 } 2924 }
2924 2925
2925 void ChromeContentBrowserClient::RegisterRenderFrameMojoInterfaces( 2926 void ChromeContentBrowserClient::RegisterRenderFrameMojoInterfaces(
2926 service_manager::InterfaceRegistry* registry, 2927 service_manager::InterfaceRegistry* registry,
2927 content::RenderFrameHost* render_frame_host) { 2928 content::RenderFrameHost* render_frame_host) {
2928 if (base::FeatureList::IsEnabled(features::kWebUsb) 2929 if (base::FeatureList::IsEnabled(features::kWebUsb)
2929 #if defined(ENABLE_EXTENSIONS) 2930 #if BUILDFLAG(ENABLE_EXTENSIONS)
2930 && 2931 &&
2931 !render_frame_host->GetSiteInstance()->GetSiteURL().SchemeIs( 2932 !render_frame_host->GetSiteInstance()->GetSiteURL().SchemeIs(
2932 extensions::kExtensionScheme) 2933 extensions::kExtensionScheme)
2933 #endif 2934 #endif
2934 ) { 2935 ) {
2935 registry->AddInterface( 2936 registry->AddInterface(
2936 base::Bind(&CreateUsbDeviceManager, render_frame_host)); 2937 base::Bind(&CreateUsbDeviceManager, render_frame_host));
2937 registry->AddInterface( 2938 registry->AddInterface(
2938 base::Bind(&CreateWebUsbChooserService, render_frame_host)); 2939 base::Bind(&CreateWebUsbChooserService, render_frame_host));
2939 } 2940 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 if (!prerender_contents) { 3140 if (!prerender_contents) {
3140 auto intent_picker_cb = base::Bind(ShowIntentPickerBubble()); 3141 auto intent_picker_cb = base::Bind(ShowIntentPickerBubble());
3141 auto url_to_arc_throttle = base::MakeUnique<arc::ArcNavigationThrottle>( 3142 auto url_to_arc_throttle = base::MakeUnique<arc::ArcNavigationThrottle>(
3142 handle, intent_picker_cb); 3143 handle, intent_picker_cb);
3143 throttles.push_back(std::move(url_to_arc_throttle)); 3144 throttles.push_back(std::move(url_to_arc_throttle));
3144 } 3145 }
3145 } 3146 }
3146 } 3147 }
3147 #endif 3148 #endif
3148 3149
3149 #if defined(ENABLE_EXTENSIONS) 3150 #if BUILDFLAG(ENABLE_EXTENSIONS)
3150 throttles.push_back(new extensions::ExtensionNavigationThrottle(handle)); 3151 throttles.push_back(new extensions::ExtensionNavigationThrottle(handle));
3151 #endif 3152 #endif
3152 3153
3153 return throttles; 3154 return throttles;
3154 } 3155 }
3155 3156
3156 std::unique_ptr<content::NavigationUIData> 3157 std::unique_ptr<content::NavigationUIData>
3157 ChromeContentBrowserClient::GetNavigationUIData( 3158 ChromeContentBrowserClient::GetNavigationUIData(
3158 content::NavigationHandle* navigation_handle) { 3159 content::NavigationHandle* navigation_handle) {
3159 return base::MakeUnique<ChromeNavigationUIData>(navigation_handle); 3160 return base::MakeUnique<ChromeNavigationUIData>(navigation_handle);
3160 } 3161 }
3161 3162
3162 content::DevToolsManagerDelegate* 3163 content::DevToolsManagerDelegate*
3163 ChromeContentBrowserClient::GetDevToolsManagerDelegate() { 3164 ChromeContentBrowserClient::GetDevToolsManagerDelegate() {
3164 #if defined(OS_ANDROID) 3165 #if defined(OS_ANDROID)
3165 return new DevToolsManagerDelegateAndroid(); 3166 return new DevToolsManagerDelegateAndroid();
3166 #else 3167 #else
3167 return new ChromeDevToolsManagerDelegate(); 3168 return new ChromeDevToolsManagerDelegate();
3168 #endif 3169 #endif
3169 } 3170 }
3170 3171
3171 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { 3172 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() {
3172 return new ChromeTracingDelegate(); 3173 return new ChromeTracingDelegate();
3173 } 3174 }
3174 3175
3175 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( 3176 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
3176 content::BrowserContext* browser_context, 3177 content::BrowserContext* browser_context,
3177 const GURL& url) { 3178 const GURL& url) {
3178 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) 3179 #if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
3179 return ChromeContentBrowserClientPluginsPart:: 3180 return ChromeContentBrowserClientPluginsPart::
3180 IsPluginAllowedToCallRequestOSFileHandle(browser_context, url, 3181 IsPluginAllowedToCallRequestOSFileHandle(browser_context, url,
3181 allowed_file_handle_origins_); 3182 allowed_file_handle_origins_);
3182 #else 3183 #else
3183 return false; 3184 return false;
3184 #endif 3185 #endif
3185 } 3186 }
3186 3187
3187 bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs( 3188 bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
3188 content::BrowserContext* browser_context, 3189 content::BrowserContext* browser_context,
3189 const GURL& url) { 3190 const GURL& url) {
3190 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) 3191 #if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
3191 return ChromeContentBrowserClientPluginsPart:: 3192 return ChromeContentBrowserClientPluginsPart::
3192 IsPluginAllowedToUseDevChannelAPIs(browser_context, url, 3193 IsPluginAllowedToUseDevChannelAPIs(browser_context, url,
3193 allowed_dev_channel_origins_); 3194 allowed_dev_channel_origins_);
3194 #else 3195 #else
3195 return false; 3196 return false;
3196 #endif 3197 #endif
3197 } 3198 }
3198 3199
3199 void ChromeContentBrowserClient::OverridePageVisibilityState( 3200 void ChromeContentBrowserClient::OverridePageVisibilityState(
3200 RenderFrameHost* render_frame_host, 3201 RenderFrameHost* render_frame_host,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 kWebRtcDevSwitchNames, 3235 kWebRtcDevSwitchNames,
3235 arraysize(kWebRtcDevSwitchNames)); 3236 arraysize(kWebRtcDevSwitchNames));
3236 } 3237 }
3237 } 3238 }
3238 #endif // defined(ENABLE_WEBRTC) 3239 #endif // defined(ENABLE_WEBRTC)
3239 3240
3240 std::unique_ptr<content::MemoryCoordinatorDelegate> 3241 std::unique_ptr<content::MemoryCoordinatorDelegate>
3241 ChromeContentBrowserClient::GetMemoryCoordinatorDelegate() { 3242 ChromeContentBrowserClient::GetMemoryCoordinatorDelegate() {
3242 return memory::ChromeMemoryCoordinatorDelegate::Create(); 3243 return memory::ChromeMemoryCoordinatorDelegate::Create();
3243 } 3244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698