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

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

Issue 2842433002: cros: Prevent casual shut down and power save during migration. (Closed)
Patch Set: Update BUILD.gn to include PowerSaveBlocker. 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 3dbd4336afe4463f4beda65cfe94ae2e7392d68e..2b69ed620a86f90b23bb89abef5a7770b4f447da 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
@@ -12,6 +12,7 @@
#include "base/files/file_path.h"
#include "base/sys_info.h"
#include "base/task_scheduler/post_task.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
@@ -21,6 +22,8 @@
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "chromeos/dbus/power_manager_client.h"
#include "components/login/localized_values_builder.h"
+#include "content/public/browser/browser_thread.h"
+#include "device/power_save_blocker/power_save_blocker.h"
#include "ui/base/text/bytes_formatting.h"
namespace {
@@ -212,6 +215,12 @@ void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) {
// latest battery status and show it on the screen.
if (state == UIState::READY)
DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate();
+
+ // We should block power save during migration.
+ if (state == UIState::MIGRATING)
+ StartBlockingPowerSave();
+ else
+ StopBlockingPowerSave();
}
void EncryptionMigrationScreenHandler::CheckAvailableStorage() {
@@ -284,6 +293,25 @@ void EncryptionMigrationScreenHandler::OnMountExistingVault(
weak_ptr_factory_.GetWeakPtr()));
}
+void EncryptionMigrationScreenHandler::StartBlockingPowerSave() {
+ if (!power_save_blocker_) {
+ power_save_blocker_.reset(new device::PowerSaveBlocker(
+ device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
+ device::PowerSaveBlocker::kReasonOther,
+ "Encryption migration is in progress...",
+ content::BrowserThread::GetTaskRunnerForThread(
+ content::BrowserThread::UI),
+ content::BrowserThread::GetTaskRunnerForThread(
+ content::BrowserThread::FILE)));
+ }
+}
+
+void EncryptionMigrationScreenHandler::StopBlockingPowerSave() {
+ if (power_save_blocker_.get()) {
+ power_save_blocker_.reset();
+ }
+}
+
cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() {
// |auth_key| is created in the same manner as CryptohomeAuthenticator.
const Key* key = user_context_.GetKey();
« 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