OLD | NEW |
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" | 22 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
23 #include "chrome/browser/extensions/chrome_extension_function.h" | 23 #include "chrome/browser/extensions/chrome_extension_function.h" |
24 #include "chrome/browser/signin/signin_global_error.h" | 24 #include "chrome/browser/signin/signin_global_error.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 class Profile; | |
31 | 30 |
32 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
33 namespace chromeos { | 32 namespace chromeos { |
34 class DeviceOAuth2TokenService; | 33 class DeviceOAuth2TokenService; |
35 } | 34 } |
36 #endif | 35 #endif |
37 | 36 |
| 37 namespace content { |
| 38 class BrowserContext; |
| 39 } |
| 40 |
38 namespace extensions { | 41 namespace extensions { |
39 | 42 |
40 class GetAuthTokenFunctionTest; | 43 class GetAuthTokenFunctionTest; |
41 class MockGetAuthTokenFunction; | 44 class MockGetAuthTokenFunction; |
42 | 45 |
43 namespace identity_constants { | 46 namespace identity_constants { |
44 extern const char kInvalidClientId[]; | 47 extern const char kInvalidClientId[]; |
45 extern const char kInvalidScopes[]; | 48 extern const char kInvalidScopes[]; |
46 extern const char kAuthFailure[]; | 49 extern const char kAuthFailure[]; |
47 extern const char kNoGrant[]; | 50 extern const char kNoGrant[]; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 IssueAdviceInfo issue_advice_; | 252 IssueAdviceInfo issue_advice_; |
250 std::string token_; | 253 std::string token_; |
251 base::Time expiration_time_; | 254 base::Time expiration_time_; |
252 }; | 255 }; |
253 | 256 |
254 class IdentityAPI : public ProfileKeyedAPI, | 257 class IdentityAPI : public ProfileKeyedAPI, |
255 public AccountTracker::Observer { | 258 public AccountTracker::Observer { |
256 public: | 259 public: |
257 typedef std::map<ExtensionTokenKey, IdentityTokenCacheValue> CachedTokens; | 260 typedef std::map<ExtensionTokenKey, IdentityTokenCacheValue> CachedTokens; |
258 | 261 |
259 explicit IdentityAPI(Profile* profile); | 262 explicit IdentityAPI(content::BrowserContext* context); |
260 virtual ~IdentityAPI(); | 263 virtual ~IdentityAPI(); |
261 | 264 |
262 // Request serialization queue for getAuthToken. | 265 // Request serialization queue for getAuthToken. |
263 IdentityMintRequestQueue* mint_queue(); | 266 IdentityMintRequestQueue* mint_queue(); |
264 | 267 |
265 // Token cache | 268 // Token cache |
266 void SetCachedToken(const ExtensionTokenKey& key, | 269 void SetCachedToken(const ExtensionTokenKey& key, |
267 const IdentityTokenCacheValue& token_data); | 270 const IdentityTokenCacheValue& token_data); |
268 void EraseCachedToken(const std::string& extension_id, | 271 void EraseCachedToken(const std::string& extension_id, |
269 const std::string& token); | 272 const std::string& token); |
(...skipping 16 matching lines...) Expand all Loading... |
286 | 289 |
287 private: | 290 private: |
288 friend class ProfileKeyedAPIFactory<IdentityAPI>; | 291 friend class ProfileKeyedAPIFactory<IdentityAPI>; |
289 | 292 |
290 // ProfileKeyedAPI implementation. | 293 // ProfileKeyedAPI implementation. |
291 static const char* service_name() { | 294 static const char* service_name() { |
292 return "IdentityAPI"; | 295 return "IdentityAPI"; |
293 } | 296 } |
294 static const bool kServiceIsNULLWhileTesting = true; | 297 static const bool kServiceIsNULLWhileTesting = true; |
295 | 298 |
296 Profile* profile_; | 299 content::BrowserContext* browser_context_; |
297 IdentityMintRequestQueue mint_queue_; | 300 IdentityMintRequestQueue mint_queue_; |
298 CachedTokens token_cache_; | 301 CachedTokens token_cache_; |
299 AccountTracker account_tracker_; | 302 AccountTracker account_tracker_; |
300 }; | 303 }; |
301 | 304 |
302 template <> | 305 template <> |
303 void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies(); | 306 void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies(); |
304 | 307 |
305 } // namespace extensions | 308 } // namespace extensions |
306 | 309 |
307 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 310 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
OLD | NEW |