| 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/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/system/audio/tray_audio.h" | |
| 11 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
| 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 14 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
| 15 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 16 #include "ash/wm/lock_state_controller.h" | 15 #include "ash/wm/lock_state_controller.h" |
| 17 #include "ash/wm/session_state_animator.h" | 16 #include "ash/wm/session_state_animator.h" |
| 18 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/display/types/display_snapshot.h" | 19 #include "ui/display/types/display_snapshot.h" |
| 21 #include "ui/events/event_handler.h" | 20 #include "ui/events/event_handler.h" |
| 22 #include "ui/wm/core/compound_event_filter.h" | 21 #include "ui/wm/core/compound_event_filter.h" |
| 23 | 22 |
| 24 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "ash/common/system/chromeos/audio/tray_audio.h" |
| 25 #include "chromeos/audio/cras_audio_handler.h" | 25 #include "chromeos/audio/cras_audio_handler.h" |
| 26 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace ash { | 29 namespace ash { |
| 30 | 30 |
| 31 PowerButtonController::PowerButtonController(LockStateController* controller) | 31 PowerButtonController::PowerButtonController(LockStateController* controller) |
| 32 : power_button_down_(false), | 32 : power_button_down_(false), |
| 33 lock_button_down_(false), | 33 lock_button_down_(false), |
| 34 volume_down_pressed_(false), | 34 volume_down_pressed_(false), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 if (controller_->ShutdownRequested()) | 76 if (controller_->ShutdownRequested()) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 // Avoid starting the lock/shutdown sequence if the power button is pressed | 79 // Avoid starting the lock/shutdown sequence if the power button is pressed |
| 80 // while the screen is off (http://crbug.com/128451), unless an external | 80 // while the screen is off (http://crbug.com/128451), unless an external |
| 81 // display is still on (http://crosbug.com/p/24912). | 81 // display is still on (http://crosbug.com/p/24912). |
| 82 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) | 82 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 #if defined(OS_CHROMEOS) |
| 86 // Take screenshot on power button down plus volume down when in touch view. |
| 85 if (volume_down_pressed_ && down && | 87 if (volume_down_pressed_ && down && |
| 86 WmShell::Get() | 88 WmShell::Get() |
| 87 ->maximize_mode_controller() | 89 ->maximize_mode_controller() |
| 88 ->IsMaximizeModeWindowManagerEnabled()) { | 90 ->IsMaximizeModeWindowManagerEnabled()) { |
| 89 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray(); | 91 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray(); |
| 90 if (system_tray && system_tray->GetTrayAudio()) | 92 if (system_tray && system_tray->GetTrayAudio()) |
| 91 system_tray->GetTrayAudio()->HideDetailedView(false); | 93 system_tray->GetTrayAudio()->HideDetailedView(false); |
| 92 | 94 |
| 93 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( | 95 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( |
| 94 TAKE_SCREENSHOT); | 96 TAKE_SCREENSHOT); |
| 95 | 97 |
| 96 #if defined(OS_CHROMEOS) | |
| 97 // Restore volume. | 98 // Restore volume. |
| 98 chromeos::CrasAudioHandler* audio_handler = | 99 chromeos::CrasAudioHandler* audio_handler = |
| 99 chromeos::CrasAudioHandler::Get(); | 100 chromeos::CrasAudioHandler::Get(); |
| 100 audio_handler->SetOutputVolumePercentWithoutNotifyingObservers( | 101 audio_handler->SetOutputVolumePercentWithoutNotifyingObservers( |
| 101 volume_percent_before_screenshot_, | 102 volume_percent_before_screenshot_, |
| 102 chromeos::CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT); | 103 chromeos::CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT); |
| 103 #endif | |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 #endif // defined(OS_CHROMEOS) |
| 106 | 107 |
| 107 const SessionStateDelegate* session_state_delegate = | 108 const SessionStateDelegate* session_state_delegate = |
| 108 WmShell::Get()->GetSessionStateDelegate(); | 109 WmShell::Get()->GetSessionStateDelegate(); |
| 109 if (has_legacy_power_button_) { | 110 if (has_legacy_power_button_) { |
| 110 // If power button releases won't get reported correctly because we're not | 111 // If power button releases won't get reported correctly because we're not |
| 111 // running on official hardware, just lock the screen or shut down | 112 // running on official hardware, just lock the screen or shut down |
| 112 // immediately. | 113 // immediately. |
| 113 if (down) { | 114 if (down) { |
| 114 if (session_state_delegate->CanLockScreen() && | 115 if (session_state_delegate->CanLockScreen() && |
| 115 !session_state_delegate->IsUserSessionBlocked() && | 116 !session_state_delegate->IsUserSessionBlocked() && |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 202 } |
| 202 | 203 |
| 203 void PowerButtonController::PowerButtonEventReceived( | 204 void PowerButtonController::PowerButtonEventReceived( |
| 204 bool down, | 205 bool down, |
| 205 const base::TimeTicks& timestamp) { | 206 const base::TimeTicks& timestamp) { |
| 206 OnPowerButtonEvent(down, timestamp); | 207 OnPowerButtonEvent(down, timestamp); |
| 207 } | 208 } |
| 208 #endif // defined(OS_CHROMEOS) | 209 #endif // defined(OS_CHROMEOS) |
| 209 | 210 |
| 210 } // namespace ash | 211 } // namespace ash |
| OLD | NEW |