| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Invoked when post-merge session verification fails. | 46 // Invoked when post-merge session verification fails. |
| 47 virtual void OnListAccountsFailure(bool connection_error) = 0; | 47 virtual void OnListAccountsFailure(bool connection_error) = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate, | 50 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate, |
| 51 net::URLRequestContextGetter* system_request_context, | 51 net::URLRequestContextGetter* system_request_context, |
| 52 net::URLRequestContextGetter* user_request_context, | 52 net::URLRequestContextGetter* user_request_context, |
| 53 const std::string& oauthlogin_access_token); | 53 const std::string& oauthlogin_access_token); |
| 54 virtual ~OAuth2LoginVerifier(); | 54 virtual ~OAuth2LoginVerifier(); |
| 55 | 55 |
| 56 // Initiates verification of GAIA cookies in |profile|'s cookie jar. |
| 57 void VerifyUserCookies(Profile* profile); |
| 58 |
| 56 // Attempts to restore session from OAuth2 refresh token minting all necesarry | 59 // Attempts to restore session from OAuth2 refresh token minting all necesarry |
| 57 // tokens along the way (OAuth2 access token, SID/LSID, GAIA service token). | 60 // tokens along the way (OAuth2 access token, SID/LSID, GAIA service token). |
| 58 void VerifyProfileTokens(Profile* profile); | 61 void VerifyProfileTokens(Profile* profile); |
| 59 | 62 |
| 60 private: | 63 private: |
| 61 enum SessionRestoreType { | 64 enum SessionRestoreType { |
| 62 RESTORE_UNDEFINED = 0, | 65 RESTORE_UNDEFINED = 0, |
| 63 RESTORE_FROM_GAIA_TOKEN = 1, | 66 RESTORE_FROM_GAIA_TOKEN = 1, |
| 64 RESTORE_FROM_OAUTH2_REFRESH_TOKEN = 2, | 67 RESTORE_FROM_OAUTH2_REFRESH_TOKEN = 2, |
| 65 }; | 68 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 87 // Starts OAuthLogin request for GAIA uber-token. | 90 // Starts OAuthLogin request for GAIA uber-token. |
| 88 void StartOAuthLoginForUberToken(); | 91 void StartOAuthLoginForUberToken(); |
| 89 | 92 |
| 90 // Attempts to merge session from present |gaia_token_|. | 93 // Attempts to merge session from present |gaia_token_|. |
| 91 void StartMergeSession(); | 94 void StartMergeSession(); |
| 92 | 95 |
| 93 // Schedules post merge verification to ensure that browser session restore | 96 // Schedules post merge verification to ensure that browser session restore |
| 94 // hasn't stumped over SID/LSID. | 97 // hasn't stumped over SID/LSID. |
| 95 void SchedulePostMergeVerification(); | 98 void SchedulePostMergeVerification(); |
| 96 | 99 |
| 97 // Starts post merge request verification. | 100 // Starts GAIA auth cookies (SID/LSID) verification. |
| 98 void StartPostRestoreVerification(); | 101 void StartAuthCookiesVerification(); |
| 99 | 102 |
| 100 // Decides how to proceed on GAIA |error|. If the error looks temporary, | 103 // Decides how to proceed on GAIA |error|. If the error looks temporary, |
| 101 // retries |task| after certain delay until max retry count is reached. | 104 // retries |task| after certain delay until max retry count is reached. |
| 102 void RetryOnError(const char* operation_id, | 105 void RetryOnError(const char* operation_id, |
| 103 const GoogleServiceAuthError& error, | 106 const GoogleServiceAuthError& error, |
| 104 const base::Closure& task_to_retry, | 107 const base::Closure& task_to_retry, |
| 105 const ErrorHandler& error_handler); | 108 const ErrorHandler& error_handler); |
| 106 | 109 |
| 110 // Delays operation defined with |callback| based on the current networking |
| 111 // conditions. |
| 112 bool DelayNetworkCall(const base::Closure& callback); |
| 113 |
| 107 OAuth2LoginVerifier::Delegate* delegate_; | 114 OAuth2LoginVerifier::Delegate* delegate_; |
| 108 scoped_refptr<net::URLRequestContextGetter> system_request_context_; | 115 scoped_refptr<net::URLRequestContextGetter> system_request_context_; |
| 109 scoped_refptr<net::URLRequestContextGetter> user_request_context_; | 116 scoped_refptr<net::URLRequestContextGetter> user_request_context_; |
| 110 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; | 117 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; |
| 111 std::string access_token_; | 118 std::string access_token_; |
| 112 std::string gaia_token_; | 119 std::string gaia_token_; |
| 113 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | 120 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
| 114 // The retry counter. Increment this only when failure happened. | 121 // The retry counter. Increment this only when failure happened. |
| 115 int retry_count_; | 122 int retry_count_; |
| 116 | 123 |
| 117 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier); | 124 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier); |
| 118 }; | 125 }; |
| 119 | 126 |
| 120 } // namespace chromeos | 127 } // namespace chromeos |
| 121 | 128 |
| 122 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ | 129 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_VERIFIER_H_ |
| OLD | NEW |