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

Side by Side Diff: chrome/browser/signin/easy_unlock_service_regular.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 "chrome/browser/signin/easy_unlock_service_regular.h" 5 #include "chrome/browser/signin/easy_unlock_service_regular.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 weak_ptr_factory_(this) { 86 weak_ptr_factory_(this) {
87 } 87 }
88 88
89 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { 89 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() {
90 } 90 }
91 91
92 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { 92 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const {
93 return EasyUnlockService::TYPE_REGULAR; 93 return EasyUnlockService::TYPE_REGULAR;
94 } 94 }
95 95
96 std::string EasyUnlockServiceRegular::GetUserEmail() const { 96 user_manager::UserID EasyUnlockServiceRegular::GetUserID() const {
97 const SigninManagerBase* signin_manager = 97 return user_manager::UserID::FromUserEmail(GetUserEmail());
98 SigninManagerFactory::GetForProfileIfExists(profile());
99 // |profile| has to be a signed-in profile with SigninManager already
100 // created. Otherwise, just crash to collect stack.
101 DCHECK(signin_manager);
102 const std::string user_email = signin_manager->GetAuthenticatedUsername();
103 return user_email.empty() ? user_email : gaia::CanonicalizeEmail(user_email);
104 } 98 }
105 99
106 void EasyUnlockServiceRegular::LaunchSetup() { 100 void EasyUnlockServiceRegular::LaunchSetup() {
107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 101 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
108 #if defined(OS_CHROMEOS) 102 #if defined(OS_CHROMEOS)
109 // Force the user to reauthenticate by showing a modal overlay (similar to the 103 // Force the user to reauthenticate by showing a modal overlay (similar to the
110 // lock screen). The password obtained from the reauth is cached for a short 104 // lock screen). The password obtained from the reauth is cached for a short
111 // period of time and used to create the cryptohome keys for sign-in. 105 // period of time and used to create the cryptohome keys for sign-in.
112 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { 106 if (short_lived_user_context_ && short_lived_user_context_->user_context()) {
113 OpenSetupApp(); 107 OpenSetupApp();
(...skipping 30 matching lines...) Expand all
144 base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation, 138 base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation,
145 weak_ptr_factory_.GetWeakPtr(), 139 weak_ptr_factory_.GetWeakPtr(),
146 EasyUnlockScreenlockStateHandler::NO_PAIRING)); 140 EasyUnlockScreenlockStateHandler::NO_PAIRING));
147 } 141 }
148 } 142 }
149 143
150 void EasyUnlockServiceRegular::SetHardlockAfterKeyOperation( 144 void EasyUnlockServiceRegular::SetHardlockAfterKeyOperation(
151 EasyUnlockScreenlockStateHandler::HardlockState state_on_success, 145 EasyUnlockScreenlockStateHandler::HardlockState state_on_success,
152 bool success) { 146 bool success) {
153 if (success) 147 if (success)
154 SetHardlockStateForUser(GetUserEmail(), state_on_success); 148 SetHardlockStateForUser(GetUserID(), state_on_success);
155 149
156 // Even if the refresh keys operation suceeded, we still fetch and check the 150 // Even if the refresh keys operation suceeded, we still fetch and check the
157 // cryptohome keys against the keys in local preferences as a sanity check. 151 // cryptohome keys against the keys in local preferences as a sanity check.
158 CheckCryptohomeKeysAndMaybeHardlock(); 152 CheckCryptohomeKeysAndMaybeHardlock();
159 } 153 }
160 #endif 154 #endif
161 155
162 const base::DictionaryValue* EasyUnlockServiceRegular::GetPermitAccess() const { 156 const base::DictionaryValue* EasyUnlockServiceRegular::GetPermitAccess() const {
163 const base::DictionaryValue* pairing_dict = 157 const base::DictionaryValue* pairing_dict =
164 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing); 158 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 254
261 std::string EasyUnlockServiceRegular::GetChallenge() const { 255 std::string EasyUnlockServiceRegular::GetChallenge() const {
262 return std::string(); 256 return std::string();
263 } 257 }
264 258
265 std::string EasyUnlockServiceRegular::GetWrappedSecret() const { 259 std::string EasyUnlockServiceRegular::GetWrappedSecret() const {
266 return std::string(); 260 return std::string();
267 } 261 }
268 262
269 void EasyUnlockServiceRegular::RecordEasySignInOutcome( 263 void EasyUnlockServiceRegular::RecordEasySignInOutcome(
270 const std::string& user_id, 264 const user_manager::UserID& user_id,
271 bool success) const { 265 bool success) const {
272 NOTREACHED(); 266 NOTREACHED();
273 } 267 }
274 268
275 void EasyUnlockServiceRegular::RecordPasswordLoginEvent( 269 void EasyUnlockServiceRegular::RecordPasswordLoginEvent(
276 const std::string& user_id) const { 270 const user_manager::UserID& user_id) const {
277 NOTREACHED(); 271 NOTREACHED();
278 } 272 }
279 273
280 void EasyUnlockServiceRegular::StartAutoPairing( 274 void EasyUnlockServiceRegular::StartAutoPairing(
281 const AutoPairingResultCallback& callback) { 275 const AutoPairingResultCallback& callback) {
282 if (!auto_pairing_callback_.is_null()) { 276 if (!auto_pairing_callback_.is_null()) {
283 LOG(ERROR) 277 LOG(ERROR)
284 << "Start auto pairing when there is another auto pairing requested."; 278 << "Start auto pairing when there is another auto pairing requested.";
285 callback.Run(false, std::string()); 279 callback.Run(false, std::string());
286 return; 280 return;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (will_unlock_using_easy_unlock_) { 379 if (will_unlock_using_easy_unlock_) {
386 RecordEasyUnlockScreenUnlockDuration( 380 RecordEasyUnlockScreenUnlockDuration(
387 base::TimeTicks::Now() - lock_screen_last_shown_timestamp_); 381 base::TimeTicks::Now() - lock_screen_last_shown_timestamp_);
388 } 382 }
389 } 383 }
390 384
391 will_unlock_using_easy_unlock_ = false; 385 will_unlock_using_easy_unlock_ = false;
392 } 386 }
393 387
394 void EasyUnlockServiceRegular::OnFocusedUserChanged( 388 void EasyUnlockServiceRegular::OnFocusedUserChanged(
395 const std::string& user_id) { 389 const user_manager::UserID& user_id) {
396 // Nothing to do. 390 // Nothing to do.
397 } 391 }
398 392
393 std::string EasyUnlockServiceRegular::GetUserEmail() const {
394 const SigninManagerBase* signin_manager =
395 SigninManagerFactory::GetForProfileIfExists(profile());
396 // |profile| has to be a signed-in profile with SigninManager already
397 // created. Otherwise, just crash to collect stack.
398 DCHECK(signin_manager);
399 const std::string user_email = signin_manager->GetAuthenticatedUsername();
400 return user_email.empty() ? user_email : gaia::CanonicalizeEmail(user_email);
401 }
402
399 void EasyUnlockServiceRegular::OnPrefsChanged() { 403 void EasyUnlockServiceRegular::OnPrefsChanged() {
400 SyncProfilePrefsToLocalState(); 404 SyncProfilePrefsToLocalState();
401 UpdateAppState(); 405 UpdateAppState();
402 } 406 }
403 407
404 void EasyUnlockServiceRegular::SetTurnOffFlowStatus(TurnOffFlowStatus status) { 408 void EasyUnlockServiceRegular::SetTurnOffFlowStatus(TurnOffFlowStatus status) {
405 turn_off_flow_status_ = status; 409 turn_off_flow_status_ = status;
406 NotifyTurnOffOperationStatusChanged(); 410 NotifyTurnOffOperationStatusChanged();
407 } 411 }
408 412
(...skipping 25 matching lines...) Expand all
434 new base::DictionaryValue()); 438 new base::DictionaryValue());
435 user_prefs_dict->SetBooleanWithoutPathExpansion( 439 user_prefs_dict->SetBooleanWithoutPathExpansion(
436 prefs::kEasyUnlockProximityRequired, 440 prefs::kEasyUnlockProximityRequired,
437 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); 441 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired));
438 442
439 DictionaryPrefUpdate update(local_state, 443 DictionaryPrefUpdate update(local_state,
440 prefs::kEasyUnlockLocalStateUserPrefs); 444 prefs::kEasyUnlockLocalStateUserPrefs);
441 std::string user_email = GetUserEmail(); 445 std::string user_email = GetUserEmail();
442 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); 446 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass());
443 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698