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

Side by Side Diff: chrome/browser/signin/profile_oauth2_token_service.h

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to include the update to ProfileSyncService: r224220 Created 7 years, 3 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
OLDNEW
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
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 // Takes injected TokenService for testing. 61 // Gets an account id of the primary account related to the profile.
62 bool ShouldCacheForRefreshToken(TokenService *token_service, 62 std::string GetPrimaryAccountId();
63 const std::string& refresh_token); 63
64 // Lists account IDs of all accounts with a refresh token.
65 virtual std::vector<std::string> GetAccounts() OVERRIDE;
64 66
65 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, 67 // Updates a |refresh_token| for an |account_id|. Credentials are persisted,
66 // and avialable through |LoadCredentials| after service is restarted. 68 // and avialable through |LoadCredentials| after service is restarted.
67 void UpdateCredentials(const std::string& account_id, 69 void UpdateCredentials(const std::string& account_id,
68 const std::string& refresh_token); 70 const std::string& refresh_token);
69 71
70 // Revokes credentials related to |account_id|. 72 // Revokes credentials related to |account_id|.
71 void RevokeCredentials(const std::string& account_id); 73 void RevokeCredentials(const std::string& account_id);
72 74
73 // Revokes all credentials handled by the object. 75 // Revokes all credentials handled by the object.
74 void RevokeAllCredentials(); 76 void RevokeAllCredentials();
75 77
76 SigninGlobalError* signin_global_error() { 78 SigninGlobalError* signin_global_error() {
77 return signin_global_error_.get(); 79 return signin_global_error_.get();
78 } 80 }
79 81
80 const SigninGlobalError* signin_global_error() const { 82 const SigninGlobalError* signin_global_error() const {
81 return signin_global_error_.get(); 83 return signin_global_error_.get();
82 } 84 }
83 85
84 Profile* profile() const { return profile_; } 86 Profile* profile() const { return profile_; }
85 87
86 protected: 88 protected:
87 friend class ProfileOAuth2TokenServiceFactory; 89 friend class ProfileOAuth2TokenServiceFactory;
88 ProfileOAuth2TokenService(); 90 ProfileOAuth2TokenService();
89 virtual ~ProfileOAuth2TokenService(); 91 virtual ~ProfileOAuth2TokenService();
90 92
91 // OAuth2TokenService overrides. 93 // OAuth2TokenService overrides.
92 virtual std::string GetRefreshToken() OVERRIDE; 94 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE;
93 95
94 // OAuth2TokenService implementation. 96 // OAuth2TokenService implementation.
95 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 97 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
96 98
97 // Updates the internal cache of the result from the most-recently-completed 99 // Updates the internal cache of the result from the most-recently-completed
98 // auth request (used for reporting errors to the user). 100 // auth request (used for reporting errors to the user).
99 virtual void UpdateAuthError(const GoogleServiceAuthError& error) OVERRIDE; 101 virtual void UpdateAuthError(
102 const std::string& account_id,
103 const GoogleServiceAuthError& error) OVERRIDE;
100 104
101 // Overridden to not cache tokens if the TokenService refresh token 105 // Persists credentials for |account_id|. Enables overriding for
102 // changes while a token fetch is in-flight. If the user logs out and 106 // testing purposes, or other cases, when accessing the DB is not desired.
103 // logs back in with a different account, then any in-flight token 107 virtual void PersistCredentials(const std::string& account_id,
104 // fetches will be for the old account's refresh token. Therefore 108 const std::string& refresh_token);
105 // when they come back, they shouldn't be cached. 109
106 virtual void RegisterCacheEntry(const std::string& client_id, 110 // Clears credentials persisted for |account_id|. Enables overriding for
107 const std::string& refresh_token, 111 // testing purposes, or other cases, when accessing the DB is not desired.
108 const ScopeSet& scopes, 112 virtual void ClearPersistedCredentials(const std::string& account_id);
109 const std::string& access_token,
110 const base::Time& expiration_date) OVERRIDE;
111 113
112 private: 114 private:
113 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, 115 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
114 StaleRefreshTokensNotCached);
115 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
116 TokenServiceUpdateClearsCache); 116 TokenServiceUpdateClearsCache);
117 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, 117 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
118 PersistenceDBUpgrade); 118 PersistenceDBUpgrade);
119 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, 119 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
120 PersistenceLoadCredentials); 120 PersistenceLoadCredentials);
121 121
122 // WebDataServiceConsumer implementation: 122 // WebDataServiceConsumer implementation:
123 virtual void OnWebDataServiceRequestDone( 123 virtual void OnWebDataServiceRequestDone(
124 WebDataServiceBase::Handle handle, 124 WebDataServiceBase::Handle handle,
125 const WDTypedResult* result) OVERRIDE; 125 const WDTypedResult* result) OVERRIDE;
(...skipping 28 matching lines...) Expand all
154 // The auth status from the most-recently-completed request. 154 // The auth status from the most-recently-completed request.
155 GoogleServiceAuthError last_auth_error_; 155 GoogleServiceAuthError last_auth_error_;
156 156
157 // Registrar for notifications from the TokenService. 157 // Registrar for notifications from the TokenService.
158 content::NotificationRegistrar registrar_; 158 content::NotificationRegistrar registrar_;
159 159
160 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); 160 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService);
161 }; 161 };
162 162
163 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 163 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/signin/fake_profile_oauth2_token_service.cc ('k') | chrome/browser/signin/profile_oauth2_token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698