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

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

Powered by Google App Engine
This is Rietveld 408576698