OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/dbus/power_policy_controller.h" | 5 #include "chromeos/dbus/power_policy_controller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 SendCurrentPolicy(); | 269 SendCurrentPolicy(); |
270 } | 270 } |
271 | 271 |
272 void PowerPolicyController::NotifyChromeIsExiting() { | 272 void PowerPolicyController::NotifyChromeIsExiting() { |
273 if (chrome_is_exiting_) | 273 if (chrome_is_exiting_) |
274 return; | 274 return; |
275 chrome_is_exiting_ = true; | 275 chrome_is_exiting_ = true; |
276 SendCurrentPolicy(); | 276 SendCurrentPolicy(); |
277 } | 277 } |
278 | 278 |
279 void PowerPolicyController::SetEncryptionMigrationActive(bool active) { | |
280 encryption_migration_active_ = active; | |
281 SendCurrentPolicy(); | |
fukino
2017/05/31 05:57:22
Maybe we should call SendCurrentPolicy() only when
dspaid
2017/05/31 07:04:26
Done.
| |
282 } | |
283 | |
279 PowerPolicyController::PowerPolicyController(PowerManagerClient* client) | 284 PowerPolicyController::PowerPolicyController(PowerManagerClient* client) |
280 : client_(client), | 285 : client_(client), |
281 prefs_were_set_(false), | 286 prefs_were_set_(false), |
282 honor_screen_wake_locks_(true), | 287 honor_screen_wake_locks_(true), |
283 next_wake_lock_id_(1), | 288 next_wake_lock_id_(1), |
284 chrome_is_exiting_(false) { | 289 chrome_is_exiting_(false), |
290 encryption_migration_active_(false) { | |
285 DCHECK(client_); | 291 DCHECK(client_); |
286 client_->AddObserver(this); | 292 client_->AddObserver(this); |
287 } | 293 } |
288 | 294 |
289 PowerPolicyController::~PowerPolicyController() { | 295 PowerPolicyController::~PowerPolicyController() { |
290 client_->RemoveObserver(this); | 296 client_->RemoveObserver(this); |
291 } | 297 } |
292 | 298 |
293 PowerPolicyController::WakeLock::WakeLock(Type type, | 299 PowerPolicyController::WakeLock::WakeLock(Type type, |
294 WakeLockReason reason, | 300 WakeLockReason reason, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 policy.set_ac_idle_action( | 366 policy.set_ac_idle_action( |
361 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 367 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
362 } | 368 } |
363 if (!policy.has_battery_idle_action() || policy.battery_idle_action() == | 369 if (!policy.has_battery_idle_action() || policy.battery_idle_action() == |
364 power_manager::PowerManagementPolicy_Action_SUSPEND) { | 370 power_manager::PowerManagementPolicy_Action_SUSPEND) { |
365 policy.set_battery_idle_action( | 371 policy.set_battery_idle_action( |
366 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 372 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
367 } | 373 } |
368 } | 374 } |
369 | 375 |
376 if (encryption_migration_active_ && | |
377 policy.lid_closed_action() != | |
378 power_manager::PowerManagementPolicy_Action_DO_NOTHING) { | |
379 policy.set_lid_closed_action( | |
380 power_manager::PowerManagementPolicy_Action_SUSPEND); | |
381 causes += | |
382 std::string((causes.empty() ? "" : ", ")) + "encryption migration"; | |
383 } | |
384 | |
370 // To avoid a race in the case where the user asks Chrome to sign out | 385 // To avoid a race in the case where the user asks Chrome to sign out |
371 // and then immediately closes the lid, override the lid-closed action | 386 // and then immediately closes the lid, override the lid-closed action |
372 // so the system will stay awake while Chrome is exiting. When Chrome | 387 // so the system will stay awake while Chrome is exiting. When Chrome |
373 // restarts to display the login screen, it will send an updated | 388 // restarts to display the login screen, it will send an updated |
374 // policy that powerd can act on. | 389 // policy that powerd can act on. |
375 if (chrome_is_exiting_ && | 390 if (chrome_is_exiting_ && |
376 (!policy.has_lid_closed_action() || | 391 (!policy.has_lid_closed_action() || |
377 policy.lid_closed_action() == | 392 policy.lid_closed_action() == |
378 power_manager::PowerManagementPolicy_Action_SUSPEND || | 393 power_manager::PowerManagementPolicy_Action_SUSPEND || |
379 policy.lid_closed_action() == | 394 policy.lid_closed_action() == |
380 power_manager::PowerManagementPolicy_Action_SHUT_DOWN)) { | 395 power_manager::PowerManagementPolicy_Action_SHUT_DOWN)) { |
381 policy.set_lid_closed_action( | 396 policy.set_lid_closed_action( |
382 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 397 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
383 } | 398 } |
384 | 399 |
385 if (!causes.empty()) | 400 if (!causes.empty()) |
386 policy.set_reason(causes); | 401 policy.set_reason(causes); |
387 client_->SetPolicy(policy); | 402 client_->SetPolicy(policy); |
388 } | 403 } |
389 | 404 |
390 } // namespace chromeos | 405 } // namespace chromeos |
OLD | NEW |