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

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

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

Powered by Google App Engine
This is Rietveld 408576698