| 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 if (encryption_migration_active_ == active) |
| 281 return; |
| 282 |
| 283 encryption_migration_active_ = active; |
| 284 SendCurrentPolicy(); |
| 285 } |
| 286 |
| 279 PowerPolicyController::PowerPolicyController(PowerManagerClient* client) | 287 PowerPolicyController::PowerPolicyController(PowerManagerClient* client) |
| 280 : client_(client), | 288 : client_(client), |
| 281 prefs_were_set_(false), | 289 prefs_were_set_(false), |
| 282 honor_screen_wake_locks_(true), | 290 honor_screen_wake_locks_(true), |
| 283 next_wake_lock_id_(1), | 291 next_wake_lock_id_(1), |
| 284 chrome_is_exiting_(false) { | 292 chrome_is_exiting_(false), |
| 293 encryption_migration_active_(false) { |
| 285 DCHECK(client_); | 294 DCHECK(client_); |
| 286 client_->AddObserver(this); | 295 client_->AddObserver(this); |
| 287 } | 296 } |
| 288 | 297 |
| 289 PowerPolicyController::~PowerPolicyController() { | 298 PowerPolicyController::~PowerPolicyController() { |
| 290 client_->RemoveObserver(this); | 299 client_->RemoveObserver(this); |
| 291 } | 300 } |
| 292 | 301 |
| 293 PowerPolicyController::WakeLock::WakeLock(Type type, | 302 PowerPolicyController::WakeLock::WakeLock(Type type, |
| 294 WakeLockReason reason, | 303 WakeLockReason reason, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 policy.set_ac_idle_action( | 369 policy.set_ac_idle_action( |
| 361 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 370 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
| 362 } | 371 } |
| 363 if (!policy.has_battery_idle_action() || policy.battery_idle_action() == | 372 if (!policy.has_battery_idle_action() || policy.battery_idle_action() == |
| 364 power_manager::PowerManagementPolicy_Action_SUSPEND) { | 373 power_manager::PowerManagementPolicy_Action_SUSPEND) { |
| 365 policy.set_battery_idle_action( | 374 policy.set_battery_idle_action( |
| 366 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 375 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
| 367 } | 376 } |
| 368 } | 377 } |
| 369 | 378 |
| 379 if (encryption_migration_active_ && |
| 380 policy.lid_closed_action() != |
| 381 power_manager::PowerManagementPolicy_Action_DO_NOTHING) { |
| 382 policy.set_lid_closed_action( |
| 383 power_manager::PowerManagementPolicy_Action_SUSPEND); |
| 384 causes += |
| 385 std::string((causes.empty() ? "" : ", ")) + "encryption migration"; |
| 386 } |
| 387 |
| 370 // To avoid a race in the case where the user asks Chrome to sign out | 388 // 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 | 389 // and then immediately closes the lid, override the lid-closed action |
| 372 // so the system will stay awake while Chrome is exiting. When Chrome | 390 // so the system will stay awake while Chrome is exiting. When Chrome |
| 373 // restarts to display the login screen, it will send an updated | 391 // restarts to display the login screen, it will send an updated |
| 374 // policy that powerd can act on. | 392 // policy that powerd can act on. |
| 375 if (chrome_is_exiting_ && | 393 if (chrome_is_exiting_ && |
| 376 (!policy.has_lid_closed_action() || | 394 (!policy.has_lid_closed_action() || |
| 377 policy.lid_closed_action() == | 395 policy.lid_closed_action() == |
| 378 power_manager::PowerManagementPolicy_Action_SUSPEND || | 396 power_manager::PowerManagementPolicy_Action_SUSPEND || |
| 379 policy.lid_closed_action() == | 397 policy.lid_closed_action() == |
| 380 power_manager::PowerManagementPolicy_Action_SHUT_DOWN)) { | 398 power_manager::PowerManagementPolicy_Action_SHUT_DOWN)) { |
| 381 policy.set_lid_closed_action( | 399 policy.set_lid_closed_action( |
| 382 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 400 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
| 383 } | 401 } |
| 384 | 402 |
| 385 if (!causes.empty()) | 403 if (!causes.empty()) |
| 386 policy.set_reason(causes); | 404 policy.set_reason(causes); |
| 387 client_->SetPolicy(policy); | 405 client_->SetPolicy(policy); |
| 388 } | 406 } |
| 389 | 407 |
| 390 } // namespace chromeos | 408 } // namespace chromeos |
| OLD | NEW |