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 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ | 4 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ |
5 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ | 5 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace net { | 33 namespace net { |
34 class CanonicalCookie; | 34 class CanonicalCookie; |
35 } | 35 } |
36 | 36 |
37 class AccountReconcilor : public KeyedService, | 37 class AccountReconcilor : public KeyedService, |
38 public content_settings::Observer, | 38 public content_settings::Observer, |
39 public GaiaCookieManagerService::Observer, | 39 public GaiaCookieManagerService::Observer, |
40 public OAuth2TokenService::Observer, | 40 public OAuth2TokenService::Observer, |
41 public SigninManagerBase::Observer { | 41 public SigninManagerBase::Observer { |
42 public: | 42 public: |
| 43 enum State { |
| 44 NOT_RECONCILING, |
| 45 NOT_RECONCILING_ERROR_OCCURED, |
| 46 GATHERING_INFORMATION, |
| 47 APPLYING_CHANGES |
| 48 }; |
| 49 |
43 AccountReconcilor(ProfileOAuth2TokenService* token_service, | 50 AccountReconcilor(ProfileOAuth2TokenService* token_service, |
44 SigninManagerBase* signin_manager, | 51 SigninManagerBase* signin_manager, |
45 SigninClient* client, | 52 SigninClient* client, |
46 GaiaCookieManagerService* cookie_manager_service); | 53 GaiaCookieManagerService* cookie_manager_service); |
47 ~AccountReconcilor() override; | 54 ~AccountReconcilor() override; |
48 | 55 |
49 void Initialize(bool start_reconcile_if_tokens_available); | 56 void Initialize(bool start_reconcile_if_tokens_available); |
50 | 57 |
51 // Signal that the status of the new_profile_management flag has changed. | 58 // Signal that the status of the new_profile_management flag has changed. |
52 // Pass the new status as an explicit parameter since disabling the flag | 59 // Pass the new status as an explicit parameter since disabling the flag |
53 // doesn't remove it from the CommandLine::ForCurrentProcess(). | 60 // doesn't remove it from the CommandLine::ForCurrentProcess(). |
54 void OnNewProfileManagementFlagChanged(bool new_flag_status); | 61 void OnNewProfileManagementFlagChanged(bool new_flag_status); |
55 | 62 |
56 // KeyedService implementation. | 63 // KeyedService implementation. |
57 void Shutdown() override; | 64 void Shutdown() override; |
58 | 65 |
| 66 // Determine what the reconcilor is currently doing. |
| 67 State GetState(); |
| 68 |
59 private: | 69 private: |
60 bool IsRegisteredWithTokenService() const { | 70 bool IsRegisteredWithTokenService() const { |
61 return registered_with_token_service_; | 71 return registered_with_token_service_; |
62 } | 72 } |
63 | 73 |
64 const std::vector<std::pair<std::string, bool> >& GetGaiaAccountsForTesting() | 74 const std::vector<std::pair<std::string, bool> >& GetGaiaAccountsForTesting() |
65 const { | 75 const { |
66 return gaia_accounts_; | 76 return gaia_accounts_; |
67 } | 77 } |
68 | 78 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 bool registered_with_content_settings_; | 177 bool registered_with_content_settings_; |
168 | 178 |
169 // True while the reconcilor is busy checking or managing the accounts in | 179 // True while the reconcilor is busy checking or managing the accounts in |
170 // this profile. | 180 // this profile. |
171 bool is_reconcile_started_; | 181 bool is_reconcile_started_; |
172 base::Time m_reconcile_start_time_; | 182 base::Time m_reconcile_start_time_; |
173 | 183 |
174 // True iff this is the first time the reconcilor is executing. | 184 // True iff this is the first time the reconcilor is executing. |
175 bool first_execution_; | 185 bool first_execution_; |
176 | 186 |
| 187 // True iff an error occured during the last attempt to reconcile. |
| 188 bool error_during_last_reconcile_; |
| 189 |
177 // Used during reconcile action. | 190 // Used during reconcile action. |
178 // These members are used to validate the gaia cookie. |gaia_accounts_| | 191 // These members are used to validate the gaia cookie. |gaia_accounts_| |
179 // holds the state of google accounts in the gaia cookie. Each element is | 192 // holds the state of google accounts in the gaia cookie. Each element is |
180 // a pair that holds the email address of the account and a boolean that | 193 // a pair that holds the email address of the account and a boolean that |
181 // indicates whether the account is valid or not. The accounts in the vector | 194 // indicates whether the account is valid or not. The accounts in the vector |
182 // are ordered the in same way as the gaia cookie. | 195 // are ordered the in same way as the gaia cookie. |
183 std::vector<std::pair<std::string, bool> > gaia_accounts_; | 196 std::vector<std::pair<std::string, bool> > gaia_accounts_; |
184 | 197 |
185 // Used during reconcile action. | 198 // Used during reconcile action. |
186 // These members are used to validate the tokens in OAuth2TokenService. | 199 // These members are used to validate the tokens in OAuth2TokenService. |
187 std::string primary_account_; | 200 std::string primary_account_; |
188 std::vector<std::string> chrome_accounts_; | 201 std::vector<std::string> chrome_accounts_; |
189 std::vector<std::string> add_to_cookie_; | 202 std::vector<std::string> add_to_cookie_; |
190 bool chrome_accounts_changed_; | 203 bool chrome_accounts_changed_; |
191 | 204 |
192 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); | 205 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); |
193 }; | 206 }; |
194 | 207 |
195 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ | 208 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ |
OLD | NEW |