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

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

Issue 2912763003: cros: Prevent shut down on lid-close during migration. (Closed)
Patch Set: revert unrelated change Created 3 years, 6 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 | chromeos/dbus/power_policy_controller.h » ('j') | 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
(...skipping 11 matching lines...) Expand all
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/power_supply_properties.pb.h" 30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
31 #include "chromeos/dbus/power_manager_client.h" 31 #include "chromeos/dbus/power_manager_client.h"
32 #include "chromeos/dbus/power_policy_controller.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
40 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen"; 41 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen";
41 42
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return; 276 return;
276 277
277 current_ui_state_ = state; 278 current_ui_state_ = state;
278 CallJS("setUIState", static_cast<int>(state)); 279 CallJS("setUIState", static_cast<int>(state));
279 280
280 // When this handler is about to show the READY screen, we should get the 281 // When this handler is about to show the READY screen, we should get the
281 // latest battery status and show it on the screen. 282 // latest battery status and show it on the screen.
282 if (state == UIState::READY) 283 if (state == UIState::READY)
283 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); 284 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate();
284 285
285 // We should block power save during migration. 286 // We should block power save and not shut down on lid close during migration.
286 if (state == UIState::MIGRATING) 287 if (state == UIState::MIGRATING) {
287 StartBlockingPowerSave(); 288 StartBlockingPowerSave();
288 else 289 PowerPolicyController::Get()->SetEncryptionMigrationActive(true);
290 } else {
289 StopBlockingPowerSave(); 291 StopBlockingPowerSave();
292 PowerPolicyController::Get()->SetEncryptionMigrationActive(false);
293 }
290 } 294 }
291 295
292 void EncryptionMigrationScreenHandler::CheckAvailableStorage() { 296 void EncryptionMigrationScreenHandler::CheckAvailableStorage() {
293 base::PostTaskWithTraitsAndReplyWithResult( 297 base::PostTaskWithTraitsAndReplyWithResult(
294 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, 298 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
295 base::Bind(&base::SysInfo::AmountOfFreeDiskSpace, 299 base::Bind(&base::SysInfo::AmountOfFreeDiskSpace,
296 base::FilePath(kCheckStoragePath)), 300 base::FilePath(kCheckStoragePath)),
297 base::Bind(&EncryptionMigrationScreenHandler::OnGetAvailableStorage, 301 base::Bind(&EncryptionMigrationScreenHandler::OnGetAvailableStorage,
298 weak_ptr_factory_.GetWeakPtr())); 302 weak_ptr_factory_.GetWeakPtr()));
299 } 303 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 459 }
456 460
457 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { 461 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) {
458 if (!success) { 462 if (!success) {
459 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; 463 LOG(ERROR) << "Requesting MigrateToDircrypto failed.";
460 UpdateUIState(UIState::MIGRATION_FAILED); 464 UpdateUIState(UIState::MIGRATION_FAILED);
461 } 465 }
462 } 466 }
463 467
464 } // namespace chromeos 468 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/power_policy_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698