Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "chrome/browser/signin/signin_global_error.h" | 12 #include "chrome/browser/signin/signin_global_error.h" |
| 13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" |
| 14 #include "google_apis/gaia/oauth2_token_service.h" | 14 #include "google_apis/gaia/oauth2_token_service.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class GoogleServiceAuthError; | 20 class GoogleServiceAuthError; |
| 21 class Profile; | 21 class Profile; |
| 22 class SigninGlobalError; | 22 class SigninGlobalError; |
| 23 | 23 |
| 24 // TODO(blundell): What should the following be rewritten to? | |
|
blundell
2014/02/10 16:19:16
Suggestions here?
Roger Tawa OOO till Jul 10th
2014/02/10 19:49:13
Seems like you can replace "BrowserContextKeyedSer
blundell
2014/02/13 16:07:06
Changed to "class" as "component" is an overloaded
| |
| 24 // ProfileOAuth2TokenService is a BrowserContextKeyedService that retrieves | 25 // ProfileOAuth2TokenService is a BrowserContextKeyedService that retrieves |
| 25 // OAuth2 access tokens for a given set of scopes using the OAuth2 login | 26 // OAuth2 access tokens for a given set of scopes using the OAuth2 login |
| 26 // refresh tokens. | 27 // refresh tokens. |
| 27 // | 28 // |
| 28 // See |OAuth2TokenService| for usage details. | 29 // See |OAuth2TokenService| for usage details. |
| 29 // | 30 // |
| 30 // Note: after StartRequest returns, in-flight requests will continue | 31 // Note: after StartRequest returns, in-flight requests will continue |
| 31 // even if the TokenService refresh token that was used to initiate | 32 // even if the TokenService refresh token that was used to initiate |
| 32 // the request changes or is cleared. When the request completes, | 33 // the request changes or is cleared. When the request completes, |
| 33 // Consumer::OnGetTokenSuccess will be invoked, but the access token | 34 // Consumer::OnGetTokenSuccess will be invoked, but the access token |
| 34 // won't be cached. | 35 // won't be cached. |
| 35 // | 36 // |
| 36 // Note: requests should be started from the UI thread. To start a | 37 // Note: requests should be started from the UI thread. To start a |
| 37 // request from other thread, please use ProfileOAuth2TokenServiceRequest. | 38 // request from other thread, please use ProfileOAuth2TokenServiceRequest. |
| 38 class ProfileOAuth2TokenService : public OAuth2TokenService, | 39 class ProfileOAuth2TokenService : public OAuth2TokenService { |
| 39 public BrowserContextKeyedService { | |
| 40 public: | 40 public: |
| 41 virtual ~ProfileOAuth2TokenService(); | |
| 42 | |
| 41 // Initializes this token service with the profile. | 43 // Initializes this token service with the profile. |
| 42 virtual void Initialize(Profile* profile); | 44 virtual void Initialize(Profile* profile); |
| 43 | 45 |
| 44 // BrowserContextKeyedService implementation. | 46 virtual void Shutdown(); |
| 45 virtual void Shutdown() OVERRIDE; | |
| 46 | 47 |
| 47 // Gets an account id of the primary account related to the profile. | 48 // Gets an account id of the primary account related to the profile. |
| 48 // DEPRECATED: Use SigninManagerBase::GetAuthenticatedAccountId() instead. | 49 // DEPRECATED: Use SigninManagerBase::GetAuthenticatedAccountId() instead. |
| 49 std::string GetPrimaryAccountId(); | 50 std::string GetPrimaryAccountId(); |
| 50 | 51 |
| 51 // Lists account IDs of all accounts with a refresh token. | 52 // Lists account IDs of all accounts with a refresh token. |
| 52 virtual std::vector<std::string> GetAccounts() OVERRIDE; | 53 virtual std::vector<std::string> GetAccounts() OVERRIDE; |
| 53 | 54 |
| 54 // Loads credentials from a backing persistent store to make them available | 55 // Loads credentials from a backing persistent store to make them available |
| 55 // after service is used between profile restarts. | 56 // after service is used between profile restarts. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 75 } | 76 } |
| 76 | 77 |
| 77 const SigninGlobalError* signin_global_error() const { | 78 const SigninGlobalError* signin_global_error() const { |
| 78 return signin_global_error_.get(); | 79 return signin_global_error_.get(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 Profile* profile() const { return profile_; } | 82 Profile* profile() const { return profile_; } |
| 82 | 83 |
| 83 protected: | 84 protected: |
| 84 ProfileOAuth2TokenService(); | 85 ProfileOAuth2TokenService(); |
| 85 virtual ~ProfileOAuth2TokenService(); | |
| 86 | 86 |
| 87 // OAuth2TokenService overrides. | 87 // OAuth2TokenService overrides. |
| 88 // Note: These methods are overriden so that ProfileOAuth2TokenService is a | 88 // Note: These methods are overriden so that ProfileOAuth2TokenService is a |
| 89 // concrete class. | 89 // concrete class. |
| 90 | 90 |
| 91 // Simply returns NULL and should be overriden by subsclasses. | 91 // Simply returns NULL and should be overriden by subsclasses. |
| 92 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 92 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 93 | 93 |
| 94 // Default implementation of this method is NOTREACHED as it should be be | 94 // Default implementation of this method is NOTREACHED as it should be be |
| 95 // overriden by subclasses. | 95 // overriden by subclasses. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 108 // Used to show auth errors in the wrench menu. The SigninGlobalError is | 108 // Used to show auth errors in the wrench menu. The SigninGlobalError is |
| 109 // different than most GlobalErrors in that its lifetime is controlled by | 109 // different than most GlobalErrors in that its lifetime is controlled by |
| 110 // ProfileOAuth2TokenService (so we can expose a reference for use in the | 110 // ProfileOAuth2TokenService (so we can expose a reference for use in the |
| 111 // wrench menu). | 111 // wrench menu). |
| 112 scoped_ptr<SigninGlobalError> signin_global_error_; | 112 scoped_ptr<SigninGlobalError> signin_global_error_; |
| 113 | 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); | 114 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 117 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |