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

Unified Diff: chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc

Issue 2838303003: cros: Remove user directory when encryption migration fails. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
index 2b69ed620a86f90b23bb89abef5a7770b4f447da..39017def4b8a6f36eb02b04a814d9b3df4f7e2fd 100644
--- a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
+#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/cryptohome/homedir_methods.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -312,6 +313,22 @@ void EncryptionMigrationScreenHandler::StopBlockingPowerSave() {
}
}
+void EncryptionMigrationScreenHandler::RemoveCryptohome() {
+ cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove(
fukino 2017/04/26 11:01:43 Instead of calling AsyncRemove directly, we should
xiyuan 2017/04/26 17:48:24 Agree that we should not use RemoveUser(). We can
fukino 2017/04/27 01:38:23 Thank you for the suggestion! Updated the CL to in
+ cryptohome::Identification(user_context_.GetAccountId()),
+ base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void EncryptionMigrationScreenHandler::OnRemoveCryptohome(
+ bool success,
+ cryptohome::MountError return_code) {
+ if (!success)
+ LOG(ERROR) << "Removing cryptohome failed. return code: " << return_code;
xiyuan 2017/04/26 17:48:24 nit: LOG_IF(ERROR, !success) << ....
fukino 2017/04/27 01:38:23 Done.
+
+ UpdateUIState(UIState::MIGRATION_FAILED);
+}
+
cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() {
// |auth_key| is created in the same manner as CryptohomeAuthenticator.
const Key* key = user_context_.GetKey();
@@ -344,12 +361,13 @@ void EncryptionMigrationScreenHandler::OnMigrationProgress(
DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
break;
case cryptohome::DIRCRYPTO_MIGRATION_FAILED:
- UpdateUIState(UIState::MIGRATION_FAILED);
// Stop listening to the progress updates.
DBusThreadManager::Get()
->GetCryptohomeClient()
->SetDircryptoMigrationProgressHandler(
CryptohomeClient::DircryptoMigrationProgessHandler());
+ // Shows error screen after removing user directory is completed.
+ RemoveCryptohome();
break;
default:
break;
@@ -357,12 +375,10 @@ void EncryptionMigrationScreenHandler::OnMigrationProgress(
}
void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) {
- // This function is called when MigrateToDircrypto is correctly requested.
- // It does not mean that the migration is completed. We should know the
- // completion by DircryptoMigrationProgressHandler. success == false means a
- // failure in DBus communication.
- // TODO(fukino): Handle this case. Should we retry or restart?
- DCHECK(success);
+ if (!success) {
+ LOG(ERROR) << "Requesting MigrateToDircrypto failed. Removing cryptohome.";
+ RemoveCryptohome();
xiyuan 2017/04/26 17:48:24 I think we should only RemoveCryptohome() only whe
fukino 2017/04/27 01:38:23 Done.
+ }
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698