OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ |
6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // deleted. | 92 // deleted. |
93 // Note the refresh token has been collected from TokenService when this | 93 // Note the refresh token has been collected from TokenService when this |
94 // method returns, and the request can continue even if TokenService clears | 94 // method returns, and the request can continue even if TokenService clears |
95 // its tokens after this method returns. This means that outstanding | 95 // its tokens after this method returns. This means that outstanding |
96 // StartRequest actions will still complete even if the user signs out in the | 96 // StartRequest actions will still complete even if the user signs out in the |
97 // meantime. | 97 // meantime. |
98 virtual scoped_ptr<Request> StartRequest( | 98 virtual scoped_ptr<Request> StartRequest( |
99 const ScopeSet& scopes, | 99 const ScopeSet& scopes, |
100 OAuth2TokenService::Consumer* consumer); | 100 OAuth2TokenService::Consumer* consumer); |
101 | 101 |
| 102 virtual scoped_ptr<Request> InvalidateTokenAndStartRequest( |
| 103 const ScopeSet& scopes, |
| 104 OAuth2TokenService::Consumer* consumer, |
| 105 const std::string& invalid_token); |
| 106 |
102 // content::NotificationObserver | 107 // content::NotificationObserver |
103 virtual void Observe(int type, | 108 virtual void Observe(int type, |
104 const content::NotificationSource& source, | 109 const content::NotificationSource& source, |
105 const content::NotificationDetails& details) OVERRIDE; | 110 const content::NotificationDetails& details) OVERRIDE; |
106 | 111 |
107 // SigninGlobalError::AuthStatusProvider implementation. | 112 // SigninGlobalError::AuthStatusProvider implementation. |
108 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; | 113 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; |
109 | 114 |
110 private: | 115 private: |
111 // Class that fetches an OAuth2 access token for a given set of scopes and | 116 // Class that fetches an OAuth2 access token for a given set of scopes and |
(...skipping 14 matching lines...) Expand all Loading... |
126 struct CacheEntry { | 131 struct CacheEntry { |
127 std::string access_token; | 132 std::string access_token; |
128 base::Time expiration_date; | 133 base::Time expiration_date; |
129 }; | 134 }; |
130 | 135 |
131 // Returns a currently valid OAuth2 access token for the given set of scopes, | 136 // Returns a currently valid OAuth2 access token for the given set of scopes, |
132 // or NULL if none have been cached. Note the user of this method should | 137 // or NULL if none have been cached. Note the user of this method should |
133 // ensure no entry with the same |scopes| is added before the usage of the | 138 // ensure no entry with the same |scopes| is added before the usage of the |
134 // returned entry is done. | 139 // returned entry is done. |
135 const CacheEntry* GetCacheEntry(const ScopeSet& scopes); | 140 const CacheEntry* GetCacheEntry(const ScopeSet& scopes); |
| 141 |
136 // Registers a new access token in the cache if |refresh_token| is the one | 142 // Registers a new access token in the cache if |refresh_token| is the one |
137 // currently held by TokenService. | 143 // currently held by TokenService. |
138 void RegisterCacheEntry(const std::string& refresh_token, | 144 void RegisterCacheEntry(const std::string& refresh_token, |
139 const ScopeSet& scopes, | 145 const ScopeSet& scopes, |
140 const std::string& access_token, | 146 const std::string& access_token, |
141 const base::Time& expiration_date); | 147 const base::Time& expiration_date); |
142 | 148 |
| 149 // Removes an access token for the given set of scopes from the cache. |
| 150 // Returns true if the entry was removed, otherwise false. |
| 151 bool RemoveCacheEntry(const OAuth2TokenService::ScopeSet& scopes, |
| 152 const std::string& token_to_remove); |
| 153 |
| 154 |
143 // Called when |fetcher| finishes fetching. | 155 // Called when |fetcher| finishes fetching. |
144 void OnFetchComplete(Fetcher* fetcher); | 156 void OnFetchComplete(Fetcher* fetcher); |
145 | 157 |
146 // Updates the internal cache of the result from the most-recently-completed | 158 // Updates the internal cache of the result from the most-recently-completed |
147 // auth request (used for reporting errors to the user). | 159 // auth request (used for reporting errors to the user). |
148 void UpdateAuthError(const GoogleServiceAuthError& error); | 160 void UpdateAuthError(const GoogleServiceAuthError& error); |
149 | 161 |
150 // The profile with which this instance was initialized, or NULL. | 162 // The profile with which this instance was initialized, or NULL. |
151 Profile* profile_; | 163 Profile* profile_; |
152 | 164 |
(...skipping 14 matching lines...) Expand all Loading... |
167 // token using these parameters. | 179 // token using these parameters. |
168 std::map<FetchParameters, Fetcher*> pending_fetchers_; | 180 std::map<FetchParameters, Fetcher*> pending_fetchers_; |
169 | 181 |
170 // Registrar for notifications from the TokenService. | 182 // Registrar for notifications from the TokenService. |
171 content::NotificationRegistrar registrar_; | 183 content::NotificationRegistrar registrar_; |
172 | 184 |
173 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService); | 185 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService); |
174 }; | 186 }; |
175 | 187 |
176 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ | 188 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |