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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 public WebDataServiceConsumer { | 45 public WebDataServiceConsumer { |
46 public: | 46 public: |
47 // content::NotificationObserver listening for TokenService updates. | 47 // content::NotificationObserver listening for TokenService updates. |
48 virtual void Observe(int type, | 48 virtual void Observe(int type, |
49 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
50 const content::NotificationDetails& details) OVERRIDE; | 50 const content::NotificationDetails& details) OVERRIDE; |
51 | 51 |
52 // Initializes this token service with the profile. | 52 // Initializes this token service with the profile. |
53 virtual void Initialize(Profile* profile); | 53 virtual void Initialize(Profile* profile); |
54 | 54 |
| 55 // Loads credentials from a backing persistent store to make them available |
| 56 // after service is used between profile restarts. |
| 57 // Usually it's not necessary to directly call this method. |
| 58 void LoadCredentials(); |
| 59 |
55 // BrowserContextKeyedService implementation. | 60 // BrowserContextKeyedService implementation. |
56 virtual void Shutdown() OVERRIDE; | 61 virtual void Shutdown() OVERRIDE; |
57 | 62 |
58 // Gets an account id of the primary account related to the profile. | 63 // Gets an account id of the primary account related to the profile. |
59 std::string GetPrimaryAccountId(); | 64 std::string GetPrimaryAccountId(); |
60 | 65 |
61 // Lists account IDs of all accounts with a refresh token. | 66 // Lists account IDs of all accounts with a refresh token. |
62 virtual std::vector<std::string> GetAccounts() OVERRIDE; | 67 virtual std::vector<std::string> GetAccounts() OVERRIDE; |
63 | 68 |
64 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, | 69 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // to information about the account. | 145 // to information about the account. |
141 typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap; | 146 typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap; |
142 | 147 |
143 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, | 148 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, |
144 TokenServiceUpdateClearsCache); | 149 TokenServiceUpdateClearsCache); |
145 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, | 150 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, |
146 PersistenceDBUpgrade); | 151 PersistenceDBUpgrade); |
147 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, | 152 FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest, |
148 PersistenceLoadCredentials); | 153 PersistenceLoadCredentials); |
149 | 154 |
| 155 std::string GetAccountIdForMigratingRefreshToken(); |
| 156 |
150 // WebDataServiceConsumer implementation: | 157 // WebDataServiceConsumer implementation: |
151 virtual void OnWebDataServiceRequestDone( | 158 virtual void OnWebDataServiceRequestDone( |
152 WebDataServiceBase::Handle handle, | 159 WebDataServiceBase::Handle handle, |
153 const WDTypedResult* result) OVERRIDE; | 160 const WDTypedResult* result) OVERRIDE; |
154 | 161 |
155 // Loads credentials from a backing persistent store to make them available | |
156 // after service is used between profile restarts. | |
157 void LoadCredentials(); | |
158 | |
159 // Loads credentials into in memory stucture. | 162 // Loads credentials into in memory stucture. |
160 void LoadAllCredentialsIntoMemory( | 163 void LoadAllCredentialsIntoMemory( |
161 const std::map<std::string, std::string>& db_tokens); | 164 const std::map<std::string, std::string>& db_tokens); |
162 | 165 |
163 // Loads a single pair of |account_id|, |refresh_token| into memory. | 166 // Loads a single pair of |account_id|, |refresh_token| into memory. |
164 void LoadCredentialsIntoMemory(const std::string& account_id, | 167 void LoadCredentialsIntoMemory(const std::string& account_id, |
165 const std::string& refresh_token); | 168 const std::string& refresh_token); |
166 | 169 |
167 // The profile with which this instance was initialized, or NULL. | 170 // The profile with which this instance was initialized, or NULL. |
168 Profile* profile_; | 171 Profile* profile_; |
(...skipping 10 matching lines...) Expand all Loading... |
179 // wrench menu). | 182 // wrench menu). |
180 scoped_ptr<SigninGlobalError> signin_global_error_; | 183 scoped_ptr<SigninGlobalError> signin_global_error_; |
181 | 184 |
182 // Registrar for notifications from the TokenService. | 185 // Registrar for notifications from the TokenService. |
183 content::NotificationRegistrar registrar_; | 186 content::NotificationRegistrar registrar_; |
184 | 187 |
185 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); | 188 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); |
186 }; | 189 }; |
187 | 190 |
188 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 191 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |