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

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

Issue 671183002: Revert of Inline sign in extracts gaia id from HTTP header and seeds account tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | 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_tracker_service.h" 5 #include "components/signin/core/browser/account_tracker_service.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
11 #include "base/profiler/scoped_profile.h" 10 #include "base/profiler/scoped_profile.h"
12 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
13 #include "components/signin/core/browser/signin_manager.h" 12 #include "components/signin/core/browser/signin_manager.h"
14 #include "components/signin/core/common/signin_pref_names.h" 13 #include "components/signin/core/common/signin_pref_names.h"
15 #include "google_apis/gaia/gaia_auth_util.h" 14 #include "google_apis/gaia/gaia_auth_util.h"
16 #include "google_apis/gaia/gaia_constants.h" 15 #include "google_apis/gaia/gaia_constants.h"
17 #include "google_apis/gaia/gaia_oauth_client.h" 16 #include "google_apis/gaia/gaia_oauth_client.h"
18 #include "google_apis/gaia/oauth2_token_service.h" 17 #include "google_apis/gaia/oauth2_token_service.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 441 }
443 } 442 }
444 443
445 void AccountTrackerService::LoadFromTokenService() { 444 void AccountTrackerService::LoadFromTokenService() {
446 std::vector<std::string> accounts = token_service_->GetAccounts(); 445 std::vector<std::string> accounts = token_service_->GetAccounts();
447 for (std::vector<std::string>::const_iterator it = accounts.begin(); 446 for (std::vector<std::string>::const_iterator it = accounts.begin();
448 it != accounts.end(); ++it) { 447 it != accounts.end(); ++it) {
449 OnRefreshTokenAvailable(*it); 448 OnRefreshTokenAvailable(*it);
450 } 449 }
451 } 450 }
452
453 std::string AccountTrackerService::PickAccountIdForAccount(
454 const std::string& gaia,
455 const std::string& email) {
456 return PickAccountIdForAccount(pref_service_, gaia, email);
457 }
458
459 // static
460 std::string AccountTrackerService::PickAccountIdForAccount(
461 PrefService* pref_service,
462 const std::string& gaia,
463 const std::string& email) {
464 DCHECK(!gaia.empty());
465 DCHECK(!email.empty());
466 switch(GetMigrationState(pref_service)) {
467 case MIGRATION_NOT_STARTED:
468 case MIGRATION_IN_PROGRESS:
469 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email));
470 case MIGRATION_DONE:
471 return gaia;
472 default:
473 NOTREACHED();
474 return email;
475 }
476 }
477
478 void AccountTrackerService::SeedAccountInfo(const std::string& gaia,
479 const std::string& email) {
480 DCHECK(!gaia.empty());
481 DCHECK(!email.empty());
482 const std::string account_id = PickAccountIdForAccount(gaia, email);
483 const bool already_exists = ContainsKey(accounts_, account_id);
484 StartTrackingAccount(account_id);
485 AccountState& state = accounts_[account_id];
486 DCHECK(!already_exists || state.info.gaia == gaia);
487 state.info.gaia = gaia;
488 state.info.email = email;
489 SaveToPrefs(state);
490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698