| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 894 } |
| 895 | 895 |
| 896 GURL ChromeContentBrowserClient::GetEffectiveURL( | 896 GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 897 content::BrowserContext* browser_context, const GURL& url) { | 897 content::BrowserContext* browser_context, const GURL& url) { |
| 898 Profile* profile = Profile::FromBrowserContext(browser_context); | 898 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 899 if (!profile) | 899 if (!profile) |
| 900 return url; | 900 return url; |
| 901 | 901 |
| 902 // If the input |url| should be assigned to the Instant renderer, make its | 902 // If the input |url| should be assigned to the Instant renderer, make its |
| 903 // effective URL distinct from other URLs on the search provider's domain. | 903 // effective URL distinct from other URLs on the search provider's domain. |
| 904 if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) | 904 if (search::ShouldAssignURLToInstantRenderer(url, profile)) |
| 905 return chrome::GetEffectiveURLForInstant(url, profile); | 905 return search::GetEffectiveURLForInstant(url, profile); |
| 906 | 906 |
| 907 #if defined(ENABLE_EXTENSIONS) | 907 #if defined(ENABLE_EXTENSIONS) |
| 908 return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL( | 908 return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL( |
| 909 profile, url); | 909 profile, url); |
| 910 #else | 910 #else |
| 911 return url; | 911 return url; |
| 912 #endif | 912 #endif |
| 913 } | 913 } |
| 914 | 914 |
| 915 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( | 915 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
| 916 content::BrowserContext* browser_context, const GURL& effective_url) { | 916 content::BrowserContext* browser_context, const GURL& effective_url) { |
| 917 // Non-extension, non-Instant URLs should generally use | 917 // Non-extension, non-Instant URLs should generally use |
| 918 // process-per-site-instance. Because we expect to use the effective URL, | 918 // process-per-site-instance. Because we expect to use the effective URL, |
| 919 // URLs for hosted apps (apart from bookmark apps) should have an extension | 919 // URLs for hosted apps (apart from bookmark apps) should have an extension |
| 920 // scheme by now. | 920 // scheme by now. |
| 921 | 921 |
| 922 Profile* profile = Profile::FromBrowserContext(browser_context); | 922 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 923 if (!profile) | 923 if (!profile) |
| 924 return false; | 924 return false; |
| 925 | 925 |
| 926 if (chrome::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) | 926 if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) |
| 927 return true; | 927 return true; |
| 928 | 928 |
| 929 #if defined(ENABLE_EXTENSIONS) | 929 #if defined(ENABLE_EXTENSIONS) |
| 930 return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( | 930 return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( |
| 931 profile, effective_url); | 931 profile, effective_url); |
| 932 #else | 932 #else |
| 933 return false; | 933 return false; |
| 934 #endif | 934 #endif |
| 935 } | 935 } |
| 936 | 936 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 return true; | 1027 return true; |
| 1028 | 1028 |
| 1029 // Instant URLs should only be in the instant process and instant process | 1029 // Instant URLs should only be in the instant process and instant process |
| 1030 // should only have Instant URLs. | 1030 // should only have Instant URLs. |
| 1031 InstantService* instant_service = | 1031 InstantService* instant_service = |
| 1032 InstantServiceFactory::GetForProfile(profile); | 1032 InstantServiceFactory::GetForProfile(profile); |
| 1033 if (instant_service) { | 1033 if (instant_service) { |
| 1034 bool is_instant_process = instant_service->IsInstantProcess( | 1034 bool is_instant_process = instant_service->IsInstantProcess( |
| 1035 process_host->GetID()); | 1035 process_host->GetID()); |
| 1036 bool should_be_in_instant_process = | 1036 bool should_be_in_instant_process = |
| 1037 chrome::ShouldAssignURLToInstantRenderer(site_url, profile); | 1037 search::ShouldAssignURLToInstantRenderer(site_url, profile); |
| 1038 if (is_instant_process || should_be_in_instant_process) | 1038 if (is_instant_process || should_be_in_instant_process) |
| 1039 return is_instant_process && should_be_in_instant_process; | 1039 return is_instant_process && should_be_in_instant_process; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 #if defined(ENABLE_EXTENSIONS) | 1042 #if defined(ENABLE_EXTENSIONS) |
| 1043 return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( | 1043 return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( |
| 1044 profile, process_host, site_url); | 1044 profile, process_host, site_url); |
| 1045 #else | 1045 #else |
| 1046 return true; | 1046 return true; |
| 1047 #endif | 1047 #endif |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 SiteInstance* site_instance) { | 1084 SiteInstance* site_instance) { |
| 1085 CHECK(site_instance->HasProcess()); | 1085 CHECK(site_instance->HasProcess()); |
| 1086 | 1086 |
| 1087 Profile* profile = Profile::FromBrowserContext( | 1087 Profile* profile = Profile::FromBrowserContext( |
| 1088 site_instance->GetBrowserContext()); | 1088 site_instance->GetBrowserContext()); |
| 1089 if (!profile) | 1089 if (!profile) |
| 1090 return; | 1090 return; |
| 1091 | 1091 |
| 1092 // Remember the ID of the Instant process to signal the renderer process | 1092 // Remember the ID of the Instant process to signal the renderer process |
| 1093 // on startup in |AppendExtraCommandLineSwitches| below. | 1093 // on startup in |AppendExtraCommandLineSwitches| below. |
| 1094 if (chrome::ShouldAssignURLToInstantRenderer( | 1094 if (search::ShouldAssignURLToInstantRenderer(site_instance->GetSiteURL(), |
| 1095 site_instance->GetSiteURL(), profile)) { | 1095 profile)) { |
| 1096 InstantService* instant_service = | 1096 InstantService* instant_service = |
| 1097 InstantServiceFactory::GetForProfile(profile); | 1097 InstantServiceFactory::GetForProfile(profile); |
| 1098 if (instant_service) | 1098 if (instant_service) |
| 1099 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); | 1099 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 for (size_t i = 0; i < extra_parts_.size(); ++i) | 1102 for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 1103 extra_parts_[i]->SiteInstanceGotProcess(site_instance); | 1103 extra_parts_[i]->SiteInstanceGotProcess(site_instance); |
| 1104 } | 1104 } |
| 1105 | 1105 |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 handler->SetFixupHandler(&FixupBrowserAboutURL); | 2172 handler->SetFixupHandler(&FixupBrowserAboutURL); |
| 2173 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 2173 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 2174 BrowserURLHandler::null_handler()); | 2174 BrowserURLHandler::null_handler()); |
| 2175 | 2175 |
| 2176 #if defined(OS_ANDROID) | 2176 #if defined(OS_ANDROID) |
| 2177 // Handler to rewrite chrome://newtab on Android. | 2177 // Handler to rewrite chrome://newtab on Android. |
| 2178 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, | 2178 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
| 2179 BrowserURLHandler::null_handler()); | 2179 BrowserURLHandler::null_handler()); |
| 2180 #else | 2180 #else |
| 2181 // Handler to rewrite chrome://newtab for InstantExtended. | 2181 // Handler to rewrite chrome://newtab for InstantExtended. |
| 2182 handler->AddHandlerPair(&chrome::HandleNewTabURLRewrite, | 2182 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
| 2183 &chrome::HandleNewTabURLReverseRewrite); | 2183 &search::HandleNewTabURLReverseRewrite); |
| 2184 #endif | 2184 #endif |
| 2185 | 2185 |
| 2186 // chrome: & friends. | 2186 // chrome: & friends. |
| 2187 handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse); | 2187 handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse); |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 void ChromeContentBrowserClient::ClearCache(RenderFrameHost* rfh) { | 2190 void ChromeContentBrowserClient::ClearCache(RenderFrameHost* rfh) { |
| 2191 Profile* profile = Profile::FromBrowserContext( | 2191 Profile* profile = Profile::FromBrowserContext( |
| 2192 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); | 2192 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
| 2193 BrowsingDataRemover* remover = | 2193 BrowsingDataRemover* remover = |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2564 switches::kDisableWebRtcEncryption, | 2564 switches::kDisableWebRtcEncryption, |
| 2565 }; | 2565 }; |
| 2566 to_command_line->CopySwitchesFrom(from_command_line, | 2566 to_command_line->CopySwitchesFrom(from_command_line, |
| 2567 kWebRtcDevSwitchNames, | 2567 kWebRtcDevSwitchNames, |
| 2568 arraysize(kWebRtcDevSwitchNames)); | 2568 arraysize(kWebRtcDevSwitchNames)); |
| 2569 } | 2569 } |
| 2570 } | 2570 } |
| 2571 #endif // defined(ENABLE_WEBRTC) | 2571 #endif // defined(ENABLE_WEBRTC) |
| 2572 | 2572 |
| 2573 } // namespace chrome | 2573 } // namespace chrome |
| OLD | NEW |