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

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

Issue 617183003: Make sure GetAuthenticatedAccountId() returns a canonicalized id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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/signin_manager.h" 5 #include "components/signin/core/browser/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 void SigninManager::RemoveMergeSessionObserver( 77 void SigninManager::RemoveMergeSessionObserver(
78 MergeSessionHelper::Observer* observer) { 78 MergeSessionHelper::Observer* observer) {
79 if (merge_session_helper_) 79 if (merge_session_helper_)
80 merge_session_helper_->RemoveObserver(observer); 80 merge_session_helper_->RemoveObserver(observer);
81 } 81 }
82 82
83 SigninManager::~SigninManager() {} 83 SigninManager::~SigninManager() {}
84 84
85 void SigninManager::InitTokenService() { 85 void SigninManager::InitTokenService() {
86 const std::string& account_id = GetAuthenticatedUsername(); 86 if (token_service_ && IsAuthenticated())
87 if (token_service_ && !account_id.empty()) 87 token_service_->LoadCredentials(GetAuthenticatedAccountId());
88 token_service_->LoadCredentials(account_id);
89 } 88 }
90 89
91 std::string SigninManager::SigninTypeToString(SigninManager::SigninType type) { 90 std::string SigninManager::SigninTypeToString(SigninManager::SigninType type) {
92 switch (type) { 91 switch (type) {
93 case SIGNIN_TYPE_NONE: 92 case SIGNIN_TYPE_NONE:
94 return "No Signin"; 93 return "No Signin";
95 case SIGNIN_TYPE_WITH_REFRESH_TOKEN: 94 case SIGNIN_TYPE_WITH_REFRESH_TOKEN:
96 return "Signin with refresh token"; 95 return "Signin with refresh token";
97 } 96 }
98 97
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return; 199 return;
201 } 200 }
202 201
203 ClearTransientSigninData(); 202 ClearTransientSigninData();
204 203
205 const std::string account_id = GetAuthenticatedAccountId(); 204 const std::string account_id = GetAuthenticatedAccountId();
206 const std::string username = GetAuthenticatedUsername(); 205 const std::string username = GetAuthenticatedUsername();
207 const base::Time signin_time = 206 const base::Time signin_time =
208 base::Time::FromInternalValue( 207 base::Time::FromInternalValue(
209 client_->GetPrefs()->GetInt64(prefs::kSignedInTime)); 208 client_->GetPrefs()->GetInt64(prefs::kSignedInTime));
210 clear_authenticated_username(); 209 ClearAuthenticatedUsername();
211 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesHostedDomain); 210 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesHostedDomain);
212 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 211 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
213 client_->GetPrefs()->ClearPref(prefs::kSignedInTime); 212 client_->GetPrefs()->ClearPref(prefs::kSignedInTime);
214 client_->OnSignedOut(); 213 client_->OnSignedOut();
215 214
216 // Erase (now) stale information from AboutSigninInternals. 215 // Erase (now) stale information from AboutSigninInternals.
217 NotifyDiagnosticsObservers(USERNAME, ""); 216 NotifyDiagnosticsObservers(USERNAME, "");
218 217
219 // Determine the duration the user was logged in and log that to UMA. 218 // Determine the duration the user was logged in and log that to UMA.
220 if (!signin_time.is_null()) { 219 if (!signin_time.is_null()) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 OnSignedIn(possibly_invalid_username_); 350 OnSignedIn(possibly_invalid_username_);
352 351
353 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) { 352 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) {
354 merge_session_helper_.reset(new MergeSessionHelper( 353 merge_session_helper_.reset(new MergeSessionHelper(
355 token_service_, GaiaConstants::kChromeSource, 354 token_service_, GaiaConstants::kChromeSource,
356 client_->GetURLRequestContext(), NULL)); 355 client_->GetURLRequestContext(), NULL));
357 } 356 }
358 357
359 DCHECK(!temp_refresh_token_.empty()); 358 DCHECK(!temp_refresh_token_.empty());
360 DCHECK(IsAuthenticated()); 359 DCHECK(IsAuthenticated());
361 token_service_->UpdateCredentials(GetAuthenticatedUsername(), 360 std::string account_id = GetAuthenticatedAccountId();
362 temp_refresh_token_); 361 token_service_->UpdateCredentials(account_id, temp_refresh_token_);
363 temp_refresh_token_.clear(); 362 temp_refresh_token_.clear();
364 363
365 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) 364 if (client_->ShouldMergeSigninCredentialsIntoCookieJar())
366 merge_session_helper_->LogIn(GetAuthenticatedUsername()); 365 merge_session_helper_->LogIn(account_id);
367 } 366 }
368 367
369 void SigninManager::OnExternalSigninCompleted(const std::string& username) { 368 void SigninManager::OnExternalSigninCompleted(const std::string& username) {
370 OnSignedIn(username); 369 OnSignedIn(username);
371 } 370 }
372 371
373 void SigninManager::OnSignedIn(const std::string& username) { 372 void SigninManager::OnSignedIn(const std::string& username) {
374 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, 373 client_->GetPrefs()->SetInt64(prefs::kSignedInTime,
375 base::Time::Now().ToInternalValue()); 374 base::Time::Now().ToInternalValue());
376 SetAuthenticatedUsername(username); 375 SetAuthenticatedUsername(username);
(...skipping 15 matching lines...) Expand all
392 391
393 password_.clear(); // Don't need it anymore. 392 password_.clear(); // Don't need it anymore.
394 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. 393 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again.
395 } 394 }
396 395
397 void SigninManager::ProhibitSignout(bool prohibit_signout) { 396 void SigninManager::ProhibitSignout(bool prohibit_signout) {
398 prohibit_signout_ = prohibit_signout; 397 prohibit_signout_ = prohibit_signout;
399 } 398 }
400 399
401 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } 400 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; }
OLDNEW
« no previous file with comments | « components/signin/core/browser/profile_oauth2_token_service.cc ('k') | components/signin/core/browser/signin_manager_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698