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

Unified Diff: chrome/browser/chromeos/login/oauth2_login_verifier.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_login_verifier.h
diff --git a/chrome/browser/chromeos/login/oauth2_login_verifier.h b/chrome/browser/chromeos/login/oauth2_login_verifier.h
new file mode 100644
index 0000000000000000000000000000000000000000..619a0e208ffb608d137c9e6f7402cab626db0f98
--- /dev/null
+++ b/chrome/browser/chromeos/login/oauth2_login_verifier.h
@@ -0,0 +1,93 @@
+// 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_LOGIN_VERIFIER_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_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"
+#include "google_apis/gaia/oauth2_access_token_consumer.h"
+#include "google_apis/gaia/oauth2_access_token_fetcher.h"
+
+class Profile;
+
+namespace chromeos {
+
+// Given the OAuth2 refresh token, this class will try to exchange it for GAIA
+// credentials (SID+LSID) and populate current session's cookie jar.
+class OAuth2LoginVerifier : public base::SupportsWeakPtr<OAuth2LoginVerifier>,
+ public GaiaAuthConsumer,
+ public OAuth2AccessTokenConsumer {
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ virtual void OnOAuth2LoginVerifierSuccess(const std::string& sid,
+ const std::string& lsid,
+ const std::string& auth) = 0;
+ virtual void OnOAuth2LoginVerifierFaulure() = 0;
+ };
+
+ OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate,
+ net::URLRequestContextGetter* system_request_context,
+ Profile* user_profile);
+ virtual ~OAuth2LoginVerifier();
+
+ // Starts OAuth2 token for GAIA credentials exchange.
+ void VerifyRefreshToken(const std::string& refresh_token);
+
+ private:
+ // GaiaAuthConsumer overrides.
+ virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
+ virtual void OnClientLoginFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+ virtual void OnIssueAuthTokenSuccess(const std::string& service,
+ const std::string& auth_token) OVERRIDE;
+ virtual void OnIssueAuthTokenFailure(
+ const std::string& service, const GoogleServiceAuthError& error) OVERRIDE;
+ virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE;
+ virtual void OnMergeSessionFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+
+ // OAuth2AccessTokenConsumer overrides.
+ virtual void OnGetTokenSuccess(const std::string& access_token,
+ const base::Time& expiration_time) OVERRIDE;
+ virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
+
+ // Starts OAuthLogin request.
+ void StartOAuthLogin();
+
+ // Starts sequence of calls (IssueAuthToken, MergeSession) for exchanging
+ // OAuth2 access token for GAIA cookies.
+ void StartCookiesRetrieval();
+
+ // Decides how to proceed on GAIA |error|. If the error looks temporary,
+ // retries |task| after certain delay until max retry count is reached.
+ void RetryOnError(const char* operation_id,
+ const GoogleServiceAuthError& error,
+ const base::Closure& task);
+
+ OAuth2LoginVerifier::Delegate* delegate_;
+ OAuth2AccessTokenFetcher token_fetcher_;
+ GaiaAuthFetcher gaia_fetcher_;
+ std::string access_token_;
+ std::string refresh_token_;
+ std::string sid_;
+ std::string lsid_;
+ std::string token_;
+ // The retry counter. Increment this only when failure happened.
+ int retry_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_

Powered by Google App Engine
This is Rietveld 408576698