Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
| 8 #include "ash/common/accessibility_delegate.h" | |
| 8 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
| 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 13 #include "ash/public/cpp/shell_window_ids.h" | 14 #include "ash/public/cpp/shell_window_ids.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/wm/lock_state_controller.h" | 16 #include "ash/wm/lock_state_controller.h" |
| 16 #include "ash/wm/session_state_animator.h" | 17 #include "ash/wm/session_state_animator.h" |
| 17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 Shell::GetInstance()->RemovePreTargetHandler(this); | 59 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 59 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
| 60 Shell::GetInstance()->display_configurator()->RemoveObserver(this); | 61 Shell::GetInstance()->display_configurator()->RemoveObserver(this); |
| 61 tablet_controller_.reset(); | 62 tablet_controller_.reset(); |
| 62 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 63 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 63 this); | 64 this); |
| 64 #endif | 65 #endif |
| 65 } | 66 } |
| 66 | 67 |
| 67 void PowerButtonController::OnScreenBrightnessChanged(double percent) { | 68 void PowerButtonController::OnScreenBrightnessChanged(double percent) { |
| 68 brightness_is_zero_ = percent <= 0.001; | 69 bool new_brightness_is_zero = percent <= 0.001; |
|
Daniel Erat
2016/11/16 22:08:46
is PowerButtonController the best place for this t
Qiang(Joe) Xu
2016/11/17 04:09:20
I did the investigation more on this and found the
| |
| 70 | |
| 71 // Send an a11y alert when there is a switch between screen on and off. | |
| 72 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | |
| 73 if (brightness_is_zero_ && !new_brightness_is_zero) | |
| 74 delegate->TriggerAccessibilityAlert(A11Y_ALERT_SCEEEN_ON); | |
| 75 else if (!brightness_is_zero_ && new_brightness_is_zero) | |
| 76 delegate->TriggerAccessibilityAlert(A11Y_ALERT_SCREEN_OFF); | |
| 77 | |
| 78 brightness_is_zero_ = new_brightness_is_zero; | |
| 69 } | 79 } |
| 70 | 80 |
| 71 void PowerButtonController::OnPowerButtonEvent( | 81 void PowerButtonController::OnPowerButtonEvent( |
| 72 bool down, | 82 bool down, |
| 73 const base::TimeTicks& timestamp) { | 83 const base::TimeTicks& timestamp) { |
| 74 power_button_down_ = down; | 84 power_button_down_ = down; |
| 75 | 85 |
| 76 if (lock_state_controller_->ShutdownRequested()) | 86 if (lock_state_controller_->ShutdownRequested()) |
| 77 return; | 87 return; |
| 78 | 88 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 } | 218 } |
| 209 | 219 |
| 210 void PowerButtonController::PowerButtonEventReceived( | 220 void PowerButtonController::PowerButtonEventReceived( |
| 211 bool down, | 221 bool down, |
| 212 const base::TimeTicks& timestamp) { | 222 const base::TimeTicks& timestamp) { |
| 213 OnPowerButtonEvent(down, timestamp); | 223 OnPowerButtonEvent(down, timestamp); |
| 214 } | 224 } |
| 215 #endif // defined(OS_CHROMEOS) | 225 #endif // defined(OS_CHROMEOS) |
| 216 | 226 |
| 217 } // namespace ash | 227 } // namespace ash |
| OLD | NEW |