| 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 #include "components/signin/core/browser/account_reconcilor.h" | 5 #include "components/signin/core/browser/account_reconcilor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 bool AccountReconcilor::AreAllRefreshTokensChecked() const { | 269 bool AccountReconcilor::AreAllRefreshTokensChecked() const { |
| 270 return chrome_accounts_.size() == | 270 return chrome_accounts_.size() == |
| 271 (valid_chrome_accounts_.size() + invalid_chrome_accounts_.size()); | 271 (valid_chrome_accounts_.size() + invalid_chrome_accounts_.size()); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void AccountReconcilor::RegisterForCookieChanges() { | 274 void AccountReconcilor::RegisterForCookieChanges() { |
| 275 // First clear any existing registration to avoid DCHECKs that can otherwise | 275 // First clear any existing registration to avoid DCHECKs that can otherwise |
| 276 // go off in some embedders on reauth (e.g., ChromeSigninClient). | 276 // go off in some embedders on reauth (e.g., ChromeSigninClient). |
| 277 UnregisterForCookieChanges(); | 277 UnregisterForCookieChanges(); |
| 278 client_->SetCookieChangedCallback( | 278 cookie_changed_subscription_ = client_->AddCookieChangedCallback( |
| 279 base::Bind(&AccountReconcilor::OnCookieChanged, base::Unretained(this))); | 279 base::Bind(&AccountReconcilor::OnCookieChanged, base::Unretained(this))); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void AccountReconcilor::UnregisterForCookieChanges() { | 282 void AccountReconcilor::UnregisterForCookieChanges() { |
| 283 client_->SetCookieChangedCallback(SigninClient::CookieChangedCallback()); | 283 cookie_changed_subscription_.reset(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void AccountReconcilor::RegisterWithSigninManager() { | 286 void AccountReconcilor::RegisterWithSigninManager() { |
| 287 signin_manager_->AddObserver(this); | 287 signin_manager_->AddObserver(this); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void AccountReconcilor::UnregisterWithSigninManager() { | 290 void AccountReconcilor::UnregisterWithSigninManager() { |
| 291 signin_manager_->RemoveObserver(this); | 291 signin_manager_->RemoveObserver(this); |
| 292 } | 292 } |
| 293 | 293 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 784 |
| 785 void AccountReconcilor::HandleRefreshTokenFetched( | 785 void AccountReconcilor::HandleRefreshTokenFetched( |
| 786 const std::string& account_id, | 786 const std::string& account_id, |
| 787 const std::string& refresh_token) { | 787 const std::string& refresh_token) { |
| 788 if (!refresh_token.empty()) | 788 if (!refresh_token.empty()) |
| 789 PerformAddAccountToTokenService(account_id, refresh_token); | 789 PerformAddAccountToTokenService(account_id, refresh_token); |
| 790 | 790 |
| 791 MarkAccountAsAddedToChrome(account_id); | 791 MarkAccountAsAddedToChrome(account_id); |
| 792 CalculateIfReconcileIsDone(); | 792 CalculateIfReconcileIsDone(); |
| 793 } | 793 } |
| OLD | NEW |