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

Unified Diff: chrome/browser/chromeos/login/signin/oauth2_login_manager.cc

Issue 1102863002: Revert of Fetch OAuth2 tokens prior to profile creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/chromeos/login/signin/oauth2_login_manager.cc
diff --git a/chrome/browser/chromeos/login/signin/oauth2_login_manager.cc b/chrome/browser/chromeos/login/signin/oauth2_login_manager.cc
index 9d2989afa14493ad17cc28d5a6efa6fccefa4900..61023ea0f62914fb8272be54232c9572b66f259e 100644
--- a/chrome/browser/chromeos/login/signin/oauth2_login_manager.cc
+++ b/chrome/browser/chromeos/login/signin/oauth2_login_manager.cc
@@ -74,19 +74,21 @@
net::URLRequestContextGetter* auth_request_context,
SessionRestoreStrategy restore_strategy,
const std::string& oauth2_refresh_token,
- const std::string& oauth2_access_token) {
+ const std::string& auth_code) {
DCHECK(user_profile_);
auth_request_context_ = auth_request_context;
restore_strategy_ = restore_strategy;
refresh_token_ = oauth2_refresh_token;
- oauthlogin_access_token_ = oauth2_access_token;
+ oauthlogin_access_token_ = std::string();
+ auth_code_ = auth_code;
session_restore_start_ = base::Time::Now();
SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_PREPARING);
ContinueSessionRestore();
}
void OAuth2LoginManager::ContinueSessionRestore() {
- if (restore_strategy_ == RESTORE_FROM_COOKIE_JAR) {
+ if (restore_strategy_ == RESTORE_FROM_COOKIE_JAR ||
+ restore_strategy_ == RESTORE_FROM_AUTH_CODE) {
FetchOAuth2Tokens();
return;
}
@@ -237,23 +239,28 @@
void OAuth2LoginManager::FetchOAuth2Tokens() {
DCHECK(auth_request_context_.get());
- if (restore_strategy_ != RESTORE_FROM_COOKIE_JAR) {
- NOTREACHED();
- SetSessionRestoreState(SESSION_RESTORE_FAILED);
- return;
- }
-
// If we have authenticated cookie jar, get OAuth1 token first, then fetch
// SID/LSID cookies through OAuthLogin call.
- SigninClient* signin_client =
- ChromeSigninClientFactory::GetForProfile(user_profile_);
- std::string signin_scoped_device_id =
- signin_client->GetSigninScopedDeviceId();
-
- oauth2_token_fetcher_.reset(
- new OAuth2TokenFetcher(this, auth_request_context_.get()));
- oauth2_token_fetcher_->StartExchangeFromCookies(std::string(),
- signin_scoped_device_id);
+ if (restore_strategy_ == RESTORE_FROM_COOKIE_JAR) {
+ SigninClient* signin_client =
+ ChromeSigninClientFactory::GetForProfile(user_profile_);
+ std::string signin_scoped_device_id =
+ signin_client->GetSigninScopedDeviceId();
+
+ oauth2_token_fetcher_.reset(
+ new OAuth2TokenFetcher(this, auth_request_context_.get()));
+ oauth2_token_fetcher_->StartExchangeFromCookies(std::string(),
+ signin_scoped_device_id);
+ } else if (restore_strategy_ == RESTORE_FROM_AUTH_CODE) {
+ DCHECK(!auth_code_.empty());
+ oauth2_token_fetcher_.reset(
+ new OAuth2TokenFetcher(this,
+ g_browser_process->system_request_context()));
+ oauth2_token_fetcher_->StartExchangeFromAuthCode(auth_code_);
+ } else {
+ NOTREACHED();
+ SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED);
+ }
}
void OAuth2LoginManager::OnOAuth2TokensAvailable(

Powered by Google App Engine
This is Rietveld 408576698