OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui/webui/chromeos/login/encryption_migration_screen_han dler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_han dler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/system/devicetype_utils.h" | 10 #include "ash/system/devicetype_utils.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "base/task_scheduler/post_task.h" | 14 #include "base/task_scheduler/post_task.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
18 #include "chromeos/chromeos_switches.h" | 18 #include "chromeos/chromeos_switches.h" |
19 #include "chromeos/cryptohome/async_method_caller.h" | |
19 #include "chromeos/cryptohome/homedir_methods.h" | 20 #include "chromeos/cryptohome/homedir_methods.h" |
20 #include "chromeos/dbus/cryptohome_client.h" | 21 #include "chromeos/dbus/cryptohome_client.h" |
21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
22 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 23 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
23 #include "chromeos/dbus/power_manager_client.h" | 24 #include "chromeos/dbus/power_manager_client.h" |
24 #include "components/login/localized_values_builder.h" | 25 #include "components/login/localized_values_builder.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "device/power_save_blocker/power_save_blocker.h" | 27 #include "device/power_save_blocker/power_save_blocker.h" |
27 #include "ui/base/text/bytes_formatting.h" | 28 #include "ui/base/text/bytes_formatting.h" |
28 | 29 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 content::BrowserThread::FILE))); | 306 content::BrowserThread::FILE))); |
306 } | 307 } |
307 } | 308 } |
308 | 309 |
309 void EncryptionMigrationScreenHandler::StopBlockingPowerSave() { | 310 void EncryptionMigrationScreenHandler::StopBlockingPowerSave() { |
310 if (power_save_blocker_.get()) { | 311 if (power_save_blocker_.get()) { |
311 power_save_blocker_.reset(); | 312 power_save_blocker_.reset(); |
312 } | 313 } |
313 } | 314 } |
314 | 315 |
316 void EncryptionMigrationScreenHandler::RemoveCryptohome() { | |
317 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
| |
318 cryptohome::Identification(user_context_.GetAccountId()), | |
319 base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome, | |
320 weak_ptr_factory_.GetWeakPtr())); | |
321 } | |
322 | |
323 void EncryptionMigrationScreenHandler::OnRemoveCryptohome( | |
324 bool success, | |
325 cryptohome::MountError return_code) { | |
326 if (!success) | |
327 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.
| |
328 | |
329 UpdateUIState(UIState::MIGRATION_FAILED); | |
330 } | |
331 | |
315 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { | 332 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { |
316 // |auth_key| is created in the same manner as CryptohomeAuthenticator. | 333 // |auth_key| is created in the same manner as CryptohomeAuthenticator. |
317 const Key* key = user_context_.GetKey(); | 334 const Key* key = user_context_.GetKey(); |
318 // If the |key| is a plain text password, crash rather than attempting to | 335 // If the |key| is a plain text password, crash rather than attempting to |
319 // mount the cryptohome with a plain text password. | 336 // mount the cryptohome with a plain text password. |
320 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); | 337 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); |
321 // Set the authentication's key label to an empty string, which is a wildcard | 338 // Set the authentication's key label to an empty string, which is a wildcard |
322 // allowing any key to match. This is necessary because cryptohomes created by | 339 // allowing any key to match. This is necessary because cryptohomes created by |
323 // Chrome OS M38 and older will have a legacy key with no label while those | 340 // Chrome OS M38 and older will have a legacy key with no label while those |
324 // created by Chrome OS M39 and newer will have a key with the label | 341 // created by Chrome OS M39 and newer will have a key with the label |
(...skipping 12 matching lines...) Expand all Loading... | |
337 break; | 354 break; |
338 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: | 355 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: |
339 UpdateUIState(UIState::MIGRATING); | 356 UpdateUIState(UIState::MIGRATING); |
340 CallJS("setMigrationProgress", static_cast<double>(current) / total); | 357 CallJS("setMigrationProgress", static_cast<double>(current) / total); |
341 break; | 358 break; |
342 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: | 359 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: |
343 // Restart immediately after successful migration. | 360 // Restart immediately after successful migration. |
344 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 361 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
345 break; | 362 break; |
346 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: | 363 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: |
347 UpdateUIState(UIState::MIGRATION_FAILED); | |
348 // Stop listening to the progress updates. | 364 // Stop listening to the progress updates. |
349 DBusThreadManager::Get() | 365 DBusThreadManager::Get() |
350 ->GetCryptohomeClient() | 366 ->GetCryptohomeClient() |
351 ->SetDircryptoMigrationProgressHandler( | 367 ->SetDircryptoMigrationProgressHandler( |
352 CryptohomeClient::DircryptoMigrationProgessHandler()); | 368 CryptohomeClient::DircryptoMigrationProgessHandler()); |
369 // Shows error screen after removing user directory is completed. | |
370 RemoveCryptohome(); | |
353 break; | 371 break; |
354 default: | 372 default: |
355 break; | 373 break; |
356 } | 374 } |
357 } | 375 } |
358 | 376 |
359 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { | 377 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { |
360 // This function is called when MigrateToDircrypto is correctly requested. | 378 if (!success) { |
361 // It does not mean that the migration is completed. We should know the | 379 LOG(ERROR) << "Requesting MigrateToDircrypto failed. Removing cryptohome."; |
362 // completion by DircryptoMigrationProgressHandler. success == false means a | 380 RemoveCryptohome(); |
xiyuan
2017/04/26 17:48:24
I think we should only RemoveCryptohome() only whe
fukino
2017/04/27 01:38:23
Done.
| |
363 // failure in DBus communication. | 381 } |
364 // TODO(fukino): Handle this case. Should we retry or restart? | |
365 DCHECK(success); | |
366 } | 382 } |
367 | 383 |
368 } // namespace chromeos | 384 } // namespace chromeos |
OLD | NEW |