Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: components/signin/core/browser/account_reconcilor.cc

Issue 695553002: Account reconcilor: Use cookie store cookie changed subscription. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/account_reconcilor.h ('k') | components/signin/core/browser/signin_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698