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

Unified 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: add policy test Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 9677f919fc9dce37e08db35a626aebaf185f6ed4..3e025bc9a52cf9541b3af42c3b42cbdff197da46 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -64,6 +64,8 @@
#include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
#include "chrome/browser/ssl/ssl_add_certificate.h"
@@ -75,6 +77,7 @@
#include "chrome/browser/ui/search/search.h"
#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/browser/user_style_sheet_watcher.h"
#include "chrome/browser/user_style_sheet_watcher_factory.h"
#include "chrome/browser/view_type_utils.h"
@@ -438,6 +441,21 @@ GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
return effective_url;
}
+GURL GetEffectiveURLForSignin(const GURL& url) {
+ CHECK(SyncPromoUI::IsWebBasedSigninFlowURL(url));
+ if (url.SchemeIs(chrome::kChromeSigninScheme))
+ return url;
+
+ GURL effective_url(url);
+ // Replace the scheme with "chrome-signin:".
+ url_canon::Replacements<char> replacements;
+ std::string signin_scheme(chrome::kChromeSigninScheme);
+ replacements.SetScheme(signin_scheme.data(),
+ url_parse::Component(0, signin_scheme.length()));
+ effective_url = effective_url.ReplaceComponents(replacements);
+ return effective_url;
+}
+
} // namespace
namespace chrome {
@@ -695,6 +713,13 @@ GURL ChromeContentBrowserClient::GetEffectiveURL(
if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile))
return GetEffectiveURLForInstant(url, profile);
+ // If the input |url| should be assigned to the Signin renderer, make its
+ // effective URL distinct from other URLs on the signin service's domain.
+ // Note that the signin renderer will be allowed to sign the user in to
+ // Chrome.
+ if (SyncPromoUI::IsWebBasedSigninFlowURL(url))
+ return GetEffectiveURLForSignin(url);
+
// If the input |url| is part of an installed app, the effective URL is an
// extension URL with the ID of that extension as the host. This has the
// effect of grouping apps together in a common SiteInstance.
@@ -732,6 +757,9 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile))
return true;
+ if (SyncPromoUI::IsWebBasedSigninFlowURL(effective_url))
+ return true;
+
if (!effective_url.SchemeIs(extensions::kExtensionScheme))
return false;
@@ -829,6 +857,10 @@ bool ChromeContentBrowserClient::IsSuitableHost(
instant_service->IsInstantProcess(process_host->GetID()))
return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile);
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
+ if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID()))
+ return SyncPromoUI::IsWebBasedSigninFlowURL(site_url);
+
ExtensionService* service =
extensions::ExtensionSystem::Get(profile)->extension_service();
extensions::ProcessMap* process_map = service->process_map();
@@ -925,6 +957,16 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess(
instant_service->AddInstantProcess(site_instance->GetProcess()->GetID());
}
+ // We only expect there to be one signin process as we use process-per-site
+ // for signin URLs. The signin process will be cleared from SigninManager
+ // when the renderer is destroyed.
+ if (SyncPromoUI::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
+ SigninManager* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ if (signin_manager)
+ signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
+ }
+
ExtensionService* service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!service)
@@ -1111,6 +1153,11 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
if (instant_service &&
instant_service->IsInstantProcess(process->GetID()))
command_line->AppendSwitch(switches::kInstantProcess);
+
+ SigninManager* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ if (signin_manager && signin_manager->IsSigninProcess(process->GetID()))
+ command_line->AppendSwitch(switches::kSigninProcess);
}
if (content::IsThreadedCompositingEnabled())
« no previous file with comments | « no previous file | chrome/browser/signin/signin_browsertest.cc » ('j') | chrome/browser/signin/signin_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698