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

Unified Diff: chrome/browser/signin/easy_unlock_service_regular.cc

Issue 789793005: Revert of Clean up Smart Lock cryptohome keys logic: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/easy_unlock_service_regular.cc
diff --git a/chrome/browser/signin/easy_unlock_service_regular.cc b/chrome/browser/signin/easy_unlock_service_regular.cc
index c4b72c7236baf41990f9eb8bee61cbff7fa98c79..d1d7c03a22f4f3d7d798b7638ecb1126b06e12bc 100644
--- a/chrome/browser/signin/easy_unlock_service_regular.cc
+++ b/chrome/browser/signin/easy_unlock_service_regular.cc
@@ -91,29 +91,19 @@
base::ThreadTaskRunnerHandle::Get().get()));
OpenSetupApp();
-
- // Use this opportunity to clear the crytohome keys if it was not already
- // cleared earlier.
- const base::ListValue* devices = GetRemoteDevices();
- if (!devices || devices->empty()) {
- chromeos::EasyUnlockKeyManager* key_manager =
- chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
- key_manager->RefreshKeys(
- user_context, base::ListValue(),
- base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation,
- weak_ptr_factory_.GetWeakPtr(),
- EasyUnlockScreenlockStateHandler::NO_PAIRING));
- }
-}
-
-void EasyUnlockServiceRegular::SetHardlockAfterKeyOperation(
- EasyUnlockScreenlockStateHandler::HardlockState state_on_success,
- bool success) {
- if (success)
- SetHardlockStateForUser(GetUserEmail(), state_on_success);
-
- // Even if the refresh keys operation suceeded, we still fetch and check the
- // cryptohome keys against the keys in local preferences as a sanity check.
+}
+
+void EasyUnlockServiceRegular::OnKeysRefreshedForSetDevices(bool success) {
+ // If the keys were refreshed successfully, the hardlock state should be
+ // cleared, so Smart Lock can be used normally. Otherwise, we fall back to
+ // a hardlock state to force the user to type in their credentials again.
+ if (success) {
+ SetHardlockStateForUser(GetUserEmail(),
+ EasyUnlockScreenlockStateHandler::NO_HARDLOCK);
+ }
+
+ // Even if the keys refresh suceeded, we still fetch the cryptohome keys as a
+ // sanity check.
CheckCryptohomeKeysAndMaybeHardlock();
}
#endif
@@ -167,30 +157,34 @@
const base::ListValue& devices) {
DictionaryPrefUpdate pairing_update(profile()->GetPrefs(),
prefs::kEasyUnlockPairing);
- if (devices.empty())
- pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL);
- else
- pairing_update->SetWithoutPathExpansion(kKeyDevices, devices.DeepCopy());
+ pairing_update->SetWithoutPathExpansion(kKeyDevices, devices.DeepCopy());
#if defined(OS_CHROMEOS)
// TODO(tengs): Investigate if we can determine if the remote devices were set
// from sync or from the setup app.
- if (short_lived_user_context_ && short_lived_user_context_->user_context()) {
+ if (short_lived_user_context_ && short_lived_user_context_->user_context() &&
+ !devices.empty()) {
// We may already have the password cached, so proceed to create the
// cryptohome keys for sign-in or the system will be hardlocked.
- chromeos::UserSessionManager::GetInstance()
- ->GetEasyUnlockKeyManager()
+ chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager()
->RefreshKeys(
- *short_lived_user_context_->user_context(), devices,
- base::Bind(&EasyUnlockServiceRegular::SetHardlockAfterKeyOperation,
- weak_ptr_factory_.GetWeakPtr(),
- EasyUnlockScreenlockStateHandler::NO_HARDLOCK));
+ *short_lived_user_context_->user_context(),
+ devices,
+ base::Bind(&EasyUnlockServiceRegular::OnKeysRefreshedForSetDevices,
+ weak_ptr_factory_.GetWeakPtr()));
} else {
CheckCryptohomeKeysAndMaybeHardlock();
}
#else
CheckCryptohomeKeysAndMaybeHardlock();
#endif
+}
+
+void EasyUnlockServiceRegular::ClearRemoteDevices() {
+ DictionaryPrefUpdate pairing_update(profile()->GetPrefs(),
+ prefs::kEasyUnlockPairing);
+ pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL);
+ CheckCryptohomeKeysAndMaybeHardlock();
}
void EasyUnlockServiceRegular::RunTurnOffFlow() {
@@ -308,7 +302,7 @@
return;
}
- SetRemoteDevices(base::ListValue());
+ ClearRemoteDevices();
SetTurnOffFlowStatus(IDLE);
ReloadApp();
}
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.h ('k') | chrome/browser/signin/easy_unlock_service_signin_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698