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