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 30 matching lines...) Expand all Loading... |
41 #include "ash/system/tray/system_tray.h" | 41 #include "ash/system/tray/system_tray.h" |
42 #include "ash/system/tray/system_tray_delegate.h" | 42 #include "ash/system/tray/system_tray_delegate.h" |
43 #include "ash/system/tray/system_tray_notifier.h" | 43 #include "ash/system/tray/system_tray_notifier.h" |
44 #include "ash/system/web_notification/web_notification_tray.h" | 44 #include "ash/system/web_notification/web_notification_tray.h" |
45 #include "ash/touch/touch_hud_debug.h" | 45 #include "ash/touch/touch_hud_debug.h" |
46 #include "ash/volume_control_delegate.h" | 46 #include "ash/volume_control_delegate.h" |
47 #include "ash/wm/mru_window_tracker.h" | 47 #include "ash/wm/mru_window_tracker.h" |
48 #include "ash/wm/overview/window_selector_controller.h" | 48 #include "ash/wm/overview/window_selector_controller.h" |
49 #include "ash/wm/partial_screenshot_view.h" | 49 #include "ash/wm/partial_screenshot_view.h" |
50 #include "ash/wm/power_button_controller.h" | 50 #include "ash/wm/power_button_controller.h" |
51 #include "ash/wm/window_cycle_controller.h" | |
52 #include "ash/wm/window_state.h" | 51 #include "ash/wm/window_state.h" |
53 #include "ash/wm/window_util.h" | 52 #include "ash/wm/window_util.h" |
54 #include "ash/wm/wm_event.h" | 53 #include "ash/wm/wm_event.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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (!view) | 117 if (!view) |
119 return false; | 118 return false; |
120 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) | 119 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) |
121 return false; | 120 return false; |
122 | 121 |
123 focus_manager->AdvanceFocus(reverse); | 122 focus_manager->AdvanceFocus(reverse); |
124 return true; | 123 return true; |
125 } | 124 } |
126 | 125 |
127 bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { | 126 bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
128 Shell* shell = Shell::GetInstance(); | |
129 | |
130 if (accelerator.key_code() == ui::VKEY_TAB) | 127 if (accelerator.key_code() == ui::VKEY_TAB) |
131 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); | 128 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); |
132 | 129 |
133 if (switches::UseOverviewMode()) { | 130 Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( |
134 shell->window_selector_controller()->HandleCycleWindow( | 131 WindowSelector::BACKWARD); |
135 WindowSelector::BACKWARD); | |
136 return true; | |
137 } | |
138 shell->window_cycle_controller()->HandleCycleWindow( | |
139 WindowCycleController::BACKWARD, accelerator.IsAltDown()); | |
140 return true; | 132 return true; |
141 } | 133 } |
142 | 134 |
143 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { | 135 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
144 Shell* shell = Shell::GetInstance(); | |
145 | |
146 if (accelerator.key_code() == ui::VKEY_TAB) | 136 if (accelerator.key_code() == ui::VKEY_TAB) |
147 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); | 137 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); |
148 | 138 |
149 if (switches::UseOverviewMode()) { | 139 Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( |
150 shell->window_selector_controller()->HandleCycleWindow( | 140 WindowSelector::FORWARD); |
151 WindowSelector::FORWARD); | |
152 return true; | |
153 } | |
154 shell->window_cycle_controller()->HandleCycleWindow( | |
155 WindowCycleController::FORWARD, accelerator.IsAltDown()); | |
156 return true; | 141 return true; |
157 } | 142 } |
158 | 143 |
159 bool HandleCycleLinear(const ui::Accelerator& accelerator) { | 144 bool ToggleOverview(const ui::Accelerator& accelerator) { |
160 Shell* shell = Shell::GetInstance(); | 145 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
161 | 146 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); |
162 // TODO(jamescook): When overview becomes the default the AcceleratorAction | |
163 // should be renamed from CYCLE_LINEAR to TOGGLE_OVERVIEW. | |
164 if (switches::UseOverviewMode()) { | |
165 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); | |
166 shell->window_selector_controller()->ToggleOverview(); | |
167 return true; | |
168 } | |
169 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) | |
170 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_F5")); | |
171 shell->window_cycle_controller()->HandleLinearCycleWindow(); | |
172 return true; | 147 return true; |
173 } | 148 } |
174 | 149 |
175 bool HandleFocusLauncher() { | 150 bool HandleFocusLauncher() { |
176 Shell* shell = Shell::GetInstance(); | 151 Shell* shell = Shell::GetInstance(); |
177 base::RecordAction(base::UserMetricsAction("Accel_Focus_Launcher")); | 152 base::RecordAction(base::UserMetricsAction("Accel_Focus_Launcher")); |
178 return shell->focus_cycler()->FocusWidget( | 153 return shell->focus_cycler()->FocusWidget( |
179 Shelf::ForPrimaryDisplay()->shelf_widget()); | 154 Shelf::ForPrimaryDisplay()->shelf_widget()); |
180 } | 155 } |
181 | 156 |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 // below) or pull it into a HandleFoo() function above. | 910 // below) or pull it into a HandleFoo() function above. |
936 switch (action) { | 911 switch (action) { |
937 case ACCESSIBLE_FOCUS_NEXT: | 912 case ACCESSIBLE_FOCUS_NEXT: |
938 return HandleAccessibleFocusCycle(false); | 913 return HandleAccessibleFocusCycle(false); |
939 case ACCESSIBLE_FOCUS_PREVIOUS: | 914 case ACCESSIBLE_FOCUS_PREVIOUS: |
940 return HandleAccessibleFocusCycle(true); | 915 return HandleAccessibleFocusCycle(true); |
941 case CYCLE_BACKWARD_MRU: | 916 case CYCLE_BACKWARD_MRU: |
942 return HandleCycleBackwardMRU(accelerator); | 917 return HandleCycleBackwardMRU(accelerator); |
943 case CYCLE_FORWARD_MRU: | 918 case CYCLE_FORWARD_MRU: |
944 return HandleCycleForwardMRU(accelerator); | 919 return HandleCycleForwardMRU(accelerator); |
945 case CYCLE_LINEAR: | 920 case TOGGLE_OVERVIEW: |
946 return HandleCycleLinear(accelerator); | 921 return ToggleOverview(accelerator); |
947 #if defined(OS_CHROMEOS) | 922 #if defined(OS_CHROMEOS) |
948 case ADD_REMOVE_DISPLAY: | 923 case ADD_REMOVE_DISPLAY: |
949 return HandleAddRemoveDisplay(); | 924 return HandleAddRemoveDisplay(); |
950 case TOGGLE_MIRROR_MODE: | 925 case TOGGLE_MIRROR_MODE: |
951 return HandleToggleMirrorMode(); | 926 return HandleToggleMirrorMode(); |
952 case LOCK_SCREEN: | 927 case LOCK_SCREEN: |
953 return HandleLock(key_code); | 928 return HandleLock(key_code); |
954 case OPEN_FILE_MANAGER: | 929 case OPEN_FILE_MANAGER: |
955 return HandleFileManager(); | 930 return HandleFileManager(); |
956 case OPEN_CROSH: | 931 case OPEN_CROSH: |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 keyboard_brightness_control_delegate) { | 1189 keyboard_brightness_control_delegate) { |
1215 keyboard_brightness_control_delegate_ = | 1190 keyboard_brightness_control_delegate_ = |
1216 keyboard_brightness_control_delegate.Pass(); | 1191 keyboard_brightness_control_delegate.Pass(); |
1217 } | 1192 } |
1218 | 1193 |
1219 bool AcceleratorController::CanHandleAccelerators() const { | 1194 bool AcceleratorController::CanHandleAccelerators() const { |
1220 return true; | 1195 return true; |
1221 } | 1196 } |
1222 | 1197 |
1223 } // namespace ash | 1198 } // namespace ash |
OLD | NEW |