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

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

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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.h
diff --git a/chrome/browser/chromeos/login/oauth2_token_fetcher.h b/chrome/browser/chromeos/login/oauth2_token_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..db7799aef009fea03260a729ce0f4ad24eea250a
--- /dev/null
+++ b/chrome/browser/chromeos/login/oauth2_token_fetcher.h
@@ -0,0 +1,75 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
+#include "google_apis/gaia/gaia_auth_consumer.h"
+#include "google_apis/gaia/gaia_auth_fetcher.h"
+
+class Profile;
+
+namespace chromeos {
+
+// OAuth2TokenFetcher is used to convert authenticated cookie jar from the
+// authentication profile into OAuth2 tokens and GAIA credentials that will be
+// used to kick off other token retrieval tasks (i.e. TokenService).
+class OAuth2TokenFetcher : public base::SupportsWeakPtr<OAuth2TokenFetcher>,
+ public GaiaAuthConsumer {
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ virtual void OnOAuth2TokenAvailable(
+ const GaiaAuthConsumer::ClientLoginResult& gaia_credentials,
+ const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) = 0;
+ virtual void OnOAuth2TokenFetchFailed() = 0;
+ };
+
+ OAuth2TokenFetcher(OAuth2TokenFetcher::Delegate* delegate,
+ Profile* auth_profile);
+ virtual ~OAuth2TokenFetcher();
+
+ void Start();
+
+ private:
+ // Starts OAuthLogin call.
+ void StartOAuthLogin();
+ // Decides how to proceed on GAIA |error|. If the error looks temporary,
+ // retries |task| until max retry count is reached.
+ // If retry count runs out, or error condition is unrecoverable, it calls
+ // Delegate::OnOAuth2TokenFetchFailed().
+ void RetryOnError(const GoogleServiceAuthError& error,
+ const base::Closure& task);
+
+ // GaiaAuthConsumer overrides.
+ virtual void OnClientOAuthSuccess(
+ const GaiaAuthConsumer::ClientOAuthResult& result) OVERRIDE;
+ virtual void OnClientOAuthFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+ virtual void OnClientLoginSuccess(
+ const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE;
+ virtual void OnClientLoginFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+
+ OAuth2TokenFetcher::Delegate* delegate_;
+ Profile* auth_profile_;
+ GaiaAuthConsumer::ClientOAuthResult oauth_tokens_;
+ GaiaAuthFetcher auth_fetcher_;
+
+ // The retry counter. Increment this only when failure happened.
+ int retry_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(OAuth2TokenFetcher);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698