Commit cc55e295 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

[signin] Use the new Chrome sync endpoint when signing in to Chrome with DICE.

This CL uses the /signin/chrome/sync Gaia endpoint when signing in to
Chrome when DICE is enabled.

Bug: 789578
Change-Id: Ide40f5b7cc1d3f34f07a482f369d6826c1e2ca29
Reviewed-on: https://chromium-review.googlesource.com/800619
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520599}
parent 0c815cfa
...@@ -19,9 +19,6 @@ DiceTabHelper::DiceTabHelper(content::WebContents* web_contents) ...@@ -19,9 +19,6 @@ DiceTabHelper::DiceTabHelper(content::WebContents* web_contents)
signin_access_point_(signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN), signin_access_point_(signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN),
signin_reason_(signin_metrics::Reason::REASON_UNKNOWN_REASON), signin_reason_(signin_metrics::Reason::REASON_UNKNOWN_REASON),
should_start_sync_after_web_signin_(true) { should_start_sync_after_web_signin_(true) {
DCHECK_EQ(signin_util::GetGaiaAddAccountUrlForDice(
chrome::FindBrowserWithWebContents(web_contents)->profile()),
web_contents->GetVisibleURL());
} }
DiceTabHelper::~DiceTabHelper() {} DiceTabHelper::~DiceTabHelper() {}
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/google/google_brand.h" #include "chrome/browser/google/google_brand.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -272,6 +274,24 @@ GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point, ...@@ -272,6 +274,24 @@ GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point,
true /* is_constrained */); true /* is_constrained */);
} }
GURL GetSigninURLForDice(Profile* profile, const std::string& email) {
GURL url;
if (signin::GetAccountConsistencyMethod() ==
signin::AccountConsistencyMethod::kDicePrepareMigration) {
// Add account does not support an email hint, so the email will not be
// autofilled when the Dice prepare migration is enabled.
url = GaiaUrls::GetInstance()->add_account_url();
} else {
url = GaiaUrls::GetInstance()->signin_chrome_sync_dice();
if (!email.empty())
url = net::AppendQueryParameter(url, "email_hint", email);
}
// Pass www.gooogle.com as the continue URL as otherwise Gaia navigates to
// myaccount which may be very confusing for the user.
return net::AppendQueryParameter(
url, "continue", UIThreadSearchTermsData(profile).GoogleBaseURLValue());
}
GURL GetSigninPartitionURL() { GURL GetSigninPartitionURL() {
return GURL("chrome-guest://chrome-signin/?"); return GURL("chrome-guest://chrome-signin/?");
} }
......
...@@ -82,6 +82,11 @@ GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point, ...@@ -82,6 +82,11 @@ GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point,
signin_metrics::Reason reason, signin_metrics::Reason reason,
const std::string& email); const std::string& email);
// Returns the URL to be used to add an account when DICE is enabled.
// If email is not empty, then it will pass email as hint to the page so that it
// will be autofilled by Gaia.
GURL GetSigninURLForDice(Profile* profile, const std::string& email);
// Gets the partition URL for the embedded sign in frame/webview. // Gets the partition URL for the embedded sign in frame/webview.
GURL GetSigninPartitionURL(); GURL GetSigninPartitionURL();
......
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h"
namespace signin_util { namespace signin_util {
namespace { namespace {
...@@ -45,12 +42,4 @@ void ResetForceSigninForTesting() { ...@@ -45,12 +42,4 @@ void ResetForceSigninForTesting() {
g_is_force_signin_enabled_cache = NOT_CACHED; g_is_force_signin_enabled_cache = NOT_CACHED;
} }
GURL GetGaiaAddAccountUrlForDice(Profile* profile) {
// Pass www.gooogle.com as the continue URL as otherwise Gaia navigates to
// myaccount which may be very confusing for the user.
return net::AppendQueryParameter(
GaiaUrls::GetInstance()->add_account_url(), "continue",
UIThreadSearchTermsData(profile).GoogleBaseURLValue());
}
} // namespace signin_util } // namespace signin_util
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_ #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_ #define CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_
#include "url/gurl.h"
class Profile;
namespace signin_util { namespace signin_util {
// Return whether the force sign in policy is enabled or not. // Return whether the force sign in policy is enabled or not.
...@@ -21,9 +17,6 @@ void SetForceSigninForTesting(bool enable); ...@@ -21,9 +17,6 @@ void SetForceSigninForTesting(bool enable);
// Reset force sign in to uninitialized state for testing. // Reset force sign in to uninitialized state for testing.
void ResetForceSigninForTesting(); void ResetForceSigninForTesting();
// Returns the URL to be used to add an account when DICE is enabled.
GURL GetGaiaAddAccountUrlForDice(Profile* profile);
} // namespace signin_util } // namespace signin_util
#endif // CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_ #endif // CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/dice_tab_helper.h" #include "chrome/browser/signin/dice_tab_helper.h"
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/signin/core/browser/profile_management_switches.h" #include "components/signin/core/browser/profile_management_switches.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/gaia_urls.h"
namespace { namespace {
...@@ -56,7 +58,14 @@ void SigninViewController::ShowSignin( ...@@ -56,7 +58,14 @@ void SigninViewController::ShowSignin(
signin_metrics::AccessPoint access_point) { signin_metrics::AccessPoint access_point) {
DCHECK(ShouldShowSigninForMode(mode)); DCHECK(ShouldShowSigninForMode(mode));
if (signin::IsDicePrepareMigrationEnabled()) { if (signin::IsDicePrepareMigrationEnabled()) {
ShowDiceSigninTab(mode, browser, access_point); std::string email;
if (GetSigninReasonFromMode(mode) ==
signin_metrics::Reason::REASON_REAUTHENTICATION) {
SigninManagerBase* manager =
SigninManagerFactory::GetForProfile(browser->profile());
email = manager->GetAuthenticatedAccountInfo().email;
}
ShowDiceSigninTab(mode, browser, access_point, email);
} else { } else {
ShowModalSigninDialog(mode, browser, access_point); ShowModalSigninDialog(mode, browser, access_point);
} }
...@@ -126,23 +135,23 @@ void SigninViewController::ResetModalSigninDelegate() { ...@@ -126,23 +135,23 @@ void SigninViewController::ResetModalSigninDelegate() {
void SigninViewController::ShowDiceSigninTab( void SigninViewController::ShowDiceSigninTab(
profiles::BubbleViewMode mode, profiles::BubbleViewMode mode,
Browser* browser, Browser* browser,
signin_metrics::AccessPoint access_point) { signin_metrics::AccessPoint access_point,
const std::string& email) {
signin_metrics::Reason signin_reason = GetSigninReasonFromMode(mode); signin_metrics::Reason signin_reason = GetSigninReasonFromMode(mode);
GURL add_account_url = GURL signin_url = signin::GetSigninURLForDice(browser->profile(), email);
signin_util::GetGaiaAddAccountUrlForDice(browser->profile());
content::WebContents* active_contents = nullptr; content::WebContents* active_contents = nullptr;
if (access_point == signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE) { if (access_point == signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE) {
active_contents = browser->tab_strip_model()->GetActiveWebContents(); active_contents = browser->tab_strip_model()->GetActiveWebContents();
content::OpenURLParams params(add_account_url, content::Referrer(), content::OpenURLParams params(signin_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB, WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false); ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false);
active_contents->OpenURL(params); active_contents->OpenURL(params);
} else { } else {
chrome::ShowSingletonTab(browser, add_account_url); chrome::ShowSingletonTab(browser, signin_url);
active_contents = browser->tab_strip_model()->GetActiveWebContents(); active_contents = browser->tab_strip_model()->GetActiveWebContents();
} }
DCHECK(active_contents); DCHECK(active_contents);
DCHECK_EQ(add_account_url, active_contents->GetVisibleURL()); DCHECK_EQ(signin_url, active_contents->GetVisibleURL());
DiceTabHelper::CreateForWebContents(active_contents); DiceTabHelper::CreateForWebContents(active_contents);
DiceTabHelper* tab_helper = DiceTabHelper::FromWebContents(active_contents); DiceTabHelper* tab_helper = DiceTabHelper::FromWebContents(active_contents);
tab_helper->SetSigninAccessPoint(access_point); tab_helper->SetSigninAccessPoint(access_point);
......
...@@ -41,6 +41,13 @@ class SigninViewController { ...@@ -41,6 +41,13 @@ class SigninViewController {
Browser* browser, Browser* browser,
signin_metrics::AccessPoint access_point); signin_metrics::AccessPoint access_point);
// Shows the DICE-specific sign-in flow: opens a Gaia sign-in webpage in a new
// tab attached to |browser|.
void ShowDiceSigninTab(profiles::BubbleViewMode mode,
Browser* browser,
signin_metrics::AccessPoint access_point,
const std::string& email);
// Shows the modal sync confirmation dialog as a browser-modal dialog on top // Shows the modal sync confirmation dialog as a browser-modal dialog on top
// of the |browser|'s window. // of the |browser|'s window.
void ShowModalSyncConfirmationDialog(Browser* browser); void ShowModalSyncConfirmationDialog(Browser* browser);
...@@ -78,12 +85,6 @@ class SigninViewController { ...@@ -78,12 +85,6 @@ class SigninViewController {
Browser* browser, Browser* browser,
signin_metrics::AccessPoint access_point); signin_metrics::AccessPoint access_point);
// Shows the DICE-specific sign-in flow: opens a Gaia sign-in webpage in a new
// tab attached to |browser|.
void ShowDiceSigninTab(profiles::BubbleViewMode mode,
Browser* browser,
signin_metrics::AccessPoint access_point);
// Returns the web contents of the modal dialog. // Returns the web contents of the modal dialog.
content::WebContents* GetModalDialogWebContentsForTesting(); content::WebContents* GetModalDialogWebContentsForTesting();
......
...@@ -316,20 +316,18 @@ void OneClickSigninSyncStarter::CompleteInitForNewProfile( ...@@ -316,20 +316,18 @@ void OneClickSigninSyncStarter::CompleteInitForNewProfile(
case Profile::CREATE_STATUS_CREATED: { case Profile::CREATE_STATUS_CREATED: {
break; break;
} }
case Profile::CREATE_STATUS_INITIALIZED: { case Profile::CREATE_STATUS_INITIALIZED:
if (signin::IsDicePrepareMigrationEnabled()) { if (signin::IsDicePrepareMigrationEnabled()) {
// When DICE is enabled, the refresh token is not copied to the new // When DICE is enabled, the refresh token is not copied to the new
// profile and the user needs to sign in to the new profile in order // profile and the user needs to sign in to the new profile in order
// to enable sync. // to enable sync.
CancelSigninAndDelete(); CancelSigninAndStartNewSigninInNewProfile(new_profile);
ShowSigninInNewProfile(new_profile);
} else { } else {
// Pre-DICE, the refresh token is copied to the new profile and the user // Pre-DICE, the refresh token is copied to the new profile and the user
// does not need to autehnticate in the new profile. // does not need to autehnticate in the new profile.
CopyCredentialsToNewProfileAndFinishSignin(new_profile); CopyCredentialsToNewProfileAndFinishSignin(new_profile);
} }
break; break;
}
case Profile::CREATE_STATUS_REMOTE_FAIL: case Profile::CREATE_STATUS_REMOTE_FAIL:
case Profile::CREATE_STATUS_CANCELED: case Profile::CREATE_STATUS_CANCELED:
case Profile::MAX_CREATE_STATUS: { case Profile::MAX_CREATE_STATUS: {
...@@ -340,14 +338,19 @@ void OneClickSigninSyncStarter::CompleteInitForNewProfile( ...@@ -340,14 +338,19 @@ void OneClickSigninSyncStarter::CompleteInitForNewProfile(
} }
} }
void OneClickSigninSyncStarter::ShowSigninInNewProfile(Profile* new_profile) { void OneClickSigninSyncStarter::CancelSigninAndStartNewSigninInNewProfile(
Profile* new_profile) {
SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_);
std::string email = signin_manager->GetUsernameForAuthInProgress();
CancelSigninAndDelete();
profiles::FindOrCreateNewWindowForProfile( profiles::FindOrCreateNewWindowForProfile(
new_profile, chrome::startup::IS_PROCESS_STARTUP, new_profile, chrome::startup::IS_PROCESS_STARTUP,
chrome::startup::IS_FIRST_RUN, false); chrome::startup::IS_FIRST_RUN, false);
Browser* browser = chrome::FindTabbedBrowser(new_profile, false); Browser* browser = chrome::FindTabbedBrowser(new_profile, false);
browser->signin_view_controller()->ShowSignin( browser->signin_view_controller()->ShowDiceSigninTab(
profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, browser, profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser,
signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE); signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE, email);
} }
void OneClickSigninSyncStarter::CopyCredentialsToNewProfileAndFinishSignin( void OneClickSigninSyncStarter::CopyCredentialsToNewProfileAndFinishSignin(
......
...@@ -169,7 +169,7 @@ class OneClickSigninSyncStarter : public SigninTracker::Observer, ...@@ -169,7 +169,7 @@ class OneClickSigninSyncStarter : public SigninTracker::Observer,
void CreateNewSignedInProfile(); void CreateNewSignedInProfile();
// Opens a browser window for new profile showing the sign-in page. // Opens a browser window for new profile showing the sign-in page.
void ShowSigninInNewProfile(Profile* new_profile); void CancelSigninAndStartNewSigninInNewProfile(Profile* new_profile);
// Copies the sign-in credentials to |new_profile| and starts syncing in // Copies the sign-in credentials to |new_profile| and starts syncing in
// |new_profile|. // |new_profile|.
......
...@@ -22,6 +22,7 @@ const char kClientLoginUrlSuffix[] = "ClientLogin"; ...@@ -22,6 +22,7 @@ const char kClientLoginUrlSuffix[] = "ClientLogin";
const char kServiceLoginUrlSuffix[] = "ServiceLogin"; const char kServiceLoginUrlSuffix[] = "ServiceLogin";
const char kEmbeddedSetupChromeOsUrlSuffixV1[] = "embedded/setup/chromeos"; const char kEmbeddedSetupChromeOsUrlSuffixV1[] = "embedded/setup/chromeos";
const char kEmbeddedSetupChromeOsUrlSuffixV2[] = "embedded/setup/v2/chromeos"; const char kEmbeddedSetupChromeOsUrlSuffixV2[] = "embedded/setup/v2/chromeos";
const char kSigninChromeSyncDice[] = "signin/chrome/sync";
const char kServiceLoginAuthUrlSuffix[] = "ServiceLoginAuth"; const char kServiceLoginAuthUrlSuffix[] = "ServiceLoginAuth";
const char kServiceLogoutUrlSuffix[] = "Logout"; const char kServiceLogoutUrlSuffix[] = "Logout";
const char kIssueAuthTokenUrlSuffix[] = "IssueAuthToken"; const char kIssueAuthTokenUrlSuffix[] = "IssueAuthToken";
...@@ -102,6 +103,7 @@ GaiaUrls::GaiaUrls() { ...@@ -102,6 +103,7 @@ GaiaUrls::GaiaUrls() {
gaia_url_.Resolve(kEmbeddedSetupChromeOsUrlSuffixV1); gaia_url_.Resolve(kEmbeddedSetupChromeOsUrlSuffixV1);
embedded_setup_chromeos_url_v2_ = embedded_setup_chromeos_url_v2_ =
gaia_url_.Resolve(kEmbeddedSetupChromeOsUrlSuffixV2); gaia_url_.Resolve(kEmbeddedSetupChromeOsUrlSuffixV2);
signin_chrome_sync_dice_ = gaia_url_.Resolve(kSigninChromeSyncDice);
service_login_auth_url_ = gaia_url_.Resolve(kServiceLoginAuthUrlSuffix); service_login_auth_url_ = gaia_url_.Resolve(kServiceLoginAuthUrlSuffix);
service_logout_url_ = gaia_url_.Resolve(kServiceLogoutUrlSuffix); service_logout_url_ = gaia_url_.Resolve(kServiceLogoutUrlSuffix);
issue_auth_token_url_ = gaia_url_.Resolve(kIssueAuthTokenUrlSuffix); issue_auth_token_url_ = gaia_url_.Resolve(kIssueAuthTokenUrlSuffix);
...@@ -170,6 +172,9 @@ const GURL& GaiaUrls::embedded_setup_chromeos_url(unsigned version) const { ...@@ -170,6 +172,9 @@ const GURL& GaiaUrls::embedded_setup_chromeos_url(unsigned version) const {
return embedded_setup_chromeos_url_v1_; return embedded_setup_chromeos_url_v1_;
} }
const GURL& GaiaUrls::signin_chrome_sync_dice() const {
return signin_chrome_sync_dice_;
}
const GURL& GaiaUrls::service_login_auth_url() const { const GURL& GaiaUrls::service_login_auth_url() const {
return service_login_auth_url_; return service_login_auth_url_;
......
...@@ -23,6 +23,7 @@ class GaiaUrls { ...@@ -23,6 +23,7 @@ class GaiaUrls {
const GURL& client_login_url() const; const GURL& client_login_url() const;
const GURL& service_login_url() const; const GURL& service_login_url() const;
const GURL& embedded_setup_chromeos_url(unsigned version) const; const GURL& embedded_setup_chromeos_url(unsigned version) const;
const GURL& signin_chrome_sync_dice() const;
const GURL& service_login_auth_url() const; const GURL& service_login_auth_url() const;
const GURL& service_logout_url() const; const GURL& service_logout_url() const;
const GURL& issue_auth_token_url() const; const GURL& issue_auth_token_url() const;
...@@ -73,6 +74,7 @@ class GaiaUrls { ...@@ -73,6 +74,7 @@ class GaiaUrls {
GURL service_login_url_; GURL service_login_url_;
GURL embedded_setup_chromeos_url_v1_; GURL embedded_setup_chromeos_url_v1_;
GURL embedded_setup_chromeos_url_v2_; GURL embedded_setup_chromeos_url_v2_;
GURL signin_chrome_sync_dice_;
GURL service_login_auth_url_; GURL service_login_auth_url_;
GURL service_logout_url_; GURL service_logout_url_;
GURL issue_auth_token_url_; GURL issue_auth_token_url_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment