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

Unified Diff: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc

Issue 1344443002: Implement new password separated sign in flow for chrome desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 3 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/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..bebd3889b4027b72a0b102c2de57a42ebb6114d0 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,20 @@ 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 (switches::UseNewGaiaFlow()) {
+ DCHECK(!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 +611,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::UseNewGaiaFlow();
+ GURL url = is_new_gaia_flow
achuithb 2015/09/16 22:53:27 const
Roger Tawa OOO till Jul 10th 2015/09/24 05:54:18 Done.
+ ? GaiaUrls::GetInstance()->embedded_signin_url()
+ : GaiaUrls::GetInstance()->old_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 +681,17 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
DCHECK(!gaia_id_string16.empty());
std::string gaia_id = base::UTF16ToASCII(gaia_id_string16);
+ const bool is_new_gaia_flow = switches::UseNewGaiaFlow();
+
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_new_gaia_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_new_gaia_flow || !auth_code.empty());
bool choose_what_to_sync = false;
dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync);
@@ -664,7 +714,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 +725,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 +741,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 +752,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 +836,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);

Powered by Google App Engine
This is Rietveld 408576698