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

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: 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 OnSignedIn(possibly_invalid_username_); 349 OnSignedIn(possibly_invalid_username_);
351 350
352 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) { 351 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) {
353 merge_session_helper_.reset(new MergeSessionHelper( 352 merge_session_helper_.reset(new MergeSessionHelper(
354 token_service_, GaiaConstants::kChromeSource, 353 token_service_, GaiaConstants::kChromeSource,
355 client_->GetURLRequestContext(), NULL)); 354 client_->GetURLRequestContext(), NULL));
356 } 355 }
357 356
358 DCHECK(!temp_refresh_token_.empty()); 357 DCHECK(!temp_refresh_token_.empty());
359 DCHECK(IsAuthenticated()); 358 DCHECK(IsAuthenticated());
360 token_service_->UpdateCredentials(GetAuthenticatedUsername(), 359 std::string account_id = GetAuthenticatedAccountId();
361 temp_refresh_token_); 360 token_service_->UpdateCredentials(account_id, temp_refresh_token_);
362 temp_refresh_token_.clear(); 361 temp_refresh_token_.clear();
363 362
364 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) 363 if (client_->ShouldMergeSigninCredentialsIntoCookieJar())
365 merge_session_helper_->LogIn(GetAuthenticatedUsername()); 364 merge_session_helper_->LogIn(account_id);
366 } 365 }
367 366
368 void SigninManager::OnExternalSigninCompleted(const std::string& username) { 367 void SigninManager::OnExternalSigninCompleted(const std::string& username) {
369 OnSignedIn(username); 368 OnSignedIn(username);
370 } 369 }
371 370
372 void SigninManager::OnSignedIn(const std::string& username) { 371 void SigninManager::OnSignedIn(const std::string& username) {
373 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, 372 client_->GetPrefs()->SetInt64(prefs::kSignedInTime,
374 base::Time::Now().ToInternalValue()); 373 base::Time::Now().ToInternalValue());
375 SetAuthenticatedUsername(username); 374 SetAuthenticatedUsername(username);
(...skipping 15 matching lines...) Expand all
391 390
392 password_.clear(); // Don't need it anymore. 391 password_.clear(); // Don't need it anymore.
393 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. 392 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again.
394 } 393 }
395 394
396 void SigninManager::ProhibitSignout(bool prohibit_signout) { 395 void SigninManager::ProhibitSignout(bool prohibit_signout) {
397 prohibit_signout_ = prohibit_signout; 396 prohibit_signout_ = prohibit_signout;
398 } 397 }
399 398
400 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } 399 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698