| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void AccountReconcilor::RemoveMergeSessionObserver( | 114 void AccountReconcilor::RemoveMergeSessionObserver( |
| 115 MergeSessionHelper::Observer* observer) { | 115 MergeSessionHelper::Observer* observer) { |
| 116 merge_session_helper_.RemoveObserver(observer); | 116 merge_session_helper_.RemoveObserver(observer); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void AccountReconcilor::RegisterForCookieChanges() { | 119 void AccountReconcilor::RegisterForCookieChanges() { |
| 120 // First clear any existing registration to avoid DCHECKs that can otherwise | 120 // First clear any existing registration to avoid DCHECKs that can otherwise |
| 121 // go off in some embedders on reauth (e.g., ChromeSigninClient). | 121 // go off in some embedders on reauth (e.g., ChromeSigninClient). |
| 122 UnregisterForCookieChanges(); | 122 UnregisterForCookieChanges(); |
| 123 cookie_changed_subscription_ = client_->AddCookieChangedCallback( | 123 cookie_changed_subscription_ = client_->AddCookieChangedCallback( |
| 124 GaiaUrls::GetInstance()->gaia_url(), |
| 125 "LSID", |
| 124 base::Bind(&AccountReconcilor::OnCookieChanged, base::Unretained(this))); | 126 base::Bind(&AccountReconcilor::OnCookieChanged, base::Unretained(this))); |
| 125 } | 127 } |
| 126 | 128 |
| 127 void AccountReconcilor::UnregisterForCookieChanges() { | 129 void AccountReconcilor::UnregisterForCookieChanges() { |
| 128 cookie_changed_subscription_.reset(); | 130 cookie_changed_subscription_.reset(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void AccountReconcilor::RegisterWithSigninManager() { | 133 void AccountReconcilor::RegisterWithSigninManager() { |
| 132 signin_manager_->AddObserver(this); | 134 signin_manager_->AddObserver(this); |
| 133 } | 135 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 153 return; | 155 return; |
| 154 | 156 |
| 155 token_service_->RemoveObserver(this); | 157 token_service_->RemoveObserver(this); |
| 156 registered_with_token_service_ = false; | 158 registered_with_token_service_ = false; |
| 157 } | 159 } |
| 158 | 160 |
| 159 bool AccountReconcilor::IsProfileConnected() { | 161 bool AccountReconcilor::IsProfileConnected() { |
| 160 return signin_manager_->IsAuthenticated(); | 162 return signin_manager_->IsAuthenticated(); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void AccountReconcilor::OnCookieChanged(const net::CanonicalCookie* cookie) { | 165 void AccountReconcilor::OnCookieChanged(const net::CanonicalCookie& cookie, |
| 164 if (cookie->Name() == "LSID" && | 166 bool removed) { |
| 165 cookie->Domain() == GaiaUrls::GetInstance()->gaia_url().host() && | 167 DCHECK_EQ("LSID", cookie.Name()); |
| 166 cookie->IsSecure() && cookie->IsHttpOnly()) { | 168 DCHECK_EQ(GaiaUrls::GetInstance()->gaia_url().host(), cookie.Domain()); |
| 169 if (cookie.IsSecure() && cookie.IsHttpOnly()) { |
| 167 VLOG(1) << "AccountReconcilor::OnCookieChanged: LSID changed"; | 170 VLOG(1) << "AccountReconcilor::OnCookieChanged: LSID changed"; |
| 168 | 171 |
| 169 // It is possible that O2RT is not available at this moment. | 172 // It is possible that O2RT is not available at this moment. |
| 170 if (!token_service_->GetAccounts().size()) { | 173 if (!token_service_->GetAccounts().size()) { |
| 171 VLOG(1) << "AccountReconcilor::OnCookieChanged: cookie change is ingored" | 174 VLOG(1) << "AccountReconcilor::OnCookieChanged: cookie change is ingored" |
| 172 "because O2RT is not available yet."; | 175 "because O2RT is not available yet."; |
| 173 return; | 176 return; |
| 174 } | 177 } |
| 175 | 178 |
| 176 StartReconcile(); | 179 StartReconcile(); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 const std::string& account_id, | 482 const std::string& account_id, |
| 480 const GoogleServiceAuthError& error) { | 483 const GoogleServiceAuthError& error) { |
| 481 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id=" | 484 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id=" |
| 482 << account_id << " error=" << error.ToString(); | 485 << account_id << " error=" << error.ToString(); |
| 483 | 486 |
| 484 if (MarkAccountAsAddedToCookie(account_id)) { | 487 if (MarkAccountAsAddedToCookie(account_id)) { |
| 485 CalculateIfReconcileIsDone(); | 488 CalculateIfReconcileIsDone(); |
| 486 ScheduleStartReconcileIfChromeAccountsChanged(); | 489 ScheduleStartReconcileIfChromeAccountsChanged(); |
| 487 } | 490 } |
| 488 } | 491 } |
| OLD | NEW |