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

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: Fix one unit test, progress on second 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/logging.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "components/signin/core/browser/signin_manager.h" 12 #include "components/signin/core/browser/signin_manager.h"
12 #include "components/signin/core/common/signin_pref_names.h" 13 #include "components/signin/core/common/signin_pref_names.h"
13 #include "google_apis/gaia/gaia_auth_util.h" 14 #include "google_apis/gaia/gaia_auth_util.h"
14 #include "google_apis/gaia/gaia_constants.h" 15 #include "google_apis/gaia/gaia_constants.h"
15 #include "google_apis/gaia/gaia_oauth_client.h" 16 #include "google_apis/gaia/gaia_oauth_client.h"
16 #include "google_apis/gaia/oauth2_token_service.h" 17 #include "google_apis/gaia/oauth2_token_service.h"
17 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 436 }
436 } 437 }
437 438
438 void AccountTrackerService::LoadFromTokenService() { 439 void AccountTrackerService::LoadFromTokenService() {
439 std::vector<std::string> accounts = token_service_->GetAccounts(); 440 std::vector<std::string> accounts = token_service_->GetAccounts();
440 for (std::vector<std::string>::const_iterator it = accounts.begin(); 441 for (std::vector<std::string>::const_iterator it = accounts.begin();
441 it != accounts.end(); ++it) { 442 it != accounts.end(); ++it) {
442 OnRefreshTokenAvailable(*it); 443 OnRefreshTokenAvailable(*it);
443 } 444 }
444 } 445 }
446
447 std::string AccountTrackerService::PickAccountIdForAccount(
448 const std::string& gaia,
449 const std::string& email) {
450 return PickAccountIdForAccount(pref_service_, gaia, email);
451 }
452
453 // static
454 std::string AccountTrackerService::PickAccountIdForAccount(
455 PrefService* pref_service,
456 const std::string& gaia,
457 const std::string& email) {
458 DCHECK(!gaia.empty());
459 DCHECK(!email.empty());
460 switch(GetMigrationState(pref_service)) {
461 case MIGRATION_NOT_STARTED:
462 case MIGRATION_IN_PROGRESS:
463 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email));
464 case MIGRATION_DONE:
465 return gaia;
466 default:
467 NOTREACHED();
468 return email;
469 }
470 }
471
472 void AccountTrackerService::SeedAccountInfo(const std::string& gaia,
473 const std::string& email) {
474 DCHECK(!gaia.empty());
475 DCHECK(!email.empty());
476 const std::string account_id = PickAccountIdForAccount(gaia, email);
477 const bool already_exists = ContainsKey(accounts_, account_id);
478 StartTrackingAccount(account_id);
479 AccountState& state = accounts_[account_id];
480 DCHECK(!already_exists || state.info.gaia == gaia);
481 state.info.gaia = gaia;
482 state.info.email = email;
483 SaveToPrefs(state);
484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698