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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/signin/core/browser/account_tracker_service.cc
diff --git a/components/signin/core/browser/account_tracker_service.cc b/components/signin/core/browser/account_tracker_service.cc
index 714c452566dcc18180003a1669c087485f24b907..0b13386df96ccc9d849cb95c6e2e3cd0b564ef6b 100644
--- a/components/signin/core/browser/account_tracker_service.cc
+++ b/components/signin/core/browser/account_tracker_service.cc
@@ -5,6 +5,7 @@
#include "components/signin/core/browser/account_tracker_service.h"
#include "base/debug/trace_event.h"
+#include "base/logging.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/profiler/scoped_profile.h"
@@ -448,3 +449,42 @@ void AccountTrackerService::LoadFromTokenService() {
OnRefreshTokenAvailable(*it);
}
}
+
+std::string AccountTrackerService::PickAccountIdForAccount(
+ const std::string& gaia,
+ const std::string& email) {
+ return PickAccountIdForAccount(pref_service_, gaia, email);
+}
+
+// static
+std::string AccountTrackerService::PickAccountIdForAccount(
+ PrefService* pref_service,
+ const std::string& gaia,
+ const std::string& email) {
+ DCHECK(!gaia.empty());
+ DCHECK(!email.empty());
+ switch(GetMigrationState(pref_service)) {
+ case MIGRATION_NOT_STARTED:
+ case MIGRATION_IN_PROGRESS:
+ return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email));
+ case MIGRATION_DONE:
+ return gaia;
+ default:
+ NOTREACHED();
+ return email;
+ }
+}
+
+void AccountTrackerService::SeedAccountInfo(const std::string& gaia,
+ const std::string& email) {
+ DCHECK(!gaia.empty());
+ DCHECK(!email.empty());
+ const std::string account_id = PickAccountIdForAccount(gaia, email);
+ const bool already_exists = ContainsKey(accounts_, account_id);
+ StartTrackingAccount(account_id);
+ AccountState& state = accounts_[account_id];
+ DCHECK(!already_exists || state.info.gaia == gaia);
+ state.info.gaia = gaia;
+ state.info.email = email;
+ SaveToPrefs(state);
+}

Powered by Google App Engine
This is Rietveld 408576698