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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_api.h

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/extensions/api/identity/account_tracker.h" 16 #include "chrome/browser/extensions/api/identity/account_tracker.h"
17 #include "chrome/browser/extensions/api/identity/extension_token_key.h" 17 #include "chrome/browser/extensions/api/identity/extension_token_key.h"
18 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" 18 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h"
19 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h" 19 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h"
20 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h" 20 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
21 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" 21 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
22 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
23 #include "chrome/browser/extensions/chrome_extension_function.h" 22 #include "chrome/browser/extensions/chrome_extension_function.h"
24 #include "chrome/browser/signin/signin_global_error.h" 23 #include "chrome/browser/signin/signin_global_error.h"
24 #include "extensions/browser/browser_context_keyed_api_factory.h"
25 #include "google_apis/gaia/oauth2_mint_token_flow.h" 25 #include "google_apis/gaia/oauth2_mint_token_flow.h"
26 #include "google_apis/gaia/oauth2_token_service.h" 26 #include "google_apis/gaia/oauth2_token_service.h"
27 27
28 class GoogleServiceAuthError; 28 class GoogleServiceAuthError;
29 class MockGetAuthTokenFunction; 29 class MockGetAuthTokenFunction;
30 30
31 namespace content { 31 namespace content {
32 class BrowserContext; 32 class BrowserContext;
33 } 33 }
34 34
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 private: 239 private:
240 bool is_expired() const; 240 bool is_expired() const;
241 241
242 CacheValueStatus status_; 242 CacheValueStatus status_;
243 IssueAdviceInfo issue_advice_; 243 IssueAdviceInfo issue_advice_;
244 std::string token_; 244 std::string token_;
245 base::Time expiration_time_; 245 base::Time expiration_time_;
246 }; 246 };
247 247
248 class IdentityAPI : public ProfileKeyedAPI, 248 class IdentityAPI : public BrowserContextKeyedAPI,
249 public AccountTracker::Observer { 249 public AccountTracker::Observer {
250 public: 250 public:
251 typedef std::map<ExtensionTokenKey, IdentityTokenCacheValue> CachedTokens; 251 typedef std::map<ExtensionTokenKey, IdentityTokenCacheValue> CachedTokens;
252 252
253 explicit IdentityAPI(content::BrowserContext* context); 253 explicit IdentityAPI(content::BrowserContext* context);
254 virtual ~IdentityAPI(); 254 virtual ~IdentityAPI();
255 255
256 // Request serialization queue for getAuthToken. 256 // Request serialization queue for getAuthToken.
257 IdentityMintRequestQueue* mint_queue(); 257 IdentityMintRequestQueue* mint_queue();
258 258
259 // Token cache 259 // Token cache
260 void SetCachedToken(const ExtensionTokenKey& key, 260 void SetCachedToken(const ExtensionTokenKey& key,
261 const IdentityTokenCacheValue& token_data); 261 const IdentityTokenCacheValue& token_data);
262 void EraseCachedToken(const std::string& extension_id, 262 void EraseCachedToken(const std::string& extension_id,
263 const std::string& token); 263 const std::string& token);
264 void EraseAllCachedTokens(); 264 void EraseAllCachedTokens();
265 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key); 265 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key);
266 266
267 const CachedTokens& GetAllCachedTokens(); 267 const CachedTokens& GetAllCachedTokens();
268 268
269 void ReportAuthError(const GoogleServiceAuthError& error); 269 void ReportAuthError(const GoogleServiceAuthError& error);
270 GoogleServiceAuthError GetAuthStatusForTest() const; 270 GoogleServiceAuthError GetAuthStatusForTest() const;
271 271
272 // ProfileKeyedAPI implementation. 272 // BrowserContextKeyedAPI implementation.
273 virtual void Shutdown() OVERRIDE; 273 virtual void Shutdown() OVERRIDE;
274 static ProfileKeyedAPIFactory<IdentityAPI>* GetFactoryInstance(); 274 static BrowserContextKeyedAPIFactory<IdentityAPI>* GetFactoryInstance();
275 275
276 // AccountTracker::Observer implementation: 276 // AccountTracker::Observer implementation:
277 virtual void OnAccountAdded(const AccountIds& ids) OVERRIDE; 277 virtual void OnAccountAdded(const AccountIds& ids) OVERRIDE;
278 virtual void OnAccountRemoved(const AccountIds& ids) OVERRIDE; 278 virtual void OnAccountRemoved(const AccountIds& ids) OVERRIDE;
279 virtual void OnAccountSignInChanged(const AccountIds& ids, bool is_signed_in) 279 virtual void OnAccountSignInChanged(const AccountIds& ids, bool is_signed_in)
280 OVERRIDE; 280 OVERRIDE;
281 281
282 private: 282 private:
283 friend class ProfileKeyedAPIFactory<IdentityAPI>; 283 friend class BrowserContextKeyedAPIFactory<IdentityAPI>;
284 284
285 // ProfileKeyedAPI implementation. 285 // BrowserContextKeyedAPI implementation.
286 static const char* service_name() { 286 static const char* service_name() {
287 return "IdentityAPI"; 287 return "IdentityAPI";
288 } 288 }
289 static const bool kServiceIsNULLWhileTesting = true; 289 static const bool kServiceIsNULLWhileTesting = true;
290 290
291 content::BrowserContext* browser_context_; 291 content::BrowserContext* browser_context_;
292 IdentityMintRequestQueue mint_queue_; 292 IdentityMintRequestQueue mint_queue_;
293 CachedTokens token_cache_; 293 CachedTokens token_cache_;
294 AccountTracker account_tracker_; 294 AccountTracker account_tracker_;
295 }; 295 };
296 296
297 template <> 297 template <>
298 void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies(); 298 void BrowserContextKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies();
299 299
300 } // namespace extensions 300 } // namespace extensions
301 301
302 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 302 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/i18n/i18n_api.h ('k') | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698