| 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 <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "chrome/browser/profiles/profile.h" | 57 #include "chrome/browser/profiles/profile.h" |
| 58 #include "chrome/browser/profiles/profile_io_data.h" | 58 #include "chrome/browser/profiles/profile_io_data.h" |
| 59 #include "chrome/browser/profiles/profile_manager.h" | 59 #include "chrome/browser/profiles/profile_manager.h" |
| 60 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 60 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 61 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" | 61 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
| 62 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" | 62 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" |
| 63 #include "chrome/browser/search/instant_service.h" | 63 #include "chrome/browser/search/instant_service.h" |
| 64 #include "chrome/browser/search/instant_service_factory.h" | 64 #include "chrome/browser/search/instant_service_factory.h" |
| 65 #include "chrome/browser/search/search.h" | 65 #include "chrome/browser/search/search.h" |
| 66 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" | 66 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" |
| 67 #include "chrome/browser/signin/signin_manager.h" | |
| 68 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 69 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 67 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
| 70 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" | 68 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
| 71 #include "chrome/browser/ssl/ssl_add_certificate.h" | 69 #include "chrome/browser/ssl/ssl_add_certificate.h" |
| 72 #include "chrome/browser/ssl/ssl_blocking_page.h" | 70 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 73 #include "chrome/browser/ssl/ssl_tab_helper.h" | 71 #include "chrome/browser/ssl/ssl_tab_helper.h" |
| 74 #include "chrome/browser/tab_contents/tab_util.h" | 72 #include "chrome/browser/tab_contents/tab_util.h" |
| 75 #include "chrome/browser/toolkit_extra_parts.h" | 73 #include "chrome/browser/toolkit_extra_parts.h" |
| 76 #include "chrome/browser/ui/chrome_select_file_policy.h" | 74 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 77 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 75 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
| 78 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 76 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 #endif | 151 #endif |
| 154 | 152 |
| 155 #if defined(OS_ANDROID) | 153 #if defined(OS_ANDROID) |
| 156 #include "ui/base/ui_base_paths.h" | 154 #include "ui/base/ui_base_paths.h" |
| 157 #endif | 155 #endif |
| 158 | 156 |
| 159 #if defined(USE_NSS) | 157 #if defined(USE_NSS) |
| 160 #include "chrome/browser/ui/crypto_module_password_dialog.h" | 158 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 161 #endif | 159 #endif |
| 162 | 160 |
| 161 #if !defined(OS_CHROMEOS) |
| 162 #include "chrome/browser/signin/signin_manager.h" |
| 163 #include "chrome/browser/signin/signin_manager_factory.h" |
| 164 #endif |
| 165 |
| 163 using base::FileDescriptor; | 166 using base::FileDescriptor; |
| 164 using content::AccessTokenStore; | 167 using content::AccessTokenStore; |
| 165 using content::BrowserChildProcessHostIterator; | 168 using content::BrowserChildProcessHostIterator; |
| 166 using content::BrowserThread; | 169 using content::BrowserThread; |
| 167 using content::BrowserURLHandler; | 170 using content::BrowserURLHandler; |
| 168 using content::ChildProcessSecurityPolicy; | 171 using content::ChildProcessSecurityPolicy; |
| 169 using content::FileDescriptorInfo; | 172 using content::FileDescriptorInfo; |
| 170 using content::QuotaPermissionContext; | 173 using content::QuotaPermissionContext; |
| 171 using content::RenderViewHost; | 174 using content::RenderViewHost; |
| 172 using content::SiteInstance; | 175 using content::SiteInstance; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 440 |
| 438 // Replace the scheme with "chrome-search:". | 441 // Replace the scheme with "chrome-search:". |
| 439 url_canon::Replacements<char> replacements; | 442 url_canon::Replacements<char> replacements; |
| 440 std::string search_scheme(chrome::kChromeSearchScheme); | 443 std::string search_scheme(chrome::kChromeSearchScheme); |
| 441 replacements.SetScheme(search_scheme.data(), | 444 replacements.SetScheme(search_scheme.data(), |
| 442 url_parse::Component(0, search_scheme.length())); | 445 url_parse::Component(0, search_scheme.length())); |
| 443 effective_url = effective_url.ReplaceComponents(replacements); | 446 effective_url = effective_url.ReplaceComponents(replacements); |
| 444 return effective_url; | 447 return effective_url; |
| 445 } | 448 } |
| 446 | 449 |
| 450 #if !defined(OS_CHROMEOS) |
| 447 GURL GetEffectiveURLForSignin(const GURL& url) { | 451 GURL GetEffectiveURLForSignin(const GURL& url) { |
| 448 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); | 452 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); |
| 449 | 453 |
| 450 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); | 454 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); |
| 451 // Copy the path because the argument to SetPathStr must outlive | 455 // Copy the path because the argument to SetPathStr must outlive |
| 452 // the Replacements object. | 456 // the Replacements object. |
| 453 const std::string path_copy(url.path()); | 457 const std::string path_copy(url.path()); |
| 454 GURL::Replacements replacements; | 458 GURL::Replacements replacements; |
| 455 replacements.SetPathStr(path_copy); | 459 replacements.SetPathStr(path_copy); |
| 456 effective_url = effective_url.ReplaceComponents(replacements); | 460 effective_url = effective_url.ReplaceComponents(replacements); |
| 457 return effective_url; | 461 return effective_url; |
| 458 } | 462 } |
| 463 #endif |
| 459 | 464 |
| 460 } // namespace | 465 } // namespace |
| 461 | 466 |
| 462 namespace chrome { | 467 namespace chrome { |
| 463 | 468 |
| 464 ChromeContentBrowserClient::ChromeContentBrowserClient() { | 469 ChromeContentBrowserClient::ChromeContentBrowserClient() { |
| 465 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 470 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 466 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 471 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 467 } | 472 } |
| 468 | 473 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 content::BrowserContext* browser_context, const GURL& url) { | 712 content::BrowserContext* browser_context, const GURL& url) { |
| 708 Profile* profile = Profile::FromBrowserContext(browser_context); | 713 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 709 if (!profile) | 714 if (!profile) |
| 710 return url; | 715 return url; |
| 711 | 716 |
| 712 // If the input |url| should be assigned to the Instant renderer, make its | 717 // If the input |url| should be assigned to the Instant renderer, make its |
| 713 // effective URL distinct from other URLs on the search provider's domain. | 718 // effective URL distinct from other URLs on the search provider's domain. |
| 714 if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) | 719 if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) |
| 715 return GetEffectiveURLForInstant(url, profile); | 720 return GetEffectiveURLForInstant(url, profile); |
| 716 | 721 |
| 722 #if !defined(OS_CHROMEOS) |
| 717 // If the input |url| should be assigned to the Signin renderer, make its | 723 // If the input |url| should be assigned to the Signin renderer, make its |
| 718 // effective URL distinct from other URLs on the signin service's domain. | 724 // effective URL distinct from other URLs on the signin service's domain. |
| 719 // Note that the signin renderer will be allowed to sign the user in to | 725 // Note that the signin renderer will be allowed to sign the user in to |
| 720 // Chrome. | 726 // Chrome. |
| 721 if (SigninManager::IsWebBasedSigninFlowURL(url)) | 727 if (SigninManager::IsWebBasedSigninFlowURL(url)) |
| 722 return GetEffectiveURLForSignin(url); | 728 return GetEffectiveURLForSignin(url); |
| 729 #endif |
| 723 | 730 |
| 724 // If the input |url| is part of an installed app, the effective URL is an | 731 // If the input |url| is part of an installed app, the effective URL is an |
| 725 // extension URL with the ID of that extension as the host. This has the | 732 // extension URL with the ID of that extension as the host. This has the |
| 726 // effect of grouping apps together in a common SiteInstance. | 733 // effect of grouping apps together in a common SiteInstance. |
| 727 ExtensionService* extension_service = | 734 ExtensionService* extension_service = |
| 728 extensions::ExtensionSystem::Get(profile)->extension_service(); | 735 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 729 if (!extension_service) | 736 if (!extension_service) |
| 730 return url; | 737 return url; |
| 731 | 738 |
| 732 const Extension* extension = extension_service->extensions()-> | 739 const Extension* extension = extension_service->extensions()-> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 751 // URLs for hosted apps (apart from bookmark apps) should have an extension | 758 // URLs for hosted apps (apart from bookmark apps) should have an extension |
| 752 // scheme by now. | 759 // scheme by now. |
| 753 | 760 |
| 754 Profile* profile = Profile::FromBrowserContext(browser_context); | 761 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 755 if (!profile) | 762 if (!profile) |
| 756 return false; | 763 return false; |
| 757 | 764 |
| 758 if (chrome::ShouldAssignURLToInstantRenderer(effective_url, profile)) | 765 if (chrome::ShouldAssignURLToInstantRenderer(effective_url, profile)) |
| 759 return true; | 766 return true; |
| 760 | 767 |
| 768 #if !defined(OS_CHROMEOS) |
| 761 if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) | 769 if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) |
| 762 return true; | 770 return true; |
| 771 #endif |
| 763 | 772 |
| 764 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) | 773 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) |
| 765 return false; | 774 return false; |
| 766 | 775 |
| 767 ExtensionService* extension_service = | 776 ExtensionService* extension_service = |
| 768 extensions::ExtensionSystem::Get(profile)->extension_service(); | 777 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 769 if (!extension_service) | 778 if (!extension_service) |
| 770 return false; | 779 return false; |
| 771 | 780 |
| 772 const Extension* extension = extension_service->extensions()-> | 781 const Extension* extension = extension_service->extensions()-> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 // share any host. | 840 // share any host. |
| 832 if (!profile) | 841 if (!profile) |
| 833 return true; | 842 return true; |
| 834 | 843 |
| 835 InstantService* instant_service = | 844 InstantService* instant_service = |
| 836 InstantServiceFactory::GetForProfile(profile); | 845 InstantServiceFactory::GetForProfile(profile); |
| 837 if (instant_service && | 846 if (instant_service && |
| 838 instant_service->IsInstantProcess(process_host->GetID())) | 847 instant_service->IsInstantProcess(process_host->GetID())) |
| 839 return chrome::ShouldAssignURLToInstantRenderer(site_url, profile); | 848 return chrome::ShouldAssignURLToInstantRenderer(site_url, profile); |
| 840 | 849 |
| 850 #if !defined(OS_CHROMEOS) |
| 841 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); | 851 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
| 842 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) | 852 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) |
| 843 return SigninManager::IsWebBasedSigninFlowURL(site_url); | 853 return SigninManager::IsWebBasedSigninFlowURL(site_url); |
| 854 #endif |
| 844 | 855 |
| 845 ExtensionService* service = | 856 ExtensionService* service = |
| 846 extensions::ExtensionSystem::Get(profile)->extension_service(); | 857 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 847 extensions::ProcessMap* process_map = service->process_map(); | 858 extensions::ProcessMap* process_map = service->process_map(); |
| 848 | 859 |
| 849 // Don't allow the Task Manager to share a process with anything else. | 860 // Don't allow the Task Manager to share a process with anything else. |
| 850 // Otherwise it can affect the renderers it is observing. | 861 // Otherwise it can affect the renderers it is observing. |
| 851 // Note: we could create another RenderProcessHostPrivilege bucket for | 862 // Note: we could create another RenderProcessHostPrivilege bucket for |
| 852 // this to allow multiple chrome://tasks instances to share, but that's | 863 // this to allow multiple chrome://tasks instances to share, but that's |
| 853 // a very unlikely case without serious consequences. | 864 // a very unlikely case without serious consequences. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 // Remember the ID of the Instant process to signal the renderer process | 942 // Remember the ID of the Instant process to signal the renderer process |
| 932 // on startup in |AppendExtraCommandLineSwitches| below. | 943 // on startup in |AppendExtraCommandLineSwitches| below. |
| 933 if (chrome::ShouldAssignURLToInstantRenderer( | 944 if (chrome::ShouldAssignURLToInstantRenderer( |
| 934 site_instance->GetSiteURL(), profile)) { | 945 site_instance->GetSiteURL(), profile)) { |
| 935 InstantService* instant_service = | 946 InstantService* instant_service = |
| 936 InstantServiceFactory::GetForProfile(profile); | 947 InstantServiceFactory::GetForProfile(profile); |
| 937 if (instant_service) | 948 if (instant_service) |
| 938 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); | 949 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
| 939 } | 950 } |
| 940 | 951 |
| 952 #if !defined(OS_CHROMEOS) |
| 941 // We only expect there to be one signin process as we use process-per-site | 953 // We only expect there to be one signin process as we use process-per-site |
| 942 // for signin URLs. The signin process will be cleared from SigninManager | 954 // for signin URLs. The signin process will be cleared from SigninManager |
| 943 // when the renderer is destroyed. | 955 // when the renderer is destroyed. |
| 944 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { | 956 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { |
| 945 SigninManager* signin_manager = | 957 SigninManager* signin_manager = |
| 946 SigninManagerFactory::GetForProfile(profile); | 958 SigninManagerFactory::GetForProfile(profile); |
| 947 if (signin_manager) | 959 if (signin_manager) |
| 948 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); | 960 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); |
| 949 } | 961 } |
| 962 #endif |
| 950 | 963 |
| 951 ExtensionService* service = | 964 ExtensionService* service = |
| 952 extensions::ExtensionSystem::Get(profile)->extension_service(); | 965 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 953 if (!service) | 966 if (!service) |
| 954 return; | 967 return; |
| 955 | 968 |
| 956 const Extension* extension = | 969 const Extension* extension = |
| 957 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( | 970 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( |
| 958 site_instance->GetSiteURL())); | 971 site_instance->GetSiteURL())); |
| 959 if (!extension) | 972 if (!extension) |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 | 1145 |
| 1133 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled)) | 1146 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled)) |
| 1134 command_line->AppendSwitch(switches::kRendererPrintPreview); | 1147 command_line->AppendSwitch(switches::kRendererPrintPreview); |
| 1135 | 1148 |
| 1136 InstantService* instant_service = | 1149 InstantService* instant_service = |
| 1137 InstantServiceFactory::GetForProfile(profile); | 1150 InstantServiceFactory::GetForProfile(profile); |
| 1138 if (instant_service && | 1151 if (instant_service && |
| 1139 instant_service->IsInstantProcess(process->GetID())) | 1152 instant_service->IsInstantProcess(process->GetID())) |
| 1140 command_line->AppendSwitch(switches::kInstantProcess); | 1153 command_line->AppendSwitch(switches::kInstantProcess); |
| 1141 | 1154 |
| 1155 #if !defined(OS_CHROMEOS) |
| 1142 SigninManager* signin_manager = | 1156 SigninManager* signin_manager = |
| 1143 SigninManagerFactory::GetForProfile(profile); | 1157 SigninManagerFactory::GetForProfile(profile); |
| 1144 if (signin_manager && signin_manager->IsSigninProcess(process->GetID())) | 1158 if (signin_manager && signin_manager->IsSigninProcess(process->GetID())) |
| 1145 command_line->AppendSwitch(switches::kSigninProcess); | 1159 command_line->AppendSwitch(switches::kSigninProcess); |
| 1160 #endif |
| 1146 } | 1161 } |
| 1147 | 1162 |
| 1148 if (content::IsThreadedCompositingEnabled()) | 1163 if (content::IsThreadedCompositingEnabled()) |
| 1149 command_line->AppendSwitch(switches::kEnableThreadedCompositing); | 1164 command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
| 1150 | 1165 |
| 1151 // Please keep this in alphabetical order. | 1166 // Please keep this in alphabetical order. |
| 1152 static const char* const kSwitchNames[] = { | 1167 static const char* const kSwitchNames[] = { |
| 1153 switches::kAllowRequestOSFileHandleAPI, | 1168 switches::kAllowRequestOSFileHandleAPI, |
| 1154 switches::kAllowHTTPBackgroundPage, | 1169 switches::kAllowHTTPBackgroundPage, |
| 1155 switches::kAllowLegacyExtensionManifests, | 1170 switches::kAllowLegacyExtensionManifests, |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 io_thread_application_locale_ = locale; | 2195 io_thread_application_locale_ = locale; |
| 2181 } | 2196 } |
| 2182 | 2197 |
| 2183 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2198 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
| 2184 const std::string& locale) { | 2199 const std::string& locale) { |
| 2185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2186 io_thread_application_locale_ = locale; | 2201 io_thread_application_locale_ = locale; |
| 2187 } | 2202 } |
| 2188 | 2203 |
| 2189 } // namespace chrome | 2204 } // namespace chrome |
| OLD | NEW |