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

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

Issue 1494153002: This CL replaces e-mail with AccountId in easy signin code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years 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/base64url.h" 7 #include "base/base64url.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // TODO(tengs): Rename this function after the easy_unlock app is replaced. 149 // TODO(tengs): Rename this function after the easy_unlock app is replaced.
150 SetRemoteDevices(*device_list); 150 SetRemoteDevices(*device_list);
151 #endif 151 #endif
152 } 152 }
153 153
154 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { 154 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const {
155 return EasyUnlockService::TYPE_REGULAR; 155 return EasyUnlockService::TYPE_REGULAR;
156 } 156 }
157 157
158 std::string EasyUnlockServiceRegular::GetUserEmail() const { 158 AccountId EasyUnlockServiceRegular::GetAccountId() const {
159 const SigninManagerBase* signin_manager = 159 const SigninManagerBase* signin_manager =
160 SigninManagerFactory::GetForProfileIfExists(profile()); 160 SigninManagerFactory::GetForProfileIfExists(profile());
161 // |profile| has to be a signed-in profile with SigninManager already 161 // |profile| has to be a signed-in profile with SigninManager already
162 // created. Otherwise, just crash to collect stack. 162 // created. Otherwise, just crash to collect stack.
163 DCHECK(signin_manager); 163 DCHECK(signin_manager);
164 const std::string user_email = 164 const std::string user_email =
165 signin_manager->GetAuthenticatedAccountInfo().email; 165 signin_manager->GetAuthenticatedAccountInfo().email;
166 return user_email.empty() ? user_email : gaia::CanonicalizeEmail(user_email); 166 return user_email.empty()
167 ? EmptyAccountId()
168 : AccountId::FromUserEmail(gaia::CanonicalizeEmail(user_email));
167 } 169 }
168 170
169 void EasyUnlockServiceRegular::LaunchSetup() { 171 void EasyUnlockServiceRegular::LaunchSetup() {
170 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
171 #if defined(OS_CHROMEOS) 173 #if defined(OS_CHROMEOS)
172 // Force the user to reauthenticate by showing a modal overlay (similar to the 174 // Force the user to reauthenticate by showing a modal overlay (similar to the
173 // lock screen). The password obtained from the reauth is cached for a short 175 // lock screen). The password obtained from the reauth is cached for a short
174 // period of time and used to create the cryptohome keys for sign-in. 176 // period of time and used to create the cryptohome keys for sign-in.
175 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { 177 if (short_lived_user_context_ && short_lived_user_context_->user_context()) {
176 OpenSetupApp(); 178 OpenSetupApp();
(...skipping 30 matching lines...) Expand all
207 base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation, 209 base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation,
208 weak_ptr_factory_.GetWeakPtr(), 210 weak_ptr_factory_.GetWeakPtr(),
209 EasyUnlockScreenlockStateHandler::NO_PAIRING)); 211 EasyUnlockScreenlockStateHandler::NO_PAIRING));
210 } 212 }
211 } 213 }
212 214
213 void EasyUnlockServiceRegular::SetHardlockAfterKeyOperation( 215 void EasyUnlockServiceRegular::SetHardlockAfterKeyOperation(
214 EasyUnlockScreenlockStateHandler::HardlockState state_on_success, 216 EasyUnlockScreenlockStateHandler::HardlockState state_on_success,
215 bool success) { 217 bool success) {
216 if (success) 218 if (success)
217 SetHardlockStateForUser(GetUserEmail(), state_on_success); 219 SetHardlockStateForUser(GetAccountId(), state_on_success);
218 220
219 // Even if the refresh keys operation suceeded, we still fetch and check the 221 // Even if the refresh keys operation suceeded, we still fetch and check the
220 // cryptohome keys against the keys in local preferences as a sanity check. 222 // cryptohome keys against the keys in local preferences as a sanity check.
221 CheckCryptohomeKeysAndMaybeHardlock(); 223 CheckCryptohomeKeysAndMaybeHardlock();
222 } 224 }
223 #endif 225 #endif
224 226
225 const base::DictionaryValue* EasyUnlockServiceRegular::GetPermitAccess() const { 227 const base::DictionaryValue* EasyUnlockServiceRegular::GetPermitAccess() const {
226 const base::DictionaryValue* pairing_dict = 228 const base::DictionaryValue* pairing_dict =
227 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing); 229 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 366
365 std::string EasyUnlockServiceRegular::GetChallenge() const { 367 std::string EasyUnlockServiceRegular::GetChallenge() const {
366 return std::string(); 368 return std::string();
367 } 369 }
368 370
369 std::string EasyUnlockServiceRegular::GetWrappedSecret() const { 371 std::string EasyUnlockServiceRegular::GetWrappedSecret() const {
370 return std::string(); 372 return std::string();
371 } 373 }
372 374
373 void EasyUnlockServiceRegular::RecordEasySignInOutcome( 375 void EasyUnlockServiceRegular::RecordEasySignInOutcome(
374 const std::string& user_id, 376 const AccountId& account_id,
375 bool success) const { 377 bool success) const {
376 NOTREACHED(); 378 NOTREACHED();
377 } 379 }
378 380
379 void EasyUnlockServiceRegular::RecordPasswordLoginEvent( 381 void EasyUnlockServiceRegular::RecordPasswordLoginEvent(
380 const std::string& user_id) const { 382 const AccountId& account_id) const {
381 NOTREACHED(); 383 NOTREACHED();
382 } 384 }
383 385
384 void EasyUnlockServiceRegular::StartAutoPairing( 386 void EasyUnlockServiceRegular::StartAutoPairing(
385 const AutoPairingResultCallback& callback) { 387 const AutoPairingResultCallback& callback) {
386 if (!auto_pairing_callback_.is_null()) { 388 if (!auto_pairing_callback_.is_null()) {
387 LOG(ERROR) 389 LOG(ERROR)
388 << "Start auto pairing when there is another auto pairing requested."; 390 << "Start auto pairing when there is another auto pairing requested.";
389 callback.Run(false, std::string()); 391 callback.Run(false, std::string());
390 return; 392 return;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // If we synced remote devices while the screen was locked, we can now load 540 // If we synced remote devices while the screen was locked, we can now load
539 // the new remote devices. 541 // the new remote devices.
540 if (deferring_device_load_) { 542 if (deferring_device_load_) {
541 PA_LOG(INFO) << "Loading deferred devices after screen unlock."; 543 PA_LOG(INFO) << "Loading deferred devices after screen unlock.";
542 deferring_device_load_ = false; 544 deferring_device_load_ = false;
543 LoadRemoteDevices(); 545 LoadRemoteDevices();
544 } 546 }
545 } 547 }
546 548
547 void EasyUnlockServiceRegular::OnFocusedUserChanged( 549 void EasyUnlockServiceRegular::OnFocusedUserChanged(
548 const std::string& user_id) { 550 const AccountId& account_id) {
549 // Nothing to do. 551 // Nothing to do.
550 } 552 }
551 553
552 void EasyUnlockServiceRegular::OnPrefsChanged() { 554 void EasyUnlockServiceRegular::OnPrefsChanged() {
553 SyncProfilePrefsToLocalState(); 555 SyncProfilePrefsToLocalState();
554 UpdateAppState(); 556 UpdateAppState();
555 } 557 }
556 558
557 void EasyUnlockServiceRegular::SetTurnOffFlowStatus(TurnOffFlowStatus status) { 559 void EasyUnlockServiceRegular::SetTurnOffFlowStatus(TurnOffFlowStatus status) {
558 turn_off_flow_status_ = status; 560 turn_off_flow_status_ = status;
(...skipping 25 matching lines...) Expand all
584 // Create the dictionary of Easy Unlock preferences for the current user. The 586 // Create the dictionary of Easy Unlock preferences for the current user. The
585 // items in the dictionary are the same profile prefs used for Easy Unlock. 587 // items in the dictionary are the same profile prefs used for Easy Unlock.
586 scoped_ptr<base::DictionaryValue> user_prefs_dict( 588 scoped_ptr<base::DictionaryValue> user_prefs_dict(
587 new base::DictionaryValue()); 589 new base::DictionaryValue());
588 user_prefs_dict->SetBooleanWithoutPathExpansion( 590 user_prefs_dict->SetBooleanWithoutPathExpansion(
589 prefs::kEasyUnlockProximityRequired, 591 prefs::kEasyUnlockProximityRequired,
590 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); 592 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired));
591 593
592 DictionaryPrefUpdate update(local_state, 594 DictionaryPrefUpdate update(local_state,
593 prefs::kEasyUnlockLocalStateUserPrefs); 595 prefs::kEasyUnlockLocalStateUserPrefs);
594 std::string user_email = GetUserEmail(); 596 update->SetWithoutPathExpansion(GetAccountId().GetUserEmail(),
595 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); 597 user_prefs_dict.Pass());
596 } 598 }
597 599
598 cryptauth::GcmDeviceInfo EasyUnlockServiceRegular::GetGcmDeviceInfo() { 600 cryptauth::GcmDeviceInfo EasyUnlockServiceRegular::GetGcmDeviceInfo() {
599 cryptauth::GcmDeviceInfo device_info; 601 cryptauth::GcmDeviceInfo device_info;
600 device_info.set_long_device_id(EasyUnlockService::GetDeviceId()); 602 device_info.set_long_device_id(EasyUnlockService::GetDeviceId());
601 device_info.set_device_type(cryptauth::CHROME); 603 device_info.set_device_type(cryptauth::CHROME);
602 device_info.set_device_software_version(version_info::GetVersionNumber()); 604 device_info.set_device_software_version(version_info::GetVersionNumber());
603 google::protobuf::int64 software_version_code = 605 google::protobuf::int64 software_version_code =
604 proximity_auth::HashStringToInt64(version_info::GetLastChange()); 606 proximity_auth::HashStringToInt64(version_info::GetLastChange());
605 device_info.set_device_software_version_code(software_version_code); 607 device_info.set_device_software_version_code(software_version_code);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 PA_LOG(INFO) << "Refresh token not yet available, " 674 PA_LOG(INFO) << "Refresh token not yet available, "
673 << "waiting before starting CryptAuth managers"; 675 << "waiting before starting CryptAuth managers";
674 token_service->AddObserver(this); 676 token_service->AddObserver(this);
675 } 677 }
676 678
677 device_manager_->AddObserver(this); 679 device_manager_->AddObserver(this);
678 enrollment_manager_->Start(); 680 enrollment_manager_->Start();
679 device_manager_->Start(); 681 device_manager_->Start();
680 } 682 }
681 #endif 683 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698