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

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

Issue 372033002: Change semantics of newProfileManagement() to accountConsistency() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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 | Annotate | Revision Log
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 VLOG(1) << "AccountReconcilor::GoogleSignedOut: signed out"; 355 VLOG(1) << "AccountReconcilor::GoogleSignedOut: signed out";
356 gaia_fetcher_.reset(); 356 gaia_fetcher_.reset();
357 get_gaia_accounts_callbacks_.clear(); 357 get_gaia_accounts_callbacks_.clear();
358 AbortReconcile(); 358 AbortReconcile();
359 UnregisterWithTokenService(); 359 UnregisterWithTokenService();
360 UnregisterForCookieChanges(); 360 UnregisterForCookieChanges();
361 PerformLogoutAllAccountsAction(); 361 PerformLogoutAllAccountsAction();
362 } 362 }
363 363
364 void AccountReconcilor::PerformMergeAction(const std::string& account_id) { 364 void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
365 if (!switches::IsNewProfileManagement()) { 365 if (!switches::IsEnableAccountConsistency()) {
366 MarkAccountAsAddedToCookie(account_id); 366 MarkAccountAsAddedToCookie(account_id);
367 return; 367 return;
368 } 368 }
369 VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id; 369 VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id;
370 merge_session_helper_.LogIn(account_id); 370 merge_session_helper_.LogIn(account_id);
371 } 371 }
372 372
373 void AccountReconcilor::PerformStartRemoveAction( 373 void AccountReconcilor::PerformStartRemoveAction(
374 const std::string& account_id) { 374 const std::string& account_id) {
375 VLOG(1) << "AccountReconcilor::PerformStartRemoveAction: " << account_id; 375 VLOG(1) << "AccountReconcilor::PerformStartRemoveAction: " << account_id;
376 GetAccountsFromCookie(base::Bind( 376 GetAccountsFromCookie(base::Bind(
377 &AccountReconcilor::PerformFinishRemoveAction, 377 &AccountReconcilor::PerformFinishRemoveAction,
378 base::Unretained(this), 378 base::Unretained(this),
379 account_id)); 379 account_id));
380 } 380 }
381 381
382 void AccountReconcilor::PerformFinishRemoveAction( 382 void AccountReconcilor::PerformFinishRemoveAction(
383 const std::string& account_id, 383 const std::string& account_id,
384 const GoogleServiceAuthError& error, 384 const GoogleServiceAuthError& error,
385 const std::vector<std::pair<std::string, bool> >& accounts) { 385 const std::vector<std::pair<std::string, bool> >& accounts) {
386 if (!switches::IsNewProfileManagement()) 386 if (!switches::IsEnableAccountConsistency())
387 return; 387 return;
388 VLOG(1) << "AccountReconcilor::PerformFinishRemoveAction:" 388 VLOG(1) << "AccountReconcilor::PerformFinishRemoveAction:"
389 << " account=" << account_id << " error=" << error.ToString(); 389 << " account=" << account_id << " error=" << error.ToString();
390 if (error.state() == GoogleServiceAuthError::NONE) { 390 if (error.state() == GoogleServiceAuthError::NONE) {
391 AbortReconcile(); 391 AbortReconcile();
392 std::vector<std::string> accounts_only; 392 std::vector<std::string> accounts_only;
393 for (std::vector<std::pair<std::string, bool> >::const_iterator i = 393 for (std::vector<std::pair<std::string, bool> >::const_iterator i =
394 accounts.begin(); 394 accounts.begin();
395 i != accounts.end(); 395 i != accounts.end();
396 ++i) { 396 ++i) {
397 accounts_only.push_back(i->first); 397 accounts_only.push_back(i->first);
398 } 398 }
399 merge_session_helper_.LogOut(account_id, accounts_only); 399 merge_session_helper_.LogOut(account_id, accounts_only);
400 } 400 }
401 // Wait for the next ReconcileAction if there is an error. 401 // Wait for the next ReconcileAction if there is an error.
402 } 402 }
403 403
404 void AccountReconcilor::PerformAddToChromeAction( 404 void AccountReconcilor::PerformAddToChromeAction(
405 const std::string& account_id, 405 const std::string& account_id,
406 int session_index, 406 int session_index,
407 const std::string& signin_scoped_device_id) { 407 const std::string& signin_scoped_device_id) {
408 if (!switches::IsNewProfileManagement()) { 408 if (!switches::IsEnableAccountConsistency()) {
409 MarkAccountAsAddedToChrome(account_id); 409 MarkAccountAsAddedToChrome(account_id);
410 return; 410 return;
411 } 411 }
412 VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:" 412 VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:"
413 << " account=" << account_id << " session_index=" << session_index; 413 << " account=" << account_id << " session_index=" << session_index;
414 414
415 #if !defined(OS_ANDROID) && !defined(OS_IOS) 415 #if !defined(OS_ANDROID) && !defined(OS_IOS)
416 refresh_token_fetchers_.push_back(new RefreshTokenFetcher( 416 refresh_token_fetchers_.push_back(new RefreshTokenFetcher(
417 this, account_id, session_index, signin_scoped_device_id)); 417 this, account_id, session_index, signin_scoped_device_id));
418 #endif 418 #endif
419 } 419 }
420 420
421 void AccountReconcilor::PerformLogoutAllAccountsAction() { 421 void AccountReconcilor::PerformLogoutAllAccountsAction() {
422 if (!switches::IsNewProfileManagement()) 422 if (!switches::IsEnableAccountConsistency())
423 return; 423 return;
424 VLOG(1) << "AccountReconcilor::PerformLogoutAllAccountsAction"; 424 VLOG(1) << "AccountReconcilor::PerformLogoutAllAccountsAction";
425 merge_session_helper_.LogOutAllAccounts(); 425 merge_session_helper_.LogOutAllAccounts();
426 } 426 }
427 427
428 void AccountReconcilor::StartReconcile() { 428 void AccountReconcilor::StartReconcile() {
429 if (!IsProfileConnected() || is_reconcile_started_) 429 if (!IsProfileConnected() || is_reconcile_started_)
430 return; 430 return;
431 431
432 is_reconcile_started_ = true; 432 is_reconcile_started_ = true;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 const std::string& account_id) { 755 const std::string& account_id) {
756 invalid_chrome_accounts_.insert(account_id); 756 invalid_chrome_accounts_.insert(account_id);
757 FinishReconcile(); 757 FinishReconcile();
758 } 758 }
759 759
760 void AccountReconcilor::PerformAddAccountToTokenService( 760 void AccountReconcilor::PerformAddAccountToTokenService(
761 const std::string& account_id, 761 const std::string& account_id,
762 const std::string& refresh_token) { 762 const std::string& refresh_token) {
763 // The flow should never get to this method if new_profile_management is 763 // The flow should never get to this method if new_profile_management is
764 // false, but better safe than sorry. 764 // false, but better safe than sorry.
765 if (!switches::IsNewProfileManagement()) 765 if (!switches::IsEnableAccountConsistency())
766 return; 766 return;
767 token_service_->UpdateCredentials(account_id, refresh_token); 767 token_service_->UpdateCredentials(account_id, refresh_token);
768 } 768 }
769 769
770 // Remove the account from the list that is being updated. 770 // Remove the account from the list that is being updated.
771 void AccountReconcilor::MarkAccountAsAddedToChrome( 771 void AccountReconcilor::MarkAccountAsAddedToChrome(
772 const std::string& account_id) { 772 const std::string& account_id) {
773 for (std::vector<std::pair<std::string, int> >::iterator i = 773 for (std::vector<std::pair<std::string, int> >::iterator i =
774 add_to_chrome_.begin(); 774 add_to_chrome_.begin();
775 i != add_to_chrome_.end(); 775 i != add_to_chrome_.end();
776 ++i) { 776 ++i) {
777 if (gaia::AreEmailsSame(account_id, i->first)) { 777 if (gaia::AreEmailsSame(account_id, i->first)) {
778 add_to_chrome_.erase(i); 778 add_to_chrome_.erase(i);
779 break; 779 break;
780 } 780 }
781 } 781 }
782 } 782 }
783 783
784 void AccountReconcilor::HandleRefreshTokenFetched( 784 void AccountReconcilor::HandleRefreshTokenFetched(
785 const std::string& account_id, 785 const std::string& account_id,
786 const std::string& refresh_token) { 786 const std::string& refresh_token) {
787 if (!refresh_token.empty()) 787 if (!refresh_token.empty())
788 PerformAddAccountToTokenService(account_id, refresh_token); 788 PerformAddAccountToTokenService(account_id, refresh_token);
789 789
790 MarkAccountAsAddedToChrome(account_id); 790 MarkAccountAsAddedToChrome(account_id);
791 CalculateIfReconcileIsDone(); 791 CalculateIfReconcileIsDone();
792 } 792 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698