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

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

Issue 473153002: 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: rebased Created 6 years, 2 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_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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 } 436 }
437 437
438 void AccountTrackerService::LoadFromTokenService() { 438 void AccountTrackerService::LoadFromTokenService() {
439 std::vector<std::string> accounts = token_service_->GetAccounts(); 439 std::vector<std::string> accounts = token_service_->GetAccounts();
440 for (std::vector<std::string>::const_iterator it = accounts.begin(); 440 for (std::vector<std::string>::const_iterator it = accounts.begin();
441 it != accounts.end(); ++it) { 441 it != accounts.end(); ++it) {
442 OnRefreshTokenAvailable(*it); 442 OnRefreshTokenAvailable(*it);
443 } 443 }
444 } 444 }
445
446 std::string AccountTrackerService::PickAccountIdForAccount(
447 const std::string& gaia,
448 const std::string& email) {
449 return PickAccountIdForAccount(pref_service_, gaia, email);
450 }
451
452 // static
453 std::string AccountTrackerService::PickAccountIdForAccount(
454 PrefService* pref_service,
455 const std::string& gaia,
456 const std::string& email) {
457 DCHECK(!gaia.empty());
bartfab (slow) 2014/10/14 17:12:38 Nit: #include "base/logging.h"
Roger Tawa OOO till Jul 10th 2014/10/16 02:39:32 Done.
458 DCHECK(!email.empty());
459 switch(GetMigrationState(pref_service)) {
460 case MIGRATION_NOT_STARTED:
461 case MIGRATION_IN_PROGRESS:
462 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email));
463 case MIGRATION_DONE:
464 return gaia;
465 default:
466 NOTREACHED();
467 return email;
468 }
469 }
470
471 void AccountTrackerService::SeedAccountInfo(const std::string& gaia,
472 const std::string& email) {
473 DCHECK(!gaia.empty());
474 DCHECK(!email.empty());
475 const std::string account_id = PickAccountIdForAccount(gaia, email);
476 bool already_exists = ContainsKey(accounts_, account_id);
bartfab (slow) 2014/10/14 17:12:38 Nit: const.
Roger Tawa OOO till Jul 10th 2014/10/16 02:39:32 Done.
477 StartTrackingAccount(account_id);
478 AccountState& state = accounts_[account_id];
479 DCHECK(!already_exists || state.info.gaia == gaia);
480 state.info.gaia = gaia;
481 state.info.email = email;
482 SaveToPrefs(state);
483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698