| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // Initializes this token service with the profile. | 52 // Initializes this token service with the profile. |
| 53 virtual void Initialize(Profile* profile); | 53 virtual void Initialize(Profile* profile); |
| 54 | 54 |
| 55 // BrowserContextKeyedService implementation. | 55 // BrowserContextKeyedService implementation. |
| 56 virtual void Shutdown() OVERRIDE; | 56 virtual void Shutdown() OVERRIDE; |
| 57 | 57 |
| 58 // SigninGlobalError::AuthStatusProvider implementation. | 58 // SigninGlobalError::AuthStatusProvider implementation. |
| 59 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; | 59 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; |
| 60 | 60 |
| 61 // OAuth2TokenService implementation. | |
| 62 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | |
| 63 | |
| 64 // Takes injected TokenService for testing. | 61 // Takes injected TokenService for testing. |
| 65 bool ShouldCacheForRefreshToken(TokenService *token_service, | 62 bool ShouldCacheForRefreshToken(TokenService *token_service, |
| 66 const std::string& refresh_token); | 63 const std::string& refresh_token); |
| 67 | 64 |
| 68 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, | 65 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, |
| 69 // and avialable through |LoadCredentials| after service is restarted. | 66 // and avialable through |LoadCredentials| after service is restarted. |
| 70 void UpdateCredentials(const std::string& account_id, | 67 void UpdateCredentials(const std::string& account_id, |
| 71 const std::string& refresh_token); | 68 const std::string& refresh_token); |
| 72 | 69 |
| 73 // Revokes credentials related to |account_id|. | 70 // Revokes credentials related to |account_id|. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 87 Profile* profile() const { return profile_; } | 84 Profile* profile() const { return profile_; } |
| 88 | 85 |
| 89 protected: | 86 protected: |
| 90 friend class ProfileOAuth2TokenServiceFactory; | 87 friend class ProfileOAuth2TokenServiceFactory; |
| 91 ProfileOAuth2TokenService(); | 88 ProfileOAuth2TokenService(); |
| 92 virtual ~ProfileOAuth2TokenService(); | 89 virtual ~ProfileOAuth2TokenService(); |
| 93 | 90 |
| 94 // OAuth2TokenService overrides. | 91 // OAuth2TokenService overrides. |
| 95 virtual std::string GetRefreshToken() OVERRIDE; | 92 virtual std::string GetRefreshToken() OVERRIDE; |
| 96 | 93 |
| 94 // OAuth2TokenService implementation. |
| 95 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 96 |
| 97 // Updates the internal cache of the result from the most-recently-completed | 97 // Updates the internal cache of the result from the most-recently-completed |
| 98 // auth request (used for reporting errors to the user). | 98 // auth request (used for reporting errors to the user). |
| 99 virtual void UpdateAuthError(const GoogleServiceAuthError& error) OVERRIDE; | 99 virtual void UpdateAuthError(const GoogleServiceAuthError& error) OVERRIDE; |
| 100 | 100 |
| 101 // Overridden to not cache tokens if the TokenService refresh token | 101 // Overridden to not cache tokens if the TokenService refresh token |
| 102 // changes while a token fetch is in-flight. If the user logs out and | 102 // changes while a token fetch is in-flight. If the user logs out and |
| 103 // logs back in with a different account, then any in-flight token | 103 // logs back in with a different account, then any in-flight token |
| 104 // fetches will be for the old account's refresh token. Therefore | 104 // fetches will be for the old account's refresh token. Therefore |
| 105 // when they come back, they shouldn't be cached. | 105 // when they come back, they shouldn't be cached. |
| 106 virtual void RegisterCacheEntry(const std::string& refresh_token, | 106 virtual void RegisterCacheEntry(const std::string& refresh_token, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // The auth status from the most-recently-completed request. | 153 // The auth status from the most-recently-completed request. |
| 154 GoogleServiceAuthError last_auth_error_; | 154 GoogleServiceAuthError last_auth_error_; |
| 155 | 155 |
| 156 // Registrar for notifications from the TokenService. | 156 // Registrar for notifications from the TokenService. |
| 157 content::NotificationRegistrar registrar_; | 157 content::NotificationRegistrar registrar_; |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); | 159 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 162 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |