| 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "ash/accelerators/accelerator_commands.h" | 12 #include "ash/accelerators/accelerator_commands.h" |
| 13 #include "ash/accelerators/debug_commands.h" | 13 #include "ash/accelerators/debug_commands.h" |
| 14 #include "ash/common/accessibility_delegate.h" | 14 #include "ash/common/accessibility_delegate.h" |
| 15 #include "ash/common/accessibility_types.h" | 15 #include "ash/common/accessibility_types.h" |
| 16 #include "ash/common/ash_switches.h" | 16 #include "ash/common/ash_switches.h" |
| 17 #include "ash/common/focus_cycler.h" | 17 #include "ash/common/focus_cycler.h" |
| 18 #include "ash/common/media_delegate.h" | 18 #include "ash/common/media_delegate.h" |
| 19 #include "ash/common/multi_profile_uma.h" | 19 #include "ash/common/multi_profile_uma.h" |
| 20 #include "ash/common/session/session_state_delegate.h" | 20 #include "ash/common/session/session_state_delegate.h" |
| 21 #include "ash/common/shelf/shelf_model.h" | 21 #include "ash/common/shelf/shelf_model.h" |
| 22 #include "ash/common/shell_delegate.h" | 22 #include "ash/common/shell_delegate.h" |
| 23 #include "ash/common/shell_window_ids.h" | 23 #include "ash/common/shell_window_ids.h" |
| 24 #include "ash/common/system/brightness_control_delegate.h" |
| 25 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 24 #include "ash/common/system/system_notifier.h" | 26 #include "ash/common/system/system_notifier.h" |
| 25 #include "ash/common/system/tray/system_tray_delegate.h" | 27 #include "ash/common/system/tray/system_tray_delegate.h" |
| 26 #include "ash/common/system/tray/system_tray_notifier.h" | 28 #include "ash/common/system/tray/system_tray_notifier.h" |
| 27 #include "ash/common/system/volume_control_delegate.h" | 29 #include "ash/common/system/volume_control_delegate.h" |
| 28 #include "ash/common/system/web_notification/web_notification_tray.h" | 30 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 29 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 31 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 30 #include "ash/common/wm/mru_window_tracker.h" | 32 #include "ash/common/wm/mru_window_tracker.h" |
| 31 #include "ash/common/wm/overview/window_selector_controller.h" | 33 #include "ash/common/wm/overview/window_selector_controller.h" |
| 32 #include "ash/common/wm/window_state.h" | 34 #include "ash/common/wm/window_state.h" |
| 33 #include "ash/common/wm/wm_event.h" | 35 #include "ash/common/wm/wm_event.h" |
| 34 #include "ash/common/wm_shell.h" | 36 #include "ash/common/wm_shell.h" |
| 35 #include "ash/debug.h" | 37 #include "ash/debug.h" |
| 36 #include "ash/display/window_tree_host_manager.h" | 38 #include "ash/display/window_tree_host_manager.h" |
| 37 #include "ash/gpu_support.h" | 39 #include "ash/gpu_support.h" |
| 38 #include "ash/ime_control_delegate.h" | 40 #include "ash/ime_control_delegate.h" |
| 39 #include "ash/magnifier/magnification_controller.h" | 41 #include "ash/magnifier/magnification_controller.h" |
| 40 #include "ash/magnifier/partial_magnification_controller.h" | 42 #include "ash/magnifier/partial_magnification_controller.h" |
| 41 #include "ash/new_window_delegate.h" | 43 #include "ash/new_window_delegate.h" |
| 42 #include "ash/root_window_controller.h" | 44 #include "ash/root_window_controller.h" |
| 43 #include "ash/rotator/screen_rotation_animator.h" | 45 #include "ash/rotator/screen_rotation_animator.h" |
| 44 #include "ash/rotator/window_rotation.h" | 46 #include "ash/rotator/window_rotation.h" |
| 45 #include "ash/screen_util.h" | 47 #include "ash/screen_util.h" |
| 46 #include "ash/screenshot_delegate.h" | 48 #include "ash/screenshot_delegate.h" |
| 47 #include "ash/shelf/shelf.h" | 49 #include "ash/shelf/shelf.h" |
| 48 #include "ash/shelf/shelf_delegate.h" | 50 #include "ash/shelf/shelf_delegate.h" |
| 49 #include "ash/shelf/shelf_widget.h" | 51 #include "ash/shelf/shelf_widget.h" |
| 50 #include "ash/shell.h" | 52 #include "ash/shell.h" |
| 51 #include "ash/system/brightness_control_delegate.h" | |
| 52 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | |
| 53 #include "ash/system/status_area_widget.h" | 53 #include "ash/system/status_area_widget.h" |
| 54 #include "ash/system/tray/system_tray.h" | 54 #include "ash/system/tray/system_tray.h" |
| 55 #include "ash/touch/touch_hud_debug.h" | 55 #include "ash/touch/touch_hud_debug.h" |
| 56 #include "ash/utility/screenshot_controller.h" | 56 #include "ash/utility/screenshot_controller.h" |
| 57 #include "ash/wm/power_button_controller.h" | 57 #include "ash/wm/power_button_controller.h" |
| 58 #include "ash/wm/window_cycle_controller.h" | 58 #include "ash/wm/window_cycle_controller.h" |
| 59 #include "ash/wm/window_state_aura.h" | 59 #include "ash/wm/window_state_aura.h" |
| 60 #include "ash/wm/window_util.h" | 60 #include "ash/wm/window_util.h" |
| 61 #include "base/bind.h" | 61 #include "base/bind.h" |
| 62 #include "base/command_line.h" | 62 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 #include "ui/compositor/layer_animation_sequence.h" | 73 #include "ui/compositor/layer_animation_sequence.h" |
| 74 #include "ui/compositor/layer_animator.h" | 74 #include "ui/compositor/layer_animator.h" |
| 75 #include "ui/display/screen.h" | 75 #include "ui/display/screen.h" |
| 76 #include "ui/events/event.h" | 76 #include "ui/events/event.h" |
| 77 #include "ui/events/keycodes/keyboard_codes.h" | 77 #include "ui/events/keycodes/keyboard_codes.h" |
| 78 #include "ui/message_center/message_center.h" | 78 #include "ui/message_center/message_center.h" |
| 79 #include "ui/message_center/notification.h" | 79 #include "ui/message_center/notification.h" |
| 80 #include "ui/message_center/notifier_settings.h" | 80 #include "ui/message_center/notifier_settings.h" |
| 81 | 81 |
| 82 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
| 83 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 83 #include "ash/display/display_configuration_controller.h" | 84 #include "ash/display/display_configuration_controller.h" |
| 84 #include "ash/system/chromeos/keyboard_brightness_controller.h" | |
| 85 #include "base/sys_info.h" | 85 #include "base/sys_info.h" |
| 86 #include "chromeos/dbus/dbus_thread_manager.h" | 86 #include "chromeos/dbus/dbus_thread_manager.h" |
| 87 #include "chromeos/dbus/power_manager_client.h" | 87 #include "chromeos/dbus/power_manager_client.h" |
| 88 #include "ui/base/ime/chromeos/ime_keyboard.h" | 88 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 89 #include "ui/base/ime/chromeos/input_method_manager.h" | 89 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 90 #endif // defined(OS_CHROMEOS) | 90 #endif // defined(OS_CHROMEOS) |
| 91 | 91 |
| 92 namespace ash { | 92 namespace ash { |
| 93 namespace { | 93 namespace { |
| 94 | 94 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 bool CanHandleUnpin() { | 547 bool CanHandleUnpin() { |
| 548 wm::WindowState* window_state = wm::GetActiveWindowState(); | 548 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 549 return window_state && window_state->IsPinned(); | 549 return window_state && window_state->IsPinned(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void HandleUnpin() { | 552 void HandleUnpin() { |
| 553 accelerators::Unpin(); | 553 accelerators::Unpin(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 #if defined(OS_CHROMEOS) | 556 #if defined(OS_CHROMEOS) |
| 557 void HandleBrightnessDown(BrightnessControlDelegate* delegate, | |
| 558 const ui::Accelerator& accelerator) { | |
| 559 if (delegate) | |
| 560 delegate->HandleBrightnessDown(accelerator); | |
| 561 } | |
| 562 | |
| 563 void HandleBrightnessUp(BrightnessControlDelegate* delegate, | |
| 564 const ui::Accelerator& accelerator) { | |
| 565 if (delegate) | |
| 566 delegate->HandleBrightnessUp(accelerator); | |
| 567 } | |
| 568 | |
| 569 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { | 557 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { |
| 570 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); | 558 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
| 571 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || | 559 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || |
| 572 (previous_key_code != ui::VKEY_LSHIFT && | 560 (previous_key_code != ui::VKEY_LSHIFT && |
| 573 previous_key_code != ui::VKEY_SHIFT && | 561 previous_key_code != ui::VKEY_SHIFT && |
| 574 previous_key_code != ui::VKEY_RSHIFT)) { | 562 previous_key_code != ui::VKEY_RSHIFT)) { |
| 575 // If something else was pressed between the Shift key being pressed | 563 // If something else was pressed between the Shift key being pressed |
| 576 // and released, then ignore the release of the Shift key. | 564 // and released, then ignore the release of the Shift key. |
| 577 return false; | 565 return false; |
| 578 } | 566 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 return true; | 788 return true; |
| 801 } | 789 } |
| 802 return false; | 790 return false; |
| 803 } | 791 } |
| 804 | 792 |
| 805 AcceleratorController::AcceleratorProcessingRestriction | 793 AcceleratorController::AcceleratorProcessingRestriction |
| 806 AcceleratorController::GetCurrentAcceleratorRestriction() { | 794 AcceleratorController::GetCurrentAcceleratorRestriction() { |
| 807 return GetAcceleratorProcessingRestriction(-1); | 795 return GetAcceleratorProcessingRestriction(-1); |
| 808 } | 796 } |
| 809 | 797 |
| 810 void AcceleratorController::SetBrightnessControlDelegate( | |
| 811 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate) { | |
| 812 brightness_control_delegate_ = std::move(brightness_control_delegate); | |
| 813 } | |
| 814 | |
| 815 void AcceleratorController::SetImeControlDelegate( | 798 void AcceleratorController::SetImeControlDelegate( |
| 816 std::unique_ptr<ImeControlDelegate> ime_control_delegate) { | 799 std::unique_ptr<ImeControlDelegate> ime_control_delegate) { |
| 817 ime_control_delegate_ = std::move(ime_control_delegate); | 800 ime_control_delegate_ = std::move(ime_control_delegate); |
| 818 } | 801 } |
| 819 | 802 |
| 820 void AcceleratorController::SetScreenshotDelegate( | 803 void AcceleratorController::SetScreenshotDelegate( |
| 821 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) { | 804 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) { |
| 822 screenshot_delegate_ = std::move(screenshot_delegate); | 805 screenshot_delegate_ = std::move(screenshot_delegate); |
| 823 } | 806 } |
| 824 | 807 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 case WINDOW_MINIMIZE: | 1256 case WINDOW_MINIMIZE: |
| 1274 HandleWindowMinimize(); | 1257 HandleWindowMinimize(); |
| 1275 break; | 1258 break; |
| 1276 case WINDOW_POSITION_CENTER: | 1259 case WINDOW_POSITION_CENTER: |
| 1277 HandlePositionCenter(); | 1260 HandlePositionCenter(); |
| 1278 break; | 1261 break; |
| 1279 case UNPIN: | 1262 case UNPIN: |
| 1280 HandleUnpin(); | 1263 HandleUnpin(); |
| 1281 break; | 1264 break; |
| 1282 #if defined(OS_CHROMEOS) | 1265 #if defined(OS_CHROMEOS) |
| 1283 case BRIGHTNESS_DOWN: | 1266 case BRIGHTNESS_DOWN: { |
| 1284 HandleBrightnessDown(brightness_control_delegate_.get(), accelerator); | 1267 BrightnessControlDelegate* brightness_control_delegate = |
| 1268 WmShell::Get()->brightness_control_delegate(); |
| 1269 if (brightness_control_delegate) |
| 1270 brightness_control_delegate->HandleBrightnessDown(accelerator); |
| 1285 break; | 1271 break; |
| 1286 case BRIGHTNESS_UP: | 1272 } |
| 1287 HandleBrightnessUp(brightness_control_delegate_.get(), accelerator); | 1273 case BRIGHTNESS_UP: { |
| 1274 BrightnessControlDelegate* brightness_control_delegate = |
| 1275 WmShell::Get()->brightness_control_delegate(); |
| 1276 if (brightness_control_delegate) |
| 1277 brightness_control_delegate->HandleBrightnessUp(accelerator); |
| 1288 break; | 1278 break; |
| 1279 } |
| 1289 case DEBUG_ADD_REMOVE_DISPLAY: | 1280 case DEBUG_ADD_REMOVE_DISPLAY: |
| 1290 case DEBUG_SHOW_TOAST: | 1281 case DEBUG_SHOW_TOAST: |
| 1291 case DEBUG_TOGGLE_TOUCH_PAD: | 1282 case DEBUG_TOGGLE_TOUCH_PAD: |
| 1292 case DEBUG_TOGGLE_TOUCH_SCREEN: | 1283 case DEBUG_TOGGLE_TOUCH_SCREEN: |
| 1293 case DEBUG_TOGGLE_TOUCH_VIEW: | 1284 case DEBUG_TOGGLE_TOUCH_VIEW: |
| 1294 case DEBUG_TOGGLE_UNIFIED_DESKTOP: | 1285 case DEBUG_TOGGLE_UNIFIED_DESKTOP: |
| 1295 debug::PerformDebugActionIfEnabled(action); | 1286 debug::PerformDebugActionIfEnabled(action); |
| 1296 break; | 1287 break; |
| 1297 case DISABLE_CAPS_LOCK: | 1288 case DISABLE_CAPS_LOCK: |
| 1298 HandleDisableCapsLock(); | 1289 HandleDisableCapsLock(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 } | 1427 } |
| 1437 | 1428 |
| 1438 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1429 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
| 1439 std::unique_ptr<KeyboardBrightnessControlDelegate> | 1430 std::unique_ptr<KeyboardBrightnessControlDelegate> |
| 1440 keyboard_brightness_control_delegate) { | 1431 keyboard_brightness_control_delegate) { |
| 1441 keyboard_brightness_control_delegate_ = | 1432 keyboard_brightness_control_delegate_ = |
| 1442 std::move(keyboard_brightness_control_delegate); | 1433 std::move(keyboard_brightness_control_delegate); |
| 1443 } | 1434 } |
| 1444 | 1435 |
| 1445 } // namespace ash | 1436 } // namespace ash |
| OLD | NEW |