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

Unified Diff: chrome/browser/chromeos/login/oauth2_token_fetcher.cc

Issue 12704002: Support for auth code based authentication flow for both app and web UI driven flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase4 Created 7 years, 9 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/oauth2_token_fetcher.cc
diff --git a/chrome/browser/chromeos/login/oauth2_token_fetcher.cc b/chrome/browser/chromeos/login/oauth2_token_fetcher.cc
index 7161eaacc4978a8d6efe66cdad3608cc338887a9..a83a5ed1ea7d8e5e6ed86e61af4743318cd837c0 100644
--- a/chrome/browser/chromeos/login/oauth2_token_fetcher.cc
+++ b/chrome/browser/chromeos/login/oauth2_token_fetcher.cc
@@ -42,7 +42,7 @@ OAuth2TokenFetcher::OAuth2TokenFetcher(
OAuth2TokenFetcher::~OAuth2TokenFetcher() {
}
-void OAuth2TokenFetcher::Start() {
+void OAuth2TokenFetcher::StartExchangeFromCookies() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Delay the verification if the network is not connected or on a captive
@@ -53,13 +53,35 @@ void OAuth2TokenFetcher::Start() {
VLOG(1) << "Network is offline. Deferring OAuth2 token fetch.";
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&OAuth2TokenFetcher::Start, AsWeakPtr()),
+ base::Bind(&OAuth2TokenFetcher::StartExchangeFromCookies,
+ AsWeakPtr()),
base::TimeDelta::FromMilliseconds(kRequestRestartDelay));
return;
}
auth_fetcher_.StartCookieForOAuthLoginTokenExchange(EmptyString());
}
+void OAuth2TokenFetcher::StartExchangeFromAuthCode(
+ const std::string& auth_code) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ auth_code_ = auth_code;
+ // Delay the verification if the network is not connected or on a captive
+ // portal.
+ ConnectivityStateHelper* csh = ConnectivityStateHelper::Get();
+ if (!csh->DefaultNetworkOnline()) {
+ // If network is offline, defer the token fetching until online.
+ VLOG(1) << "Network is offline. Deferring OAuth2 token fetch.";
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&OAuth2TokenFetcher::StartExchangeFromAuthCode,
+ AsWeakPtr(),
+ auth_code),
+ base::TimeDelta::FromMilliseconds(kRequestRestartDelay));
+ return;
+ }
+ auth_fetcher_.StartAuthCodeForOAuth2TokenExchange(auth_code);
+}
+
void OAuth2TokenFetcher::OnClientOAuthSuccess(
const GaiaAuthConsumer::ClientOAuthResult& oauth_tokens) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -72,10 +94,15 @@ void OAuth2TokenFetcher::OnClientOAuthSuccess(
void OAuth2TokenFetcher::OnClientOAuthFailure(
const GoogleServiceAuthError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- RetryOnError(error,
- base::Bind(&OAuth2TokenFetcher::Start, AsWeakPtr()),
- base::Bind(&Delegate::OnOAuth2TokensFetchFailed,
- base::Unretained(delegate_)));
+ RetryOnError(
+ error,
+ auth_code_.empty() ?
+ base::Bind(&OAuth2TokenFetcher::StartExchangeFromCookies,
+ AsWeakPtr()) :
+ base::Bind(&OAuth2TokenFetcher::StartExchangeFromAuthCode,
+ AsWeakPtr(), auth_code_),
+ base::Bind(&Delegate::OnOAuth2TokensFetchFailed,
+ base::Unretained(delegate_)));
}
void OAuth2TokenFetcher::RetryOnError(const GoogleServiceAuthError& error,
« no previous file with comments | « chrome/browser/chromeos/login/oauth2_token_fetcher.h ('k') | chrome/browser/chromeos/login/oauth_login_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698