Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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.h" | |
|
xiyuan
2013/01/07 23:07:55
callback.h is probably not needed. And you might n
| |
| 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 authenticated credentials from the cookie jar, try to exchange | |
| 24 // fetch OAuth1 token+secret and then set of GAIA credentials (SID/LSID) that | |
| 25 // can be used for other token fetching calls (i.e. TokenService). | |
|
xiyuan
2013/01/07 23:07:55
Update the comments?
zel
2013/01/08 02:05:41
Done.
| |
| 26 class OAuth2LoginVerifier : public base::SupportsWeakPtr<OAuth2LoginVerifier>, | |
| 27 public GaiaAuthConsumer, | |
| 28 public OAuth2AccessTokenConsumer { | |
| 29 public: | |
| 30 class Delegate { | |
| 31 public: | |
| 32 virtual ~Delegate() {} | |
| 33 virtual void OnOAuth2LoginVerifierSuccess(const std::string& sid, | |
| 34 const std::string& lsid, | |
| 35 const std::string& auth) = 0; | |
| 36 virtual void OnOAuth2LoginVerifierFaulure() = 0; | |
| 37 }; | |
| 38 | |
| 39 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate, | |
| 40 net::URLRequestContextGetter* system_request_context, | |
| 41 Profile* user_profile); | |
| 42 virtual ~OAuth2LoginVerifier(); | |
| 43 | |
| 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 delY until max retry count is reached. | |
|
xiyuan
2013/01/07 23:07:55
nit: delY -> delay
zel
2013/01/08 02:05:41
Done.
| |
| 73 void RetryOnError(const char* operation_id, | |
| 74 const GoogleServiceAuthError& error, | |
| 75 const base::Closure& task); | |
| 76 | |
| 77 OAuth2LoginVerifier::Delegate* delegate_; | |
| 78 Profile* auth_profile_; | |
|
xiyuan
2013/01/07 23:07:55
|auth_profile_| seems not used.
zel
2013/01/08 02:05:41
Done.
| |
| 79 OAuth2AccessTokenFetcher token_fetcher_; | |
| 80 GaiaAuthFetcher gaia_fetcher_; | |
| 81 std::string access_token_; | |
| 82 std::string refresh_token_; | |
| 83 std::string sid_; | |
| 84 std::string lsid_; | |
| 85 std::string token_; | |
| 86 // The retry counter. Increment this only when failure happened. | |
| 87 int retry_count_; | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier); | |
| 90 }; | |
| 91 | |
| 92 } // namespace chromeos | |
| 93 | |
| 94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ | |
| OLD | NEW |