| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "chrome/browser/prerender/prerender_message_filter.h" | 56 #include "chrome/browser/prerender/prerender_message_filter.h" |
| 57 #include "chrome/browser/prerender/prerender_tracker.h" | 57 #include "chrome/browser/prerender/prerender_tracker.h" |
| 58 #include "chrome/browser/printing/printing_message_filter.h" | 58 #include "chrome/browser/printing/printing_message_filter.h" |
| 59 #include "chrome/browser/profiles/profile.h" | 59 #include "chrome/browser/profiles/profile.h" |
| 60 #include "chrome/browser/profiles/profile_io_data.h" | 60 #include "chrome/browser/profiles/profile_io_data.h" |
| 61 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
| 62 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 62 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 63 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" | 63 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
| 64 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" | 64 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" |
| 65 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" | 65 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" |
| 66 #include "chrome/browser/signin/signin_manager.h" |
| 67 #include "chrome/browser/signin/signin_manager_factory.h" |
| 66 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 68 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
| 67 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" | 69 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
| 68 #include "chrome/browser/ssl/ssl_add_certificate.h" | 70 #include "chrome/browser/ssl/ssl_add_certificate.h" |
| 69 #include "chrome/browser/ssl/ssl_blocking_page.h" | 71 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 70 #include "chrome/browser/ssl/ssl_tab_helper.h" | 72 #include "chrome/browser/ssl/ssl_tab_helper.h" |
| 71 #include "chrome/browser/tab_contents/tab_util.h" | 73 #include "chrome/browser/tab_contents/tab_util.h" |
| 72 #include "chrome/browser/toolkit_extra_parts.h" | 74 #include "chrome/browser/toolkit_extra_parts.h" |
| 73 #include "chrome/browser/ui/chrome_select_file_policy.h" | 75 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 74 #include "chrome/browser/ui/search/search.h" | 76 #include "chrome/browser/ui/search/search.h" |
| 75 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 77 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
| 76 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 78 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 79 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 77 #include "chrome/browser/user_style_sheet_watcher.h" | 80 #include "chrome/browser/user_style_sheet_watcher.h" |
| 78 #include "chrome/browser/user_style_sheet_watcher_factory.h" | 81 #include "chrome/browser/user_style_sheet_watcher_factory.h" |
| 79 #include "chrome/browser/view_type_utils.h" | 82 #include "chrome/browser/view_type_utils.h" |
| 80 #include "chrome/common/child_process_logging.h" | 83 #include "chrome/common/child_process_logging.h" |
| 81 #include "chrome/common/chrome_constants.h" | 84 #include "chrome/common/chrome_constants.h" |
| 82 #include "chrome/common/chrome_paths.h" | 85 #include "chrome/common/chrome_paths.h" |
| 83 #include "chrome/common/chrome_switches.h" | 86 #include "chrome/common/chrome_switches.h" |
| 84 #include "chrome/common/extensions/background_info.h" | 87 #include "chrome/common/extensions/background_info.h" |
| 85 #include "chrome/common/extensions/extension.h" | 88 #include "chrome/common/extensions/extension.h" |
| 86 #include "chrome/common/extensions/extension_process_policy.h" | 89 #include "chrome/common/extensions/extension_process_policy.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 435 |
| 433 // Replace the scheme with "chrome-search:". | 436 // Replace the scheme with "chrome-search:". |
| 434 url_canon::Replacements<char> replacements; | 437 url_canon::Replacements<char> replacements; |
| 435 std::string search_scheme(chrome::kChromeSearchScheme); | 438 std::string search_scheme(chrome::kChromeSearchScheme); |
| 436 replacements.SetScheme(search_scheme.data(), | 439 replacements.SetScheme(search_scheme.data(), |
| 437 url_parse::Component(0, search_scheme.length())); | 440 url_parse::Component(0, search_scheme.length())); |
| 438 effective_url = effective_url.ReplaceComponents(replacements); | 441 effective_url = effective_url.ReplaceComponents(replacements); |
| 439 return effective_url; | 442 return effective_url; |
| 440 } | 443 } |
| 441 | 444 |
| 445 GURL GetEffectiveURLForSignin(const GURL& url) { |
| 446 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); |
| 447 |
| 448 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); |
| 449 GURL::Replacements replacements; |
| 450 replacements.SetPathStr(url.path()); |
| 451 effective_url = effective_url.ReplaceComponents(replacements); |
| 452 return effective_url; |
| 453 } |
| 454 |
| 442 } // namespace | 455 } // namespace |
| 443 | 456 |
| 444 namespace chrome { | 457 namespace chrome { |
| 445 | 458 |
| 446 ChromeContentBrowserClient::ChromeContentBrowserClient() { | 459 ChromeContentBrowserClient::ChromeContentBrowserClient() { |
| 447 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 460 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 448 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 461 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 449 } | 462 } |
| 450 | 463 |
| 451 ChromeContentBrowserClient::~ChromeContentBrowserClient() { | 464 ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 content::BrowserContext* browser_context, const GURL& url) { | 702 content::BrowserContext* browser_context, const GURL& url) { |
| 690 Profile* profile = Profile::FromBrowserContext(browser_context); | 703 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 691 if (!profile) | 704 if (!profile) |
| 692 return url; | 705 return url; |
| 693 | 706 |
| 694 // If the input |url| should be assigned to the Instant renderer, make its | 707 // If the input |url| should be assigned to the Instant renderer, make its |
| 695 // effective URL distinct from other URLs on the search provider's domain. | 708 // effective URL distinct from other URLs on the search provider's domain. |
| 696 if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile)) | 709 if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile)) |
| 697 return GetEffectiveURLForInstant(url, profile); | 710 return GetEffectiveURLForInstant(url, profile); |
| 698 | 711 |
| 712 // If the input |url| should be assigned to the Signin renderer, make its |
| 713 // effective URL distinct from other URLs on the signin service's domain. |
| 714 // Note that the signin renderer will be allowed to sign the user in to |
| 715 // Chrome. |
| 716 if (SigninManager::IsWebBasedSigninFlowURL(url)) |
| 717 return GetEffectiveURLForSignin(url); |
| 718 |
| 699 // If the input |url| is part of an installed app, the effective URL is an | 719 // If the input |url| is part of an installed app, the effective URL is an |
| 700 // extension URL with the ID of that extension as the host. This has the | 720 // extension URL with the ID of that extension as the host. This has the |
| 701 // effect of grouping apps together in a common SiteInstance. | 721 // effect of grouping apps together in a common SiteInstance. |
| 702 ExtensionService* extension_service = | 722 ExtensionService* extension_service = |
| 703 extensions::ExtensionSystem::Get(profile)->extension_service(); | 723 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 704 if (!extension_service) | 724 if (!extension_service) |
| 705 return url; | 725 return url; |
| 706 | 726 |
| 707 const Extension* extension = extension_service->extensions()-> | 727 const Extension* extension = extension_service->extensions()-> |
| 708 GetHostedAppByURL(ExtensionURLInfo(url)); | 728 GetHostedAppByURL(ExtensionURLInfo(url)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 726 // URLs for hosted apps (apart from bookmark apps) should have an extension | 746 // URLs for hosted apps (apart from bookmark apps) should have an extension |
| 727 // scheme by now. | 747 // scheme by now. |
| 728 | 748 |
| 729 Profile* profile = Profile::FromBrowserContext(browser_context); | 749 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 730 if (!profile) | 750 if (!profile) |
| 731 return false; | 751 return false; |
| 732 | 752 |
| 733 if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile)) | 753 if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile)) |
| 734 return true; | 754 return true; |
| 735 | 755 |
| 756 if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) |
| 757 return true; |
| 758 |
| 736 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) | 759 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) |
| 737 return false; | 760 return false; |
| 738 | 761 |
| 739 ExtensionService* extension_service = | 762 ExtensionService* extension_service = |
| 740 extensions::ExtensionSystem::Get(profile)->extension_service(); | 763 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 741 if (!extension_service) | 764 if (!extension_service) |
| 742 return false; | 765 return false; |
| 743 | 766 |
| 744 const Extension* extension = extension_service->extensions()-> | 767 const Extension* extension = extension_service->extensions()-> |
| 745 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); | 768 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // share any host. | 846 // share any host. |
| 824 if (!profile) | 847 if (!profile) |
| 825 return true; | 848 return true; |
| 826 | 849 |
| 827 InstantService* instant_service = | 850 InstantService* instant_service = |
| 828 InstantServiceFactory::GetForProfile(profile); | 851 InstantServiceFactory::GetForProfile(profile); |
| 829 if (instant_service && | 852 if (instant_service && |
| 830 instant_service->IsInstantProcess(process_host->GetID())) | 853 instant_service->IsInstantProcess(process_host->GetID())) |
| 831 return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile); | 854 return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile); |
| 832 | 855 |
| 856 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
| 857 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) |
| 858 return SigninManager::IsWebBasedSigninFlowURL(site_url); |
| 859 |
| 833 ExtensionService* service = | 860 ExtensionService* service = |
| 834 extensions::ExtensionSystem::Get(profile)->extension_service(); | 861 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 835 extensions::ProcessMap* process_map = service->process_map(); | 862 extensions::ProcessMap* process_map = service->process_map(); |
| 836 | 863 |
| 837 // Don't allow the Task Manager to share a process with anything else. | 864 // Don't allow the Task Manager to share a process with anything else. |
| 838 // Otherwise it can affect the renderers it is observing. | 865 // Otherwise it can affect the renderers it is observing. |
| 839 // Note: we could create another RenderProcessHostPrivilege bucket for | 866 // Note: we could create another RenderProcessHostPrivilege bucket for |
| 840 // this to allow multiple chrome://tasks instances to share, but that's | 867 // this to allow multiple chrome://tasks instances to share, but that's |
| 841 // a very unlikely case without serious consequences. | 868 // a very unlikely case without serious consequences. |
| 842 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) | 869 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 // Remember the ID of the Instant process to signal the renderer process | 946 // Remember the ID of the Instant process to signal the renderer process |
| 920 // on startup in |AppendExtraCommandLineSwitches| below. | 947 // on startup in |AppendExtraCommandLineSwitches| below. |
| 921 if (chrome::search::ShouldAssignURLToInstantRenderer( | 948 if (chrome::search::ShouldAssignURLToInstantRenderer( |
| 922 site_instance->GetSiteURL(), profile)) { | 949 site_instance->GetSiteURL(), profile)) { |
| 923 InstantService* instant_service = | 950 InstantService* instant_service = |
| 924 InstantServiceFactory::GetForProfile(profile); | 951 InstantServiceFactory::GetForProfile(profile); |
| 925 if (instant_service) | 952 if (instant_service) |
| 926 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); | 953 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
| 927 } | 954 } |
| 928 | 955 |
| 956 // We only expect there to be one signin process as we use process-per-site |
| 957 // for signin URLs. The signin process will be cleared from SigninManager |
| 958 // when the renderer is destroyed. |
| 959 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { |
| 960 SigninManager* signin_manager = |
| 961 SigninManagerFactory::GetForProfile(profile); |
| 962 if (signin_manager) |
| 963 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); |
| 964 } |
| 965 |
| 929 ExtensionService* service = | 966 ExtensionService* service = |
| 930 extensions::ExtensionSystem::Get(profile)->extension_service(); | 967 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 931 if (!service) | 968 if (!service) |
| 932 return; | 969 return; |
| 933 | 970 |
| 934 const Extension* extension = | 971 const Extension* extension = |
| 935 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( | 972 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( |
| 936 site_instance->GetSiteURL())); | 973 site_instance->GetSiteURL())); |
| 937 if (!extension) | 974 if (!extension) |
| 938 return; | 975 return; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 } | 1142 } |
| 1106 | 1143 |
| 1107 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled)) | 1144 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled)) |
| 1108 command_line->AppendSwitch(switches::kRendererPrintPreview); | 1145 command_line->AppendSwitch(switches::kRendererPrintPreview); |
| 1109 | 1146 |
| 1110 InstantService* instant_service = | 1147 InstantService* instant_service = |
| 1111 InstantServiceFactory::GetForProfile(profile); | 1148 InstantServiceFactory::GetForProfile(profile); |
| 1112 if (instant_service && | 1149 if (instant_service && |
| 1113 instant_service->IsInstantProcess(process->GetID())) | 1150 instant_service->IsInstantProcess(process->GetID())) |
| 1114 command_line->AppendSwitch(switches::kInstantProcess); | 1151 command_line->AppendSwitch(switches::kInstantProcess); |
| 1152 |
| 1153 SigninManager* signin_manager = |
| 1154 SigninManagerFactory::GetForProfile(profile); |
| 1155 if (signin_manager && signin_manager->IsSigninProcess(process->GetID())) |
| 1156 command_line->AppendSwitch(switches::kSigninProcess); |
| 1115 } | 1157 } |
| 1116 | 1158 |
| 1117 if (content::IsThreadedCompositingEnabled()) | 1159 if (content::IsThreadedCompositingEnabled()) |
| 1118 command_line->AppendSwitch(switches::kEnableThreadedCompositing); | 1160 command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
| 1119 | 1161 |
| 1120 // Please keep this in alphabetical order. | 1162 // Please keep this in alphabetical order. |
| 1121 static const char* const kSwitchNames[] = { | 1163 static const char* const kSwitchNames[] = { |
| 1122 switches::kAllowHTTPBackgroundPage, | 1164 switches::kAllowHTTPBackgroundPage, |
| 1123 switches::kAllowLegacyExtensionManifests, | 1165 switches::kAllowLegacyExtensionManifests, |
| 1124 switches::kAllowScriptingGallery, | 1166 switches::kAllowScriptingGallery, |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 io_thread_application_locale_ = locale; | 2138 io_thread_application_locale_ = locale; |
| 2097 } | 2139 } |
| 2098 | 2140 |
| 2099 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2141 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
| 2100 const std::string& locale) { | 2142 const std::string& locale) { |
| 2101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2102 io_thread_application_locale_ = locale; | 2144 io_thread_application_locale_ = locale; |
| 2103 } | 2145 } |
| 2104 | 2146 |
| 2105 } // namespace chrome | 2147 } // namespace chrome |
| OLD | NEW |