| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 61 // OAuth2TokenService implementation. |
| 62 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 62 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 63 | 63 |
| 64 // Takes injected TokenService for testing. | 64 // Takes injected TokenService for testing. |
| 65 bool ShouldCacheForRefreshToken(TokenService *token_service, | 65 bool ShouldCacheForRefreshToken(const std::string& refresh_token); |
| 66 const std::string& refresh_token); | 66 |
| 67 // Gets an account id of the primary account related to the profile. |
| 68 std::string GetPrimaryAccountId(); |
| 69 |
| 70 // Lists account IDs of all accounts with a refresh token. |
| 71 std::vector<std::string> GetAccounts(); |
| 67 | 72 |
| 68 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, | 73 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, |
| 69 // and avialable through |LoadCredentials| after service is restarted. | 74 // and avialable through |LoadCredentials| after service is restarted. |
| 70 void UpdateCredentials(const std::string& account_id, | 75 void UpdateCredentials(const std::string& account_id, |
| 71 const std::string& refresh_token); | 76 const std::string& refresh_token); |
| 72 | 77 |
| 73 // Revokes credentials related to |account_id|. | 78 // Revokes credentials related to |account_id|. |
| 74 void RevokeCredentials(const std::string& account_id); | 79 void RevokeCredentials(const std::string& account_id); |
| 75 | 80 |
| 76 // Revokes all credentials handled by the object. | 81 // Revokes all credentials handled by the object. |
| 77 void RevokeAllCredentials(); | 82 void RevokeAllCredentials(); |
| 78 | 83 |
| 79 SigninGlobalError* signin_global_error() { | 84 SigninGlobalError* signin_global_error() { |
| 80 return signin_global_error_.get(); | 85 return signin_global_error_.get(); |
| 81 } | 86 } |
| 82 | 87 |
| 83 const SigninGlobalError* signin_global_error() const { | 88 const SigninGlobalError* signin_global_error() const { |
| 84 return signin_global_error_.get(); | 89 return signin_global_error_.get(); |
| 85 } | 90 } |
| 86 | 91 |
| 87 Profile* profile() const { return profile_; } | 92 Profile* profile() const { return profile_; } |
| 88 | 93 |
| 89 protected: | 94 protected: |
| 90 friend class ProfileOAuth2TokenServiceFactory; | 95 friend class ProfileOAuth2TokenServiceFactory; |
| 91 ProfileOAuth2TokenService(); | 96 ProfileOAuth2TokenService(); |
| 92 virtual ~ProfileOAuth2TokenService(); | 97 virtual ~ProfileOAuth2TokenService(); |
| 93 | 98 |
| 94 // OAuth2TokenService overrides. | 99 // OAuth2TokenService overrides. |
| 95 virtual std::string GetRefreshToken() OVERRIDE; | 100 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE; |
| 96 | 101 |
| 97 // Updates the internal cache of the result from the most-recently-completed | 102 // Updates the internal cache of the result from the most-recently-completed |
| 98 // auth request (used for reporting errors to the user). | 103 // auth request (used for reporting errors to the user). |
| 99 virtual void UpdateAuthError(const GoogleServiceAuthError& error) OVERRIDE; | 104 virtual void UpdateAuthError(const GoogleServiceAuthError& error) OVERRIDE; |
| 100 | 105 |
| 101 // Overridden to not cache tokens if the TokenService refresh token | 106 // 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 | 107 // 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 | 108 // logs back in with a different account, then any in-flight token |
| 104 // fetches will be for the old account's refresh token. Therefore | 109 // fetches will be for the old account's refresh token. Therefore |
| 105 // when they come back, they shouldn't be cached. | 110 // when they come back, they shouldn't be cached. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // The auth status from the most-recently-completed request. | 158 // The auth status from the most-recently-completed request. |
| 154 GoogleServiceAuthError last_auth_error_; | 159 GoogleServiceAuthError last_auth_error_; |
| 155 | 160 |
| 156 // Registrar for notifications from the TokenService. | 161 // Registrar for notifications from the TokenService. |
| 157 content::NotificationRegistrar registrar_; | 162 content::NotificationRegistrar registrar_; |
| 158 | 163 |
| 159 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); | 164 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); |
| 160 }; | 165 }; |
| 161 | 166 |
| 162 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 167 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |