OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_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 19 matching lines...) Expand all Loading... |
30 // even if the TokenService refresh token that was used to initiate | 30 // even if the TokenService refresh token that was used to initiate |
31 // the request changes or is cleared. When the request completes, | 31 // the request changes or is cleared. When the request completes, |
32 // Consumer::OnGetTokenSuccess will be invoked, but the access token | 32 // Consumer::OnGetTokenSuccess will be invoked, but the access token |
33 // won't be cached. | 33 // won't be cached. |
34 // | 34 // |
35 // Note: requests should be started from the UI thread. To start a | 35 // Note: requests should be started from the UI thread. To start a |
36 // request from other thread, please use OAuth2TokenServiceRequest. | 36 // request from other thread, please use OAuth2TokenServiceRequest. |
37 class ProfileOAuth2TokenService : public OAuth2TokenService, | 37 class ProfileOAuth2TokenService : public OAuth2TokenService, |
38 public KeyedService { | 38 public KeyedService { |
39 public: | 39 public: |
40 virtual ~ProfileOAuth2TokenService(); | 40 ~ProfileOAuth2TokenService() override; |
41 | 41 |
42 // Initializes this token service with the SigninClient. | 42 // Initializes this token service with the SigninClient. |
43 virtual void Initialize(SigninClient* client); | 43 virtual void Initialize(SigninClient* client); |
44 | 44 |
45 // KeyedService implementation. | 45 // KeyedService implementation. |
46 virtual void Shutdown() override; | 46 void Shutdown() override; |
47 | 47 |
48 // Lists account IDs of all accounts with a refresh token. | 48 // Lists account IDs of all accounts with a refresh token. |
49 virtual std::vector<std::string> GetAccounts() override; | 49 std::vector<std::string> GetAccounts() override; |
50 | 50 |
51 // Loads credentials from a backing persistent store to make them available | 51 // Loads credentials from a backing persistent store to make them available |
52 // after service is used between profile restarts. | 52 // after service is used between profile restarts. |
53 // | 53 // |
54 // Only call this method if there is at least one account connected to the | 54 // Only call this method if there is at least one account connected to the |
55 // profile, otherwise startup will cause unneeded work on the IO thread. The | 55 // profile, otherwise startup will cause unneeded work on the IO thread. The |
56 // primary account is specified with the |primary_account_id| argument and | 56 // primary account is specified with the |primary_account_id| argument and |
57 // should not be empty. For a regular profile, the primary account id comes | 57 // should not be empty. For a regular profile, the primary account id comes |
58 // from SigninManager. For a supervised user, the id comes from | 58 // from SigninManager. For a supervised user, the id comes from |
59 // SupervisedUserService. | 59 // SupervisedUserService. |
(...skipping 18 matching lines...) Expand all Loading... |
78 SigninClient* client() const { return client_; } | 78 SigninClient* client() const { return client_; } |
79 | 79 |
80 protected: | 80 protected: |
81 ProfileOAuth2TokenService(); | 81 ProfileOAuth2TokenService(); |
82 | 82 |
83 // OAuth2TokenService overrides. | 83 // OAuth2TokenService overrides. |
84 // Note: These methods are overriden so that ProfileOAuth2TokenService is a | 84 // Note: These methods are overriden so that ProfileOAuth2TokenService is a |
85 // concrete class. | 85 // concrete class. |
86 | 86 |
87 // Simply returns NULL and should be overriden by subsclasses. | 87 // Simply returns NULL and should be overriden by subsclasses. |
88 virtual net::URLRequestContextGetter* GetRequestContext() override; | 88 net::URLRequestContextGetter* GetRequestContext() override; |
89 | 89 |
90 // Updates the internal cache of the result from the most-recently-completed | 90 // Updates the internal cache of the result from the most-recently-completed |
91 // auth request (used for reporting errors to the user). | 91 // auth request (used for reporting errors to the user). |
92 virtual void UpdateAuthError( | 92 void UpdateAuthError(const std::string& account_id, |
93 const std::string& account_id, | 93 const GoogleServiceAuthError& error) override; |
94 const GoogleServiceAuthError& error) override; | |
95 | 94 |
96 // Validate that the account_id argument is valid. This method DCHECKs | 95 // Validate that the account_id argument is valid. This method DCHECKs |
97 // when invalid. | 96 // when invalid. |
98 void ValidateAccountId(const std::string& account_id) const; | 97 void ValidateAccountId(const std::string& account_id) const; |
99 | 98 |
100 private: | 99 private: |
101 // The client with which this instance was initialized, or NULL. | 100 // The client with which this instance was initialized, or NULL. |
102 SigninClient* client_; | 101 SigninClient* client_; |
103 | 102 |
104 // Used to expose auth errors to the UI. | 103 // Used to expose auth errors to the UI. |
105 scoped_ptr<SigninErrorController> signin_error_controller_; | 104 scoped_ptr<SigninErrorController> signin_error_controller_; |
106 | 105 |
107 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); | 106 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); |
108 }; | 107 }; |
109 | 108 |
110 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 109 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |