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

Side by Side Diff: components/signin/core/browser/signin_manager_base.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
« no previous file with comments | « components/signin/core/browser/signin_manager_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_base.h" 5 #include "components/signin/core/browser/signin_manager_base.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 23 matching lines...) Expand all
34 34
35 // If the user is clearing the token service from the command line, then 35 // If the user is clearing the token service from the command line, then
36 // clear their login info also (not valid to be logged in without any 36 // clear their login info also (not valid to be logged in without any
37 // tokens). 37 // tokens).
38 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 38 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
39 if (cmd_line->HasSwitch(switches::kClearTokenService)) 39 if (cmd_line->HasSwitch(switches::kClearTokenService))
40 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 40 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
41 41
42 std::string user = 42 std::string user =
43 client_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); 43 client_->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
44 if (!user.empty()) { 44 if (!user.empty())
45 #if defined(OS_IOS)
46 // Prior to M38, Chrome on iOS did not normalize the email before setting
47 // it in SigninManager. |AccountReconcilor| expects the authenticated email
48 // to be normalized as it used as an account identifier and is compared
49 // to the accounts available in the cookies.
50 user = gaia::CanonicalizeEmail(gaia::SanitizeEmail(user));
51 #endif
52 SetAuthenticatedUsername(user); 45 SetAuthenticatedUsername(user);
53 }
54 } 46 }
55 47
56 bool SigninManagerBase::IsInitialized() const { return initialized_; } 48 bool SigninManagerBase::IsInitialized() const { return initialized_; }
57 49
58 bool SigninManagerBase::IsSigninAllowed() const { 50 bool SigninManagerBase::IsSigninAllowed() const {
59 return client_->GetPrefs()->GetBoolean(prefs::kSigninAllowed); 51 return client_->GetPrefs()->GetBoolean(prefs::kSigninAllowed);
60 } 52 }
61 53
62 const std::string& SigninManagerBase::GetAuthenticatedUsername() const { 54 std::string SigninManagerBase::GetAuthenticatedUsername() const {
63 return authenticated_username_; 55 return authenticated_username_;
64 } 56 }
65 57
66 const std::string& SigninManagerBase::GetAuthenticatedAccountId() const { 58 std::string SigninManagerBase::GetAuthenticatedAccountId() const {
67 return GetAuthenticatedUsername(); 59 return IsAuthenticated()
60 ? gaia::CanonicalizeEmail(gaia::SanitizeEmail(GetAuthenticatedUsername()))
msarda 2014/10/01 15:57:26 I think this is potentially an expensive operation
Roger Tawa OOO till Jul 10th 2014/10/02 03:18:22 Added new member, but left api as is.
61 : std::string();
68 } 62 }
69 63
70 void SigninManagerBase::SetAuthenticatedUsername(const std::string& username) { 64 void SigninManagerBase::SetAuthenticatedUsername(const std::string& username) {
71 if (!authenticated_username_.empty()) { 65 if (!authenticated_username_.empty()) {
72 DLOG_IF(ERROR, !gaia::AreEmailsSame(username, authenticated_username_)) 66 DLOG_IF(ERROR, !gaia::AreEmailsSame(username, authenticated_username_))
73 << "Tried to change the authenticated username to something different: " 67 << "Tried to change the authenticated username to something different: "
74 << "Current: " << authenticated_username_ << ", New: " << username; 68 << "Current: " << authenticated_username_ << ", New: " << username;
75 69
76 #if defined(OS_IOS) 70 #if defined(OS_IOS)
77 // Prior to M26, chrome on iOS did not normalize the email before setting 71 // Prior to M26, chrome on iOS did not normalize the email before setting
(...skipping 20 matching lines...) Expand all
98 // user is signed in the two preferences should match. Doing it here as 92 // user is signed in the two preferences should match. Doing it here as
99 // opposed to on signin allows us to catch the upgrade scenario. 93 // opposed to on signin allows us to catch the upgrade scenario.
100 client_->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername, username); 94 client_->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername, username);
101 } 95 }
102 96
103 void SigninManagerBase::clear_authenticated_username() { 97 void SigninManagerBase::clear_authenticated_username() {
104 authenticated_username_.clear(); 98 authenticated_username_.clear();
105 } 99 }
106 100
107 bool SigninManagerBase::IsAuthenticated() const { 101 bool SigninManagerBase::IsAuthenticated() const {
108 return !GetAuthenticatedAccountId().empty(); 102 return !authenticated_username_.empty();
109 } 103 }
110 104
111 bool SigninManagerBase::AuthInProgress() const { 105 bool SigninManagerBase::AuthInProgress() const {
112 // SigninManagerBase never kicks off auth processes itself. 106 // SigninManagerBase never kicks off auth processes itself.
113 return false; 107 return false;
114 } 108 }
115 109
116 void SigninManagerBase::Shutdown() {} 110 void SigninManagerBase::Shutdown() {}
117 111
118 void SigninManagerBase::AddObserver(Observer* observer) { 112 void SigninManagerBase::AddObserver(Observer* observer) {
(...skipping 22 matching lines...) Expand all
141 NotifySigninValueChanged(field, value)); 135 NotifySigninValueChanged(field, value));
142 } 136 }
143 137
144 void SigninManagerBase::NotifyDiagnosticsObservers( 138 void SigninManagerBase::NotifyDiagnosticsObservers(
145 const TimedSigninStatusField& field, 139 const TimedSigninStatusField& field,
146 const std::string& value) { 140 const std::string& value) {
147 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 141 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
148 signin_diagnostics_observers_, 142 signin_diagnostics_observers_,
149 NotifySigninValueChanged(field, value)); 143 NotifySigninValueChanged(field, value));
150 } 144 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/signin_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698