| 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 <iostream> | 9 #include <iostream> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ash/system/tray/system_tray.h" | 42 #include "ash/system/tray/system_tray.h" |
| 43 #include "ash/system/tray/system_tray_delegate.h" | 43 #include "ash/system/tray/system_tray_delegate.h" |
| 44 #include "ash/system/tray/system_tray_notifier.h" | 44 #include "ash/system/tray/system_tray_notifier.h" |
| 45 #include "ash/system/web_notification/web_notification_tray.h" | 45 #include "ash/system/web_notification/web_notification_tray.h" |
| 46 #include "ash/touch/touch_hud_debug.h" | 46 #include "ash/touch/touch_hud_debug.h" |
| 47 #include "ash/volume_control_delegate.h" | 47 #include "ash/volume_control_delegate.h" |
| 48 #include "ash/wm/mru_window_tracker.h" | 48 #include "ash/wm/mru_window_tracker.h" |
| 49 #include "ash/wm/overview/window_selector_controller.h" | 49 #include "ash/wm/overview/window_selector_controller.h" |
| 50 #include "ash/wm/partial_screenshot_view.h" | 50 #include "ash/wm/partial_screenshot_view.h" |
| 51 #include "ash/wm/power_button_controller.h" | 51 #include "ash/wm/power_button_controller.h" |
| 52 #include "ash/wm/window_cycle_controller.h" | |
| 53 #include "ash/wm/window_state.h" | 52 #include "ash/wm/window_state.h" |
| 54 #include "ash/wm/window_util.h" | 53 #include "ash/wm/window_util.h" |
| 55 #include "base/bind.h" | 54 #include "base/bind.h" |
| 56 #include "base/command_line.h" | 55 #include "base/command_line.h" |
| 57 #include "base/metrics/user_metrics.h" | 56 #include "base/metrics/user_metrics.h" |
| 58 #include "ui/aura/env.h" | 57 #include "ui/aura/env.h" |
| 59 #include "ui/aura/window_event_dispatcher.h" | 58 #include "ui/aura/window_event_dispatcher.h" |
| 60 #include "ui/base/accelerators/accelerator.h" | 59 #include "ui/base/accelerators/accelerator.h" |
| 61 #include "ui/base/accelerators/accelerator_manager.h" | 60 #include "ui/base/accelerators/accelerator_manager.h" |
| 62 #include "ui/compositor/debug_utils.h" | 61 #include "ui/compositor/debug_utils.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (!view) | 115 if (!view) |
| 117 return false; | 116 return false; |
| 118 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) | 117 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) |
| 119 return false; | 118 return false; |
| 120 | 119 |
| 121 focus_manager->AdvanceFocus(reverse); | 120 focus_manager->AdvanceFocus(reverse); |
| 122 return true; | 121 return true; |
| 123 } | 122 } |
| 124 | 123 |
| 125 bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { | 124 bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
| 126 Shell* shell = Shell::GetInstance(); | |
| 127 | |
| 128 if (accelerator.key_code() == ui::VKEY_TAB) | 125 if (accelerator.key_code() == ui::VKEY_TAB) |
| 129 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); | 126 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); |
| 130 | 127 |
| 131 if (switches::UseOverviewMode()) { | 128 Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( |
| 132 shell->window_selector_controller()->HandleCycleWindow( | 129 WindowSelector::BACKWARD); |
| 133 WindowSelector::BACKWARD); | |
| 134 return true; | |
| 135 } | |
| 136 shell->window_cycle_controller()->HandleCycleWindow( | |
| 137 WindowCycleController::BACKWARD, accelerator.IsAltDown()); | |
| 138 return true; | 130 return true; |
| 139 } | 131 } |
| 140 | 132 |
| 141 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { | 133 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
| 142 Shell* shell = Shell::GetInstance(); | |
| 143 | |
| 144 if (accelerator.key_code() == ui::VKEY_TAB) | 134 if (accelerator.key_code() == ui::VKEY_TAB) |
| 145 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); | 135 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); |
| 146 | 136 |
| 147 if (switches::UseOverviewMode()) { | 137 Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( |
| 148 shell->window_selector_controller()->HandleCycleWindow( | 138 WindowSelector::FORWARD); |
| 149 WindowSelector::FORWARD); | |
| 150 return true; | |
| 151 } | |
| 152 shell->window_cycle_controller()->HandleCycleWindow( | |
| 153 WindowCycleController::FORWARD, accelerator.IsAltDown()); | |
| 154 return true; | 139 return true; |
| 155 } | 140 } |
| 156 | 141 |
| 157 bool HandleCycleLinear(const ui::Accelerator& accelerator) { | 142 bool ToggleOverview(const ui::Accelerator& accelerator) { |
| 158 Shell* shell = Shell::GetInstance(); | 143 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
| 159 | 144 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); |
| 160 // TODO(jamescook): When overview becomes the default the AcceleratorAction | |
| 161 // should be renamed from CYCLE_LINEAR to TOGGLE_OVERVIEW. | |
| 162 if (switches::UseOverviewMode()) { | |
| 163 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); | |
| 164 shell->window_selector_controller()->ToggleOverview(); | |
| 165 return true; | |
| 166 } | |
| 167 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) | |
| 168 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_F5")); | |
| 169 shell->window_cycle_controller()->HandleLinearCycleWindow(); | |
| 170 return true; | 145 return true; |
| 171 } | 146 } |
| 172 | 147 |
| 173 bool HandleDisableCapsLock(ui::KeyboardCode key_code, | 148 bool HandleDisableCapsLock(ui::KeyboardCode key_code, |
| 174 ui::EventType previous_event_type, | 149 ui::EventType previous_event_type, |
| 175 ui::KeyboardCode previous_key_code) { | 150 ui::KeyboardCode previous_key_code) { |
| 176 Shell* shell = Shell::GetInstance(); | 151 Shell* shell = Shell::GetInstance(); |
| 177 | 152 |
| 178 if (previous_event_type == ui::ET_KEY_RELEASED || | 153 if (previous_event_type == ui::ET_KEY_RELEASED || |
| 179 (previous_key_code != ui::VKEY_LSHIFT && | 154 (previous_key_code != ui::VKEY_LSHIFT && |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 // below) or pull it into a HandleFoo() function above. | 904 // below) or pull it into a HandleFoo() function above. |
| 930 switch (action) { | 905 switch (action) { |
| 931 case ACCESSIBLE_FOCUS_NEXT: | 906 case ACCESSIBLE_FOCUS_NEXT: |
| 932 return HandleAccessibleFocusCycle(false); | 907 return HandleAccessibleFocusCycle(false); |
| 933 case ACCESSIBLE_FOCUS_PREVIOUS: | 908 case ACCESSIBLE_FOCUS_PREVIOUS: |
| 934 return HandleAccessibleFocusCycle(true); | 909 return HandleAccessibleFocusCycle(true); |
| 935 case CYCLE_BACKWARD_MRU: | 910 case CYCLE_BACKWARD_MRU: |
| 936 return HandleCycleBackwardMRU(accelerator); | 911 return HandleCycleBackwardMRU(accelerator); |
| 937 case CYCLE_FORWARD_MRU: | 912 case CYCLE_FORWARD_MRU: |
| 938 return HandleCycleForwardMRU(accelerator); | 913 return HandleCycleForwardMRU(accelerator); |
| 939 case CYCLE_LINEAR: | 914 case TOGGLE_OVERVIEW: |
| 940 return HandleCycleLinear(accelerator); | 915 return ToggleOverview(accelerator); |
| 941 #if defined(OS_CHROMEOS) | 916 #if defined(OS_CHROMEOS) |
| 942 case ADD_REMOVE_DISPLAY: | 917 case ADD_REMOVE_DISPLAY: |
| 943 return HandleAddRemoveDisplay(); | 918 return HandleAddRemoveDisplay(); |
| 944 case TOGGLE_MIRROR_MODE: | 919 case TOGGLE_MIRROR_MODE: |
| 945 return HandleToggleMirrorMode(); | 920 return HandleToggleMirrorMode(); |
| 946 case LOCK_SCREEN: | 921 case LOCK_SCREEN: |
| 947 return HandleLock(key_code); | 922 return HandleLock(key_code); |
| 948 case OPEN_FILE_MANAGER: | 923 case OPEN_FILE_MANAGER: |
| 949 return HandleFileManager(); | 924 return HandleFileManager(); |
| 950 case OPEN_CROSH: | 925 case OPEN_CROSH: |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 keyboard_brightness_control_delegate) { | 1183 keyboard_brightness_control_delegate) { |
| 1209 keyboard_brightness_control_delegate_ = | 1184 keyboard_brightness_control_delegate_ = |
| 1210 keyboard_brightness_control_delegate.Pass(); | 1185 keyboard_brightness_control_delegate.Pass(); |
| 1211 } | 1186 } |
| 1212 | 1187 |
| 1213 bool AcceleratorController::CanHandleAccelerators() const { | 1188 bool AcceleratorController::CanHandleAccelerators() const { |
| 1214 return true; | 1189 return true; |
| 1215 } | 1190 } |
| 1216 | 1191 |
| 1217 } // namespace ash | 1192 } // namespace ash |
| OLD | NEW |