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

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

Issue 2907773002: cros: Prevent shut down on lid-close during migration. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/system/devicetype_utils.h" 11 #include "ash/system/devicetype_utils.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/sys_info.h" 17 #include "base/sys_info.h"
18 #include "base/task_scheduler/post_task.h" 18 #include "base/task_scheduler/post_task.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chromeos/arc/arc_migration_constants.h" 20 #include "chrome/browser/chromeos/arc/arc_migration_constants.h"
21 #include "chrome/browser/chromeos/login/ui/login_feedback.h" 21 #include "chrome/browser/chromeos/login/ui/login_feedback.h"
22 #include "chrome/browser/lifetime/application_lifetime.h" 22 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
26 #include "chromeos/cryptohome/async_method_caller.h" 26 #include "chromeos/cryptohome/async_method_caller.h"
27 #include "chromeos/cryptohome/homedir_methods.h" 27 #include "chromeos/cryptohome/homedir_methods.h"
28 #include "chromeos/dbus/cryptohome_client.h" 28 #include "chromeos/dbus/cryptohome_client.h"
29 #include "chromeos/dbus/dbus_thread_manager.h" 29 #include "chromeos/dbus/dbus_thread_manager.h"
30 #include "chromeos/dbus/power_manager/policy.pb.h"
30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" 31 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
31 #include "chromeos/dbus/power_manager_client.h" 32 #include "chromeos/dbus/power_manager_client.h"
32 #include "components/login/localized_values_builder.h" 33 #include "components/login/localized_values_builder.h"
33 #include "components/user_manager/user_manager.h" 34 #include "components/user_manager/user_manager.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
35 #include "device/power_save_blocker/power_save_blocker.h" 36 #include "device/power_save_blocker/power_save_blocker.h"
36 #include "ui/base/text/bytes_formatting.h" 37 #include "ui/base/text/bytes_formatting.h"
37 38
38 namespace { 39 namespace {
39 40
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 345
345 void EncryptionMigrationScreenHandler::OnMountExistingVault( 346 void EncryptionMigrationScreenHandler::OnMountExistingVault(
346 bool success, 347 bool success,
347 cryptohome::MountError return_code, 348 cryptohome::MountError return_code,
348 const std::string& mount_hash) { 349 const std::string& mount_hash) {
349 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) { 350 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) {
350 UpdateUIState(UIState::MIGRATION_FAILED); 351 UpdateUIState(UIState::MIGRATION_FAILED);
351 return; 352 return;
352 } 353 }
353 354
355 // Prevent shut down on lid close.
356 // We set SUSPEND instead of DO_NOTHING to avoid potential heat issue.
357 // Note that, once migration finishes, the system will shut down or restart
358 // regardless of the migration result (success or failures). Given this, we
359 // don't need to restore the power policy.
360 power_manager::PowerManagementPolicy policy;
361 policy.set_lid_closed_action(
362 power_manager::PowerManagementPolicy_Action_SUSPEND);
363 DBusThreadManager::Get()->GetPowerManagerClient()->SetPolicy(policy);
Daniel Erat 2017/05/26 13:45:34 you can't send a policy directly like this; it'll
364
365 // Start migration with a progress listener.
354 DBusThreadManager::Get() 366 DBusThreadManager::Get()
355 ->GetCryptohomeClient() 367 ->GetCryptohomeClient()
356 ->SetDircryptoMigrationProgressHandler( 368 ->SetDircryptoMigrationProgressHandler(
357 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, 369 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress,
358 weak_ptr_factory_.GetWeakPtr())); 370 weak_ptr_factory_.GetWeakPtr()));
359 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( 371 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto(
360 cryptohome::Identification(user_context_.GetAccountId()), 372 cryptohome::Identification(user_context_.GetAccountId()),
361 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested, 373 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested,
362 weak_ptr_factory_.GetWeakPtr())); 374 weak_ptr_factory_.GetWeakPtr()));
363 } 375 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 467 }
456 468
457 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { 469 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) {
458 if (!success) { 470 if (!success) {
459 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; 471 LOG(ERROR) << "Requesting MigrateToDircrypto failed.";
460 UpdateUIState(UIState::MIGRATION_FAILED); 472 UpdateUIState(UIState::MIGRATION_FAILED);
461 } 473 }
462 } 474 }
463 475
464 } // namespace chromeos 476 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698