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

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 class Profile;
20
21 namespace chromeos {
22
23 // Given the OAuth2 refresh token, this class will try to exchange it for GAIA
24 // credentials (SID+LSID) and populate current session's cookie jar.
25 class OAuth2LoginVerifier : public base::SupportsWeakPtr<OAuth2LoginVerifier>,
26 public GaiaAuthConsumer,
27 public OAuth2AccessTokenConsumer {
28 public:
29 class Delegate {
30 public:
31 virtual ~Delegate() {}
32 virtual void OnOAuth2LoginVerifierSuccess(const std::string& sid,
33 const std::string& lsid,
34 const std::string& auth) = 0;
35 virtual void OnOAuth2LoginVerifierFaulure() = 0;
36 };
37
38 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate,
39 net::URLRequestContextGetter* system_request_context,
40 Profile* user_profile);
41 virtual ~OAuth2LoginVerifier();
42
43 // Starts OAuth2 token for GAIA credentials exchange.
44 void VerifyRefreshToken(const std::string& refresh_token);
45
46 private:
47 // GaiaAuthConsumer overrides.
48 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
49 virtual void OnClientLoginFailure(
50 const GoogleServiceAuthError& error) OVERRIDE;
51 virtual void OnIssueAuthTokenSuccess(const std::string& service,
52 const std::string& auth_token) OVERRIDE;
53 virtual void OnIssueAuthTokenFailure(
54 const std::string& service, const GoogleServiceAuthError& error) OVERRIDE;
55 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE;
56 virtual void OnMergeSessionFailure(
57 const GoogleServiceAuthError& error) OVERRIDE;
58
59 // OAuth2AccessTokenConsumer overrides.
60 virtual void OnGetTokenSuccess(const std::string& access_token,
61 const base::Time& expiration_time) OVERRIDE;
62 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
63
64 // Starts OAuthLogin request.
65 void StartOAuthLogin();
66
67 // Starts sequence of calls (IssueAuthToken, MergeSession) for exchanging
68 // OAuth2 access token for GAIA cookies.
69 void StartCookiesRetrieval();
70
71 // Decides how to proceed on GAIA |error|. If the error looks temporary,
72 // retries |task| after certain delay until max retry count is reached.
73 void RetryOnError(const char* operation_id,
74 const GoogleServiceAuthError& error,
75 const base::Closure& task);
76
77 OAuth2LoginVerifier::Delegate* delegate_;
78 OAuth2AccessTokenFetcher token_fetcher_;
79 GaiaAuthFetcher gaia_fetcher_;
80 std::string access_token_;
81 std::string refresh_token_;
82 std::string sid_;
83 std::string lsid_;
84 std::string token_;
85 // The retry counter. Increment this only when failure happened.
86 int retry_count_;
87
88 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier);
89 };
90
91 } // namespace chromeos
92
93 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698