| Index: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| index 7d53c8db25f5695a05bffeba3d5433d6d9889551..2eb672aaf8d277c7dee9a1f2fc0659fc1af6a2c6 100644
|
| --- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| +++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| @@ -228,6 +228,7 @@ class InlineSigninHelper : public GaiaAuthConsumer {
|
| const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| + const std::string& auth_code,
|
| const std::string& signin_scoped_device_id,
|
| bool choose_what_to_sync,
|
| bool confirm_untrusted_signin);
|
| @@ -265,6 +266,7 @@ class InlineSigninHelper : public GaiaAuthConsumer {
|
| std::string gaia_id_;
|
| std::string password_;
|
| std::string session_index_;
|
| + std::string auth_code_;
|
| bool choose_what_to_sync_;
|
| bool confirm_untrusted_signin_;
|
|
|
| @@ -280,6 +282,7 @@ InlineSigninHelper::InlineSigninHelper(
|
| const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| + const std::string& auth_code,
|
| const std::string& signin_scoped_device_id,
|
| bool choose_what_to_sync,
|
| bool confirm_untrusted_signin)
|
| @@ -291,12 +294,19 @@ InlineSigninHelper::InlineSigninHelper(
|
| gaia_id_(gaia_id),
|
| password_(password),
|
| session_index_(session_index),
|
| + auth_code_(auth_code),
|
| choose_what_to_sync_(choose_what_to_sync),
|
| confirm_untrusted_signin_(confirm_untrusted_signin) {
|
| DCHECK(profile_);
|
| DCHECK(!email_.empty());
|
| - gaia_auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithDeviceId(
|
| - session_index, signin_scoped_device_id);
|
| + if (!auth_code_.empty()) {
|
| + gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId(
|
| + auth_code, signin_scoped_device_id);
|
| + } else {
|
| + DCHECK(!session_index_.empty());
|
| + gaia_auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithDeviceId(
|
| + session_index_, signin_scoped_device_id);
|
| + }
|
| }
|
|
|
| void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
|
| @@ -600,6 +610,38 @@ void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) {
|
| params.SetString("service", "chromiumsync");
|
|
|
| content::WebContents* contents = web_ui()->GetWebContents();
|
| + const GURL& current_url = contents->GetURL();
|
| + signin_metrics::Source source = signin::GetSourceForPromoURL(current_url);
|
| +
|
| + std::string is_constrained;
|
| + net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
|
| +
|
| + // Use new embedded flow if in constrained window.
|
| + if (is_constrained == "1") {
|
| + const bool is_new_gaia_flow = switches::UsePasswordSeparatedSigninFlow();
|
| + const GURL url = is_new_gaia_flow
|
| + ? GaiaUrls::GetInstance()->embedded_signin_url()
|
| + : GaiaUrls::GetInstance()->password_combined_embedded_signin_url();
|
| + params.SetBoolean("isNewGaiaFlow", is_new_gaia_flow);
|
| + params.SetString("clientId",
|
| + GaiaUrls::GetInstance()->oauth2_chrome_client_id());
|
| + params.SetString("gaiaPath", url.path().substr(1));
|
| +
|
| + std::string flow;
|
| + switch (source) {
|
| + case signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT:
|
| + flow = "addaccount";
|
| + break;
|
| + case signin_metrics::SOURCE_REAUTH:
|
| + flow = "reauth";
|
| + break;
|
| + default:
|
| + flow = "signin";
|
| + break;
|
| + }
|
| + params.SetString("flow", flow);
|
| + }
|
| +
|
| content::WebContentsObserver::Observe(contents);
|
| LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN);
|
| }
|
| @@ -638,10 +680,20 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
|
| DCHECK(!gaia_id_string16.empty());
|
| std::string gaia_id = base::UTF16ToASCII(gaia_id_string16);
|
|
|
| + std::string is_constrained;
|
| + net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
|
| + const bool is_password_separated_signin_flow = is_constrained == "1" &&
|
| + switches::UsePasswordSeparatedSigninFlow();
|
| +
|
| base::string16 session_index_string16;
|
| dict->GetString("sessionIndex", &session_index_string16);
|
| std::string session_index = base::UTF16ToASCII(session_index_string16);
|
| - DCHECK(!session_index.empty());
|
| + DCHECK(is_password_separated_signin_flow || !session_index.empty());
|
| +
|
| + base::string16 auth_code_string16;
|
| + dict->GetString("authCode", &auth_code_string16);
|
| + std::string auth_code = base::UTF16ToASCII(auth_code_string16);
|
| + DCHECK(!is_password_separated_signin_flow || !auth_code.empty());
|
|
|
| bool choose_what_to_sync = false;
|
| dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync);
|
| @@ -664,7 +716,7 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
|
| FinishCompleteLoginParams params(nullptr, partition, current_url, path,
|
| confirm_untrusted_signin_, email,
|
| gaia_id, password, session_index,
|
| - choose_what_to_sync);
|
| + auth_code, choose_what_to_sync);
|
| ProfileManager::CreateCallback callback = base::Bind(
|
| &InlineLoginHandlerImpl::FinishCompleteLogin, params);
|
| profiles::SwitchToProfile(path, chrome::GetActiveDesktop(), true,
|
| @@ -675,7 +727,7 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
|
| FinishCompleteLoginParams(this, partition, current_url,
|
| base::FilePath(), confirm_untrusted_signin_,
|
| email, gaia_id, password, session_index,
|
| - choose_what_to_sync),
|
| + auth_code, choose_what_to_sync),
|
| profile,
|
| Profile::CREATE_STATUS_CREATED);
|
| }
|
| @@ -691,6 +743,7 @@ InlineLoginHandlerImpl::FinishCompleteLoginParams::FinishCompleteLoginParams(
|
| const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| + const std::string& auth_code,
|
| bool choose_what_to_sync)
|
| : handler(handler),
|
| partition(partition),
|
| @@ -701,6 +754,7 @@ InlineLoginHandlerImpl::FinishCompleteLoginParams::FinishCompleteLoginParams(
|
| gaia_id(gaia_id),
|
| password(password),
|
| session_index(session_index),
|
| + auth_code(auth_code),
|
| choose_what_to_sync(choose_what_to_sync) {}
|
|
|
| InlineLoginHandlerImpl::
|
| @@ -784,7 +838,8 @@ void InlineLoginHandlerImpl::FinishCompleteLogin(
|
| params.partition->GetURLRequestContext(), profile,
|
| params.url,
|
| params.email, params.gaia_id, params.password,
|
| - params.session_index, signin_scoped_device_id,
|
| + params.session_index, params.auth_code,
|
| + signin_scoped_device_id,
|
| params.choose_what_to_sync,
|
| params.confirm_untrusted_signin);
|
|
|
|
|