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

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

Powered by Google App Engine
This is Rietveld 408576698