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