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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h"
14 #include "google_apis/gaia/gaia_auth_consumer.h"
15 #include "google_apis/gaia/gaia_auth_fetcher.h"
16 #include "google_apis/gaia/oauth2_access_token_consumer.h"
17 #include "google_apis/gaia/oauth2_access_token_fetcher.h"
18
19 namespace net {
20 class URLRequestContextGetter;
21 }
22
23 namespace chromeos {
24
25 // Given the OAuth2 refresh token, this class will try to exchange it for GAIA
26 // credentials (SID+LSID) and populate current session's cookie jar.
27 class OAuth2LoginVerifier : public base::SupportsWeakPtr<OAuth2LoginVerifier>,
28 public GaiaAuthConsumer,
29 public OAuth2AccessTokenConsumer {
30 public:
31 class Delegate {
32 public:
33 virtual ~Delegate() {}
34 virtual void OnOAuth2LoginVerifierSuccess(const std::string& sid,
35 const std::string& lsid,
36 const std::string& auth) = 0;
37 virtual void OnOAuth2LoginVerifierFailure() = 0;
38 };
39
40 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate,
41 net::URLRequestContextGetter* system_request_context,
42 net::URLRequestContextGetter* user_request_context);
43 virtual ~OAuth2LoginVerifier();
44
45 // Starts OAuth2 token for GAIA credentials exchange.
46 void VerifyRefreshToken(const std::string& refresh_token);
47
48 private:
49 // GaiaAuthConsumer overrides.
50 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
51 virtual void OnClientLoginFailure(
52 const GoogleServiceAuthError& error) OVERRIDE;
53 virtual void OnIssueAuthTokenSuccess(const std::string& service,
54 const std::string& auth_token) OVERRIDE;
55 virtual void OnIssueAuthTokenFailure(
56 const std::string& service, const GoogleServiceAuthError& error) OVERRIDE;
57 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE;
58 virtual void OnMergeSessionFailure(
59 const GoogleServiceAuthError& error) OVERRIDE;
60
61 // OAuth2AccessTokenConsumer overrides.
62 virtual void OnGetTokenSuccess(const std::string& access_token,
63 const base::Time& expiration_time) OVERRIDE;
64 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
65
66 // Starts OAuthLogin request.
67 void StartOAuthLogin();
68
69 // Starts sequence of calls (IssueAuthToken, MergeSession) for exchanging
70 // OAuth2 access token for GAIA cookies.
71 void StartCookiesRetrieval();
72
73 // Decides how to proceed on GAIA |error|. If the error looks temporary,
74 // retries |task| after certain delay until max retry count is reached.
75 void RetryOnError(const char* operation_id,
76 const GoogleServiceAuthError& error,
77 const base::Closure& task);
78
79 OAuth2LoginVerifier::Delegate* delegate_;
80 OAuth2AccessTokenFetcher token_fetcher_;
81 GaiaAuthFetcher gaia_fetcher_;
82 std::string access_token_;
83 std::string refresh_token_;
84 std::string sid_;
85 std::string lsid_;
86 std::string token_;
87 // The retry counter. Increment this only when failure happened.
88 int retry_count_;
89
90 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier);
91 };
92
93 } // namespace chromeos
94
95 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698