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 "ash/caps_lock_delegate.h" | 7 #include "ash/caps_lock_delegate.h" |
8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
10 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_delegate.h" | 12 #include "ash/shell_delegate.h" |
| 13 #include "ash/shell_url_constants.h" |
13 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
14 #include "ash/wm/window_cycle_controller.h" | 15 #include "ash/wm/window_cycle_controller.h" |
| 16 #include "googleurl/src/gurl.h" |
15 #include "ui/aura/event.h" | 17 #include "ui/aura/event.h" |
16 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
17 #include "ui/base/accelerators/accelerator.h" | 19 #include "ui/base/accelerators/accelerator.h" |
18 #include "ui/base/accelerators/accelerator_manager.h" | 20 #include "ui/base/accelerators/accelerator_manager.h" |
19 #include "ui/gfx/compositor/debug_utils.h" | 21 #include "ui/gfx/compositor/debug_utils.h" |
20 #include "ui/gfx/compositor/layer_animation_sequence.h" | 22 #include "ui/gfx/compositor/layer_animation_sequence.h" |
21 #include "ui/gfx/compositor/layer_animator.h" | 23 #include "ui/gfx/compositor/layer_animator.h" |
22 #include "ui/gfx/compositor/screen_rotation.h" | 24 #include "ui/gfx/compositor/screen_rotation.h" |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 enum AcceleratorAction { | 28 enum AcceleratorAction { |
27 CYCLE_BACKWARD, | 29 CYCLE_BACKWARD, |
28 CYCLE_FORWARD, | 30 CYCLE_FORWARD, |
29 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
30 LOCK_SCREEN, | 32 LOCK_SCREEN, |
| 33 OPEN_CROSH_TAB, |
31 #endif | 34 #endif |
32 EXIT, | 35 EXIT, |
33 TAKE_SCREENSHOT, | 36 TAKE_SCREENSHOT, |
34 TOGGLE_CAPS_LOCK, | 37 TOGGLE_CAPS_LOCK, |
35 #if !defined(NDEBUG) | 38 #if !defined(NDEBUG) |
36 ROTATE_SCREEN, | 39 ROTATE_SCREEN, |
37 PRINT_LAYER_HIERARCHY, | 40 PRINT_LAYER_HIERARCHY, |
38 TOGGLE_COMPACT_WINDOW_MODE, | 41 TOGGLE_COMPACT_WINDOW_MODE, |
39 TOGGLE_ROOT_WINDOW_FULL_SCREEN, | 42 TOGGLE_ROOT_WINDOW_FULL_SCREEN, |
40 #endif | 43 #endif |
41 }; | 44 }; |
42 | 45 |
43 // Accelerators handled by AcceleratorController. | 46 // Accelerators handled by AcceleratorController. |
44 struct AcceleratorData { | 47 struct AcceleratorData { |
45 ui::KeyboardCode keycode; | 48 ui::KeyboardCode keycode; |
46 bool shift; | 49 bool shift; |
47 bool ctrl; | 50 bool ctrl; |
48 bool alt; | 51 bool alt; |
49 AcceleratorAction action; | 52 AcceleratorAction action; |
50 } kAcceleratorData[] = { | 53 } kAcceleratorData[] = { |
51 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, | 54 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, |
52 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD }, | 55 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD }, |
53 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD }, | 56 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD }, |
54 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
55 { ui::VKEY_L, true, true, false, LOCK_SCREEN }, | 58 { ui::VKEY_L, true, true, false, LOCK_SCREEN }, |
| 59 { ui::VKEY_T, false, true, true, OPEN_CROSH_TAB }, |
56 #endif | 60 #endif |
57 { ui::VKEY_Q, true, true, false, EXIT }, | 61 { ui::VKEY_Q, true, true, false, EXIT }, |
58 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD }, | 62 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD }, |
59 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, | 63 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, |
60 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, | 64 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, |
61 // On Chrome OS, Search key is mapped to LWIN. | 65 // On Chrome OS, Search key is mapped to LWIN. |
62 { ui::VKEY_LWIN, true, false, false, TOGGLE_CAPS_LOCK }, | 66 { ui::VKEY_LWIN, true, false, false, TOGGLE_CAPS_LOCK }, |
63 #if !defined(NDEBUG) | 67 #if !defined(NDEBUG) |
64 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, | 68 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, |
65 { ui::VKEY_A, false, true, true, TOGGLE_COMPACT_WINDOW_MODE }, | 69 { ui::VKEY_A, false, true, true, TOGGLE_COMPACT_WINDOW_MODE }, |
(...skipping 14 matching lines...) Expand all Loading... |
80 } | 84 } |
81 | 85 |
82 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) |
83 bool HandleLock() { | 87 bool HandleLock() { |
84 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); | 88 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); |
85 if (!delegate) | 89 if (!delegate) |
86 return false; | 90 return false; |
87 delegate->LockScreen(); | 91 delegate->LockScreen(); |
88 return true; | 92 return true; |
89 } | 93 } |
| 94 |
| 95 bool HandleOpenCrosh() { |
| 96 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); |
| 97 if (!delegate) |
| 98 return false; |
| 99 delegate->OpenNewTab(GURL(ash::kAuraTerminalURL)); |
| 100 return true; |
| 101 } |
90 #endif | 102 #endif |
91 | 103 |
92 bool HandleExit() { | 104 bool HandleExit() { |
93 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); | 105 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); |
94 if (!delegate) | 106 if (!delegate) |
95 return false; | 107 return false; |
96 delegate->Exit(); | 108 delegate->Exit(); |
97 return true; | 109 return true; |
98 } | 110 } |
99 | 111 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 switch (static_cast<AcceleratorAction>(it->second)) { | 231 switch (static_cast<AcceleratorAction>(it->second)) { |
220 case CYCLE_BACKWARD: | 232 case CYCLE_BACKWARD: |
221 return HandleCycleWindow(WindowCycleController::BACKWARD, | 233 return HandleCycleWindow(WindowCycleController::BACKWARD, |
222 accelerator.IsAltDown()); | 234 accelerator.IsAltDown()); |
223 case CYCLE_FORWARD: | 235 case CYCLE_FORWARD: |
224 return HandleCycleWindow(WindowCycleController::FORWARD, | 236 return HandleCycleWindow(WindowCycleController::FORWARD, |
225 accelerator.IsAltDown()); | 237 accelerator.IsAltDown()); |
226 #if defined(OS_CHROMEOS) | 238 #if defined(OS_CHROMEOS) |
227 case LOCK_SCREEN: | 239 case LOCK_SCREEN: |
228 return HandleLock(); | 240 return HandleLock(); |
| 241 case OPEN_CROSH_TAB: |
| 242 return HandleOpenCrosh(); |
229 #endif | 243 #endif |
230 case EXIT: | 244 case EXIT: |
231 return HandleExit(); | 245 return HandleExit(); |
232 case TAKE_SCREENSHOT: | 246 case TAKE_SCREENSHOT: |
233 if (screenshot_delegate_.get()) | 247 if (screenshot_delegate_.get()) |
234 screenshot_delegate_->HandleTakeScreenshot(); | 248 screenshot_delegate_->HandleTakeScreenshot(); |
235 // Return true to prevent propagation of the key event. | 249 // Return true to prevent propagation of the key event. |
236 return true; | 250 return true; |
237 case TOGGLE_CAPS_LOCK: | 251 case TOGGLE_CAPS_LOCK: |
238 if (caps_lock_delegate_.get()) | 252 if (caps_lock_delegate_.get()) |
(...skipping 13 matching lines...) Expand all Loading... |
252 NOTREACHED() << "Unhandled action " << it->second;; | 266 NOTREACHED() << "Unhandled action " << it->second;; |
253 } | 267 } |
254 return false; | 268 return false; |
255 } | 269 } |
256 | 270 |
257 bool AcceleratorController::CanHandleAccelerators() const { | 271 bool AcceleratorController::CanHandleAccelerators() const { |
258 return true; | 272 return true; |
259 } | 273 } |
260 | 274 |
261 } // namespace ash | 275 } // namespace ash |
OLD | NEW |