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 "chrome/browser/ui/views/accelerator_table.h" | 5 #include "chrome/browser/ui/views/accelerator_table.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "ui/base/accelerators/accelerator.h" | 12 #include "ui/base/accelerators/accelerator.h" |
13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
14 | 14 |
15 #if defined(USE_ASH) | 15 #if defined(USE_ASH) |
16 #include "ash/common/accelerators/accelerator_table.h" // nogncheck | 16 #include "ash/common/accelerators/accelerator_table.h" // nogncheck |
17 #endif | 17 #endif |
18 | 18 |
19 namespace chrome { | 19 namespace chrome { |
20 namespace { | 20 namespace { |
21 | 21 |
22 // For many commands, the Mac equivalent uses Cmd instead of Ctrl. We only need | 22 // For many commands, the Mac equivalent uses Cmd instead of Ctrl. We only need |
23 // to list the ones that do not have a key equivalent in the main menu, i.e. | 23 // to list the ones that do not have a key equivalent in the main menu, i.e. |
24 // only the ones in global_keyboard_shortcuts_mac.mm. | 24 // only the ones in global_keyboard_shortcuts_mac.mm. |
25 // TODO(jackhou): If-def out the accelerators that should not be on Mac. | |
26 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
27 const ui::EventFlags kPlatformModifier = ui::EF_COMMAND_DOWN; | 26 const ui::EventFlags kPlatformModifier = ui::EF_COMMAND_DOWN; |
28 #else | 27 #else |
29 const ui::EventFlags kPlatformModifier = ui::EF_CONTROL_DOWN; | 28 const ui::EventFlags kPlatformModifier = ui::EF_CONTROL_DOWN; |
30 #endif | 29 #endif |
31 | 30 |
32 // NOTE: Keep this list in the same (mostly-alphabetical) order as | 31 // NOTE: Between each ifdef block, keep the list in the same |
33 // the Windows accelerators in ../../app/chrome_dll.rc. | 32 // (mostly-alphabetical) order as the Windows accelerators in |
| 33 // ../../app/chrome_dll.rc. |
34 // Do not use Ctrl-Alt as a shortcut modifier, as it is used by i18n keyboards: | 34 // Do not use Ctrl-Alt as a shortcut modifier, as it is used by i18n keyboards: |
35 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx | 35 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx |
36 const AcceleratorMapping kAcceleratorMap[] = { | 36 const AcceleratorMapping kAcceleratorMap[] = { |
37 { ui::VKEY_LEFT, ui::EF_ALT_DOWN, IDC_BACK }, | |
38 { ui::VKEY_BACK, ui::EF_NONE, IDC_BACKSPACE_BACK }, | 37 { ui::VKEY_BACK, ui::EF_NONE, IDC_BACKSPACE_BACK }, |
39 { ui::VKEY_D, ui::EF_CONTROL_DOWN, IDC_BOOKMARK_PAGE }, | 38 { ui::VKEY_D, kPlatformModifier, IDC_BOOKMARK_PAGE }, |
40 { ui::VKEY_D, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 39 { ui::VKEY_D, ui::EF_SHIFT_DOWN | kPlatformModifier, |
41 IDC_BOOKMARK_ALL_TABS }, | 40 IDC_BOOKMARK_ALL_TABS }, |
42 { ui::VKEY_W, ui::EF_CONTROL_DOWN, IDC_CLOSE_TAB }, | 41 { ui::VKEY_W, kPlatformModifier, IDC_CLOSE_TAB }, |
43 { ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_CLOSE_WINDOW }, | 42 { ui::VKEY_W, ui::EF_SHIFT_DOWN | kPlatformModifier, IDC_CLOSE_WINDOW }, |
44 { ui::VKEY_F, ui::EF_CONTROL_DOWN, IDC_FIND }, | 43 { ui::VKEY_F, kPlatformModifier, IDC_FIND }, |
45 { ui::VKEY_G, ui::EF_CONTROL_DOWN, IDC_FIND_NEXT }, | 44 { ui::VKEY_G, kPlatformModifier, IDC_FIND_NEXT }, |
46 { ui::VKEY_G, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_FIND_PREVIOUS }, | 45 { ui::VKEY_G, ui::EF_SHIFT_DOWN | kPlatformModifier, IDC_FIND_PREVIOUS }, |
47 { ui::VKEY_D, ui::EF_ALT_DOWN, IDC_FOCUS_LOCATION }, | 46 { ui::VKEY_L, kPlatformModifier, IDC_FOCUS_LOCATION }, |
48 { ui::VKEY_L, ui::EF_CONTROL_DOWN, IDC_FOCUS_LOCATION }, | |
49 { ui::VKEY_K, ui::EF_CONTROL_DOWN, IDC_FOCUS_SEARCH }, | |
50 { ui::VKEY_E, ui::EF_CONTROL_DOWN, IDC_FOCUS_SEARCH }, | |
51 { ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_TOOLBAR }, | |
52 { ui::VKEY_B, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_BOOKMARKS }, | |
53 { ui::VKEY_A, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_INFOBARS }, | |
54 { ui::VKEY_RIGHT, ui::EF_ALT_DOWN, IDC_FORWARD }, | |
55 { ui::VKEY_BACK, ui::EF_SHIFT_DOWN, IDC_BACKSPACE_FORWARD }, | 47 { ui::VKEY_BACK, ui::EF_SHIFT_DOWN, IDC_BACKSPACE_FORWARD }, |
56 { ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_DEV_TOOLS }, | |
57 { ui::VKEY_F12, ui::EF_NONE, IDC_DEV_TOOLS_TOGGLE }, | 48 { ui::VKEY_F12, ui::EF_NONE, IDC_DEV_TOOLS_TOGGLE }, |
58 { ui::VKEY_J, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 49 { ui::VKEY_O, kPlatformModifier, IDC_OPEN_FILE }, |
59 IDC_DEV_TOOLS_CONSOLE }, | 50 { ui::VKEY_P, kPlatformModifier, IDC_PRINT }, |
60 { ui::VKEY_C, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 51 { ui::VKEY_R, kPlatformModifier, IDC_RELOAD }, |
61 IDC_DEV_TOOLS_INSPECT }, | 52 { ui::VKEY_R, ui::EF_SHIFT_DOWN | kPlatformModifier, |
62 { ui::VKEY_O, ui::EF_CONTROL_DOWN, IDC_OPEN_FILE }, | |
63 { ui::VKEY_P, ui::EF_CONTROL_DOWN, IDC_PRINT}, | |
64 #if defined(ENABLE_BASIC_PRINTING) | |
65 { ui::VKEY_P, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_BASIC_PRINT}, | |
66 #endif // ENABLE_BASIC_PRINTING | |
67 { ui::VKEY_R, ui::EF_CONTROL_DOWN, IDC_RELOAD }, | |
68 { ui::VKEY_R, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | |
69 IDC_RELOAD_BYPASSING_CACHE }, | 53 IDC_RELOAD_BYPASSING_CACHE }, |
70 { ui::VKEY_HOME, ui::EF_ALT_DOWN, IDC_HOME }, | 54 { ui::VKEY_S, kPlatformModifier, IDC_SAVE_PAGE }, |
71 { ui::VKEY_S, ui::EF_CONTROL_DOWN, IDC_SAVE_PAGE }, | |
72 { ui::VKEY_9, kPlatformModifier, IDC_SELECT_LAST_TAB }, | 55 { ui::VKEY_9, kPlatformModifier, IDC_SELECT_LAST_TAB }, |
73 { ui::VKEY_NUMPAD9, kPlatformModifier, IDC_SELECT_LAST_TAB }, | 56 { ui::VKEY_NUMPAD9, kPlatformModifier, IDC_SELECT_LAST_TAB }, |
74 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 57 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
75 { ui::VKEY_9, ui::EF_ALT_DOWN, IDC_SELECT_LAST_TAB }, | 58 { ui::VKEY_9, ui::EF_ALT_DOWN, IDC_SELECT_LAST_TAB }, |
76 { ui::VKEY_NUMPAD9, ui::EF_ALT_DOWN, IDC_SELECT_LAST_TAB }, | 59 { ui::VKEY_NUMPAD9, ui::EF_ALT_DOWN, IDC_SELECT_LAST_TAB }, |
77 { ui::VKEY_NEXT, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN, IDC_MOVE_TAB_NEXT }, | 60 { ui::VKEY_NEXT, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN, IDC_MOVE_TAB_NEXT }, |
78 { ui::VKEY_PRIOR, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN, | 61 { ui::VKEY_PRIOR, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN, |
79 IDC_MOVE_TAB_PREVIOUS }, | 62 IDC_MOVE_TAB_PREVIOUS }, |
80 #endif | 63 #endif |
| 64 // Control modifier is rarely used on Mac, so we allow it only in several |
| 65 // specific cases. |
81 { ui::VKEY_TAB, ui::EF_CONTROL_DOWN, IDC_SELECT_NEXT_TAB }, | 66 { ui::VKEY_TAB, ui::EF_CONTROL_DOWN, IDC_SELECT_NEXT_TAB }, |
82 { ui::VKEY_NEXT, ui::EF_CONTROL_DOWN, IDC_SELECT_NEXT_TAB }, | 67 { ui::VKEY_NEXT, ui::EF_CONTROL_DOWN, IDC_SELECT_NEXT_TAB }, |
83 { ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 68 { ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
84 IDC_SELECT_PREVIOUS_TAB }, | 69 IDC_SELECT_PREVIOUS_TAB }, |
85 { ui::VKEY_PRIOR, ui::EF_CONTROL_DOWN, IDC_SELECT_PREVIOUS_TAB }, | 70 { ui::VKEY_PRIOR, ui::EF_CONTROL_DOWN, IDC_SELECT_PREVIOUS_TAB }, |
86 { ui::VKEY_1, kPlatformModifier, IDC_SELECT_TAB_0 }, | 71 { ui::VKEY_1, kPlatformModifier, IDC_SELECT_TAB_0 }, |
87 { ui::VKEY_NUMPAD1, kPlatformModifier, IDC_SELECT_TAB_0 }, | 72 { ui::VKEY_NUMPAD1, kPlatformModifier, IDC_SELECT_TAB_0 }, |
88 { ui::VKEY_2, kPlatformModifier, IDC_SELECT_TAB_1 }, | 73 { ui::VKEY_2, kPlatformModifier, IDC_SELECT_TAB_1 }, |
89 { ui::VKEY_NUMPAD2, kPlatformModifier, IDC_SELECT_TAB_1 }, | 74 { ui::VKEY_NUMPAD2, kPlatformModifier, IDC_SELECT_TAB_1 }, |
90 { ui::VKEY_3, kPlatformModifier, IDC_SELECT_TAB_2 }, | 75 { ui::VKEY_3, kPlatformModifier, IDC_SELECT_TAB_2 }, |
(...skipping 19 matching lines...) Expand all Loading... |
110 { ui::VKEY_NUMPAD4, ui::EF_ALT_DOWN, IDC_SELECT_TAB_3 }, | 95 { ui::VKEY_NUMPAD4, ui::EF_ALT_DOWN, IDC_SELECT_TAB_3 }, |
111 { ui::VKEY_5, ui::EF_ALT_DOWN, IDC_SELECT_TAB_4 }, | 96 { ui::VKEY_5, ui::EF_ALT_DOWN, IDC_SELECT_TAB_4 }, |
112 { ui::VKEY_NUMPAD5, ui::EF_ALT_DOWN, IDC_SELECT_TAB_4 }, | 97 { ui::VKEY_NUMPAD5, ui::EF_ALT_DOWN, IDC_SELECT_TAB_4 }, |
113 { ui::VKEY_6, ui::EF_ALT_DOWN, IDC_SELECT_TAB_5 }, | 98 { ui::VKEY_6, ui::EF_ALT_DOWN, IDC_SELECT_TAB_5 }, |
114 { ui::VKEY_NUMPAD6, ui::EF_ALT_DOWN, IDC_SELECT_TAB_5 }, | 99 { ui::VKEY_NUMPAD6, ui::EF_ALT_DOWN, IDC_SELECT_TAB_5 }, |
115 { ui::VKEY_7, ui::EF_ALT_DOWN, IDC_SELECT_TAB_6 }, | 100 { ui::VKEY_7, ui::EF_ALT_DOWN, IDC_SELECT_TAB_6 }, |
116 { ui::VKEY_NUMPAD7, ui::EF_ALT_DOWN, IDC_SELECT_TAB_6 }, | 101 { ui::VKEY_NUMPAD7, ui::EF_ALT_DOWN, IDC_SELECT_TAB_6 }, |
117 { ui::VKEY_8, ui::EF_ALT_DOWN, IDC_SELECT_TAB_7 }, | 102 { ui::VKEY_8, ui::EF_ALT_DOWN, IDC_SELECT_TAB_7 }, |
118 { ui::VKEY_NUMPAD8, ui::EF_ALT_DOWN, IDC_SELECT_TAB_7 }, | 103 { ui::VKEY_NUMPAD8, ui::EF_ALT_DOWN, IDC_SELECT_TAB_7 }, |
119 { ui::VKEY_BROWSER_FAVORITES, ui::EF_NONE, IDC_SHOW_BOOKMARK_BAR }, | 104 { ui::VKEY_BROWSER_FAVORITES, ui::EF_NONE, IDC_SHOW_BOOKMARK_BAR }, |
120 #endif | 105 #endif // OS_LINUX && !OS_CHROMEOS |
121 { ui::VKEY_B, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 106 { ui::VKEY_B, ui::EF_SHIFT_DOWN | kPlatformModifier, |
122 IDC_SHOW_BOOKMARK_BAR }, | 107 IDC_SHOW_BOOKMARK_BAR }, |
123 { ui::VKEY_O, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | |
124 IDC_SHOW_BOOKMARK_MANAGER }, | |
125 { ui::VKEY_J, ui::EF_CONTROL_DOWN, IDC_SHOW_DOWNLOADS }, | |
126 { ui::VKEY_H, ui::EF_CONTROL_DOWN, IDC_SHOW_HISTORY }, | |
127 { ui::VKEY_F, ui::EF_ALT_DOWN, IDC_SHOW_APP_MENU}, | |
128 { ui::VKEY_E, ui::EF_ALT_DOWN, IDC_SHOW_APP_MENU}, | |
129 { ui::VKEY_ESCAPE, ui::EF_NONE, IDC_STOP }, | 108 { ui::VKEY_ESCAPE, ui::EF_NONE, IDC_STOP }, |
130 { ui::VKEY_U, ui::EF_CONTROL_DOWN, IDC_VIEW_SOURCE }, | 109 { ui::VKEY_OEM_MINUS, kPlatformModifier, IDC_ZOOM_MINUS }, |
131 { ui::VKEY_OEM_MINUS, ui::EF_CONTROL_DOWN, IDC_ZOOM_MINUS }, | 110 { ui::VKEY_SUBTRACT, kPlatformModifier, IDC_ZOOM_MINUS }, |
132 { ui::VKEY_SUBTRACT, ui::EF_CONTROL_DOWN, IDC_ZOOM_MINUS }, | 111 { ui::VKEY_0, kPlatformModifier, IDC_ZOOM_NORMAL }, |
133 { ui::VKEY_0, ui::EF_CONTROL_DOWN, IDC_ZOOM_NORMAL }, | 112 { ui::VKEY_NUMPAD0, kPlatformModifier, IDC_ZOOM_NORMAL }, |
134 { ui::VKEY_NUMPAD0, ui::EF_CONTROL_DOWN, IDC_ZOOM_NORMAL }, | 113 { ui::VKEY_OEM_PLUS, kPlatformModifier, IDC_ZOOM_PLUS }, |
135 { ui::VKEY_OEM_PLUS, ui::EF_CONTROL_DOWN, IDC_ZOOM_PLUS }, | 114 { ui::VKEY_ADD, kPlatformModifier, IDC_ZOOM_PLUS }, |
136 { ui::VKEY_ADD, ui::EF_CONTROL_DOWN, IDC_ZOOM_PLUS }, | 115 |
| 116 #if !defined(OS_MACOSX) // Function keys aren't mapped on Mac. |
137 { ui::VKEY_F1, ui::EF_NONE, IDC_HELP_PAGE_VIA_KEYBOARD }, | 117 { ui::VKEY_F1, ui::EF_NONE, IDC_HELP_PAGE_VIA_KEYBOARD }, |
138 { ui::VKEY_F3, ui::EF_NONE, IDC_FIND_NEXT }, | 118 { ui::VKEY_F3, ui::EF_NONE, IDC_FIND_NEXT }, |
139 { ui::VKEY_F3, ui::EF_SHIFT_DOWN, IDC_FIND_PREVIOUS }, | 119 { ui::VKEY_F3, ui::EF_SHIFT_DOWN, IDC_FIND_PREVIOUS }, |
140 { ui::VKEY_F4, ui::EF_CONTROL_DOWN, IDC_CLOSE_TAB }, | 120 { ui::VKEY_F4, ui::EF_CONTROL_DOWN, IDC_CLOSE_TAB }, |
141 { ui::VKEY_F4, ui::EF_ALT_DOWN, IDC_CLOSE_WINDOW }, | 121 { ui::VKEY_F4, ui::EF_ALT_DOWN, IDC_CLOSE_WINDOW }, |
142 { ui::VKEY_F5, ui::EF_NONE, IDC_RELOAD }, | 122 { ui::VKEY_F5, ui::EF_NONE, IDC_RELOAD }, |
143 { ui::VKEY_F5, ui::EF_CONTROL_DOWN, IDC_RELOAD_BYPASSING_CACHE }, | 123 { ui::VKEY_F5, ui::EF_CONTROL_DOWN, IDC_RELOAD_BYPASSING_CACHE }, |
144 { ui::VKEY_F5, ui::EF_SHIFT_DOWN, IDC_RELOAD_BYPASSING_CACHE }, | 124 { ui::VKEY_F5, ui::EF_SHIFT_DOWN, IDC_RELOAD_BYPASSING_CACHE }, |
145 { ui::VKEY_F6, ui::EF_NONE, IDC_FOCUS_NEXT_PANE }, | 125 { ui::VKEY_F6, ui::EF_NONE, IDC_FOCUS_NEXT_PANE }, |
146 { ui::VKEY_F6, ui::EF_SHIFT_DOWN, IDC_FOCUS_PREVIOUS_PANE }, | 126 { ui::VKEY_F6, ui::EF_SHIFT_DOWN, IDC_FOCUS_PREVIOUS_PANE }, |
147 { ui::VKEY_F10, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, | 127 { ui::VKEY_F10, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, |
148 { ui::VKEY_F11, ui::EF_NONE, IDC_FULLSCREEN }, | 128 { ui::VKEY_F11, ui::EF_NONE, IDC_FULLSCREEN }, |
| 129 #endif // !OS_MACOSX |
149 | 130 |
150 // Platform-specific key maps. | 131 // Platform-specific key maps. |
151 #if defined(OS_LINUX) | 132 #if defined(OS_LINUX) |
152 { ui::VKEY_BROWSER_BACK, ui::EF_NONE, IDC_BACK }, | 133 { ui::VKEY_BROWSER_BACK, ui::EF_NONE, IDC_BACK }, |
153 { ui::VKEY_BROWSER_FORWARD, ui::EF_NONE, IDC_FORWARD }, | 134 { ui::VKEY_BROWSER_FORWARD, ui::EF_NONE, IDC_FORWARD }, |
154 { ui::VKEY_BROWSER_HOME, ui::EF_NONE, IDC_HOME }, | 135 { ui::VKEY_BROWSER_HOME, ui::EF_NONE, IDC_HOME }, |
155 { ui::VKEY_BROWSER_REFRESH, ui::EF_NONE, IDC_RELOAD }, | 136 { ui::VKEY_BROWSER_REFRESH, ui::EF_NONE, IDC_RELOAD }, |
156 { ui::VKEY_BROWSER_REFRESH, ui::EF_CONTROL_DOWN, IDC_RELOAD_BYPASSING_CACHE }, | 137 { ui::VKEY_BROWSER_REFRESH, ui::EF_CONTROL_DOWN, IDC_RELOAD_BYPASSING_CACHE }, |
157 { ui::VKEY_BROWSER_REFRESH, ui::EF_SHIFT_DOWN, IDC_RELOAD_BYPASSING_CACHE }, | 138 { ui::VKEY_BROWSER_REFRESH, ui::EF_SHIFT_DOWN, IDC_RELOAD_BYPASSING_CACHE }, |
158 #endif // defined(OS_LINUX) | 139 #endif // defined(OS_LINUX) |
159 | 140 |
160 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
161 // On Chrome OS, VKEY_BROWSER_SEARCH is handled in Ash. | 142 // On Chrome OS, VKEY_BROWSER_SEARCH is handled in Ash. |
162 { ui::VKEY_BACK, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 143 { ui::VKEY_BACK, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
163 IDC_CLEAR_BROWSING_DATA }, | 144 IDC_CLEAR_BROWSING_DATA }, |
164 { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN, IDC_HELP_PAGE_VIA_KEYBOARD }, | 145 { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN, IDC_HELP_PAGE_VIA_KEYBOARD }, |
165 { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 146 { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
166 IDC_HELP_PAGE_VIA_KEYBOARD }, | 147 IDC_HELP_PAGE_VIA_KEYBOARD }, |
167 { ui::VKEY_BROWSER_FAVORITES, ui::EF_NONE, IDC_SHOW_BOOKMARK_MANAGER }, | 148 { ui::VKEY_BROWSER_FAVORITES, ui::EF_NONE, IDC_SHOW_BOOKMARK_MANAGER }, |
168 { ui::VKEY_BROWSER_STOP, ui::EF_NONE, IDC_STOP }, | 149 { ui::VKEY_BROWSER_STOP, ui::EF_NONE, IDC_STOP }, |
169 { ui::VKEY_P, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, | 150 { ui::VKEY_P, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, |
170 IDC_TOUCH_HUD_PROJECTION_TOGGLE }, | 151 IDC_TOUCH_HUD_PROJECTION_TOGGLE }, |
171 #else // OS_CHROMEOS | 152 #else // !OS_CHROMEOS |
172 { ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN, IDC_TASK_MANAGER }, | 153 { ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN, IDC_TASK_MANAGER }, |
173 { ui::VKEY_DELETE, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | |
174 IDC_CLEAR_BROWSING_DATA }, | |
175 { ui::VKEY_LMENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, | 154 { ui::VKEY_LMENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, |
176 { ui::VKEY_MENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, | 155 { ui::VKEY_MENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, |
177 { ui::VKEY_RMENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, | 156 { ui::VKEY_RMENU, ui::EF_NONE, IDC_FOCUS_MENU_BAR }, |
178 // On Windows, all VKEY_BROWSER_* keys except VKEY_BROWSER_SEARCH are handled | 157 // On Windows, all VKEY_BROWSER_* keys except VKEY_BROWSER_SEARCH are handled |
179 // via WM_APPCOMMAND. | 158 // via WM_APPCOMMAND. |
180 { ui::VKEY_BROWSER_SEARCH, ui::EF_NONE, IDC_FOCUS_SEARCH }, | 159 { ui::VKEY_BROWSER_SEARCH, ui::EF_NONE, IDC_FOCUS_SEARCH }, |
181 { ui::VKEY_M, ui::EF_SHIFT_DOWN | kPlatformModifier, IDC_SHOW_AVATAR_MENU}, | 160 { ui::VKEY_M, ui::EF_SHIFT_DOWN | kPlatformModifier, IDC_SHOW_AVATAR_MENU }, |
| 161 // For each entry until the end of the !OS_CHROMEOS block, and an entry into |
| 162 // kChromeCmdId2AshActionId below if Ash has a corresponding accelerator. |
| 163 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_MACOSX) |
| 164 { ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FEEDBACK }, |
| 165 #endif // GOOGLE_CHROME_BUILD && !OS_MACOSX |
| 166 #if !defined(OS_MACOSX) |
| 167 { ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_EXIT }, |
| 168 #endif // !OS_MACOSX |
| 169 { ui::VKEY_N, ui::EF_SHIFT_DOWN | kPlatformModifier, |
| 170 IDC_NEW_INCOGNITO_WINDOW }, |
| 171 { ui::VKEY_T, kPlatformModifier, IDC_NEW_TAB }, |
| 172 { ui::VKEY_N, kPlatformModifier, IDC_NEW_WINDOW }, |
| 173 { ui::VKEY_T, ui::EF_SHIFT_DOWN | kPlatformModifier, IDC_RESTORE_TAB }, |
| 174 #endif // !OS_CHROMEOS |
| 175 |
| 176 #if defined(OS_MACOSX) |
| 177 // VKEY_OEM_4 is Left Brace '[{' key. |
| 178 { ui::VKEY_OEM_4, ui::EF_COMMAND_DOWN, IDC_BACK }, |
| 179 { ui::VKEY_LEFT, ui::EF_COMMAND_DOWN, IDC_BACK }, |
| 180 #if defined(ENABLE_BASIC_PRINTING) |
| 181 { ui::VKEY_P, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_BASIC_PRINT }, |
| 182 #endif // ENABLE_BASIC_PRINTING |
| 183 { ui::VKEY_BACK, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, |
| 184 IDC_CLEAR_BROWSING_DATA }, |
| 185 { ui::VKEY_V, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, |
| 186 IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE }, |
| 187 { ui::VKEY_Z, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, |
| 188 IDC_CONTENT_CONTEXT_REDO }, |
| 189 { ui::VKEY_A, ui::EF_COMMAND_DOWN, IDC_CONTENT_CONTEXT_SELECTALL }, |
| 190 { ui::VKEY_Z, ui::EF_COMMAND_DOWN, IDC_CONTENT_CONTEXT_UNDO }, |
| 191 { ui::VKEY_I, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_DEV_TOOLS }, |
| 192 { ui::VKEY_J, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_DEV_TOOLS_CONSOLE }, |
| 193 { ui::VKEY_C, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, IDC_DEV_TOOLS_INSPECT}, |
| 194 { ui::VKEY_I, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, |
| 195 IDC_EMAIL_PAGE_LOCATION }, |
| 196 { ui::VKEY_Q, ui::EF_COMMAND_DOWN, IDC_EXIT }, |
| 197 { ui::VKEY_F, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_SEARCH }, |
| 198 // VKEY_OEM_6 is Right Brace ']}' key. |
| 199 { ui::VKEY_OEM_6, ui::EF_COMMAND_DOWN, IDC_FORWARD }, |
| 200 { ui::VKEY_RIGHT, ui::EF_COMMAND_DOWN, IDC_FORWARD }, |
| 201 { ui::VKEY_F, ui::EF_COMMAND_DOWN | ui::EF_CONTROL_DOWN, IDC_FULLSCREEN }, |
| 202 // VKEY_OEM_2 is Slash '/?' key. |
| 203 { ui::VKEY_OEM_2, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, |
| 204 IDC_HELP_PAGE_VIA_MENU }, |
| 205 { ui::VKEY_H, ui::EF_COMMAND_DOWN, IDC_HIDE_APP }, |
| 206 { ui::VKEY_H, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, IDC_HOME }, |
| 207 { ui::VKEY_M, ui::EF_COMMAND_DOWN, IDC_MINIMIZE_WINDOW }, |
| 208 { ui::VKEY_RIGHT, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, |
| 209 IDC_SELECT_NEXT_TAB }, |
| 210 { ui::VKEY_LEFT, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, |
| 211 IDC_SELECT_PREVIOUS_TAB }, |
| 212 { ui::VKEY_B, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, |
| 213 IDC_SHOW_BOOKMARK_MANAGER }, |
| 214 { ui::VKEY_J, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, IDC_SHOW_DOWNLOADS }, |
| 215 { ui::VKEY_L, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_SHOW_DOWNLOADS }, |
| 216 { ui::VKEY_Y, ui::EF_COMMAND_DOWN, IDC_SHOW_HISTORY }, |
| 217 { ui::VKEY_OEM_PERIOD, ui::EF_COMMAND_DOWN, IDC_STOP }, |
| 218 { ui::VKEY_U, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN, IDC_VIEW_SOURCE }, |
| 219 #else // !OS_MACOSX |
| 220 // Alt by itself (or with just shift) is never used on Mac since it's used |
| 221 // to generate non-ASCII characters. Such commands are given Mac-specific |
| 222 // bindings as well. Mapping with just Alt appear here, and should have an |
| 223 // alternative mapping in the block above. |
| 224 { ui::VKEY_LEFT, ui::EF_ALT_DOWN, IDC_BACK }, |
| 225 #if defined(ENABLE_BASIC_PRINTING) |
| 226 { ui::VKEY_P, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_BASIC_PRINT}, |
| 227 #endif // ENABLE_BASIC_PRINTING |
| 228 #if !defined(OS_CHROMEOS) |
| 229 { ui::VKEY_DELETE, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
| 230 IDC_CLEAR_BROWSING_DATA }, |
| 231 #endif // !OS_CHROMEOS |
| 232 { ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_DEV_TOOLS }, |
| 233 { ui::VKEY_J, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
| 234 IDC_DEV_TOOLS_CONSOLE }, |
| 235 { ui::VKEY_C, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
| 236 IDC_DEV_TOOLS_INSPECT }, |
| 237 { ui::VKEY_B, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_BOOKMARKS }, |
| 238 { ui::VKEY_A, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_INFOBARS }, |
| 239 { ui::VKEY_D, ui::EF_ALT_DOWN, IDC_FOCUS_LOCATION }, |
| 240 { ui::VKEY_E, ui::EF_CONTROL_DOWN, IDC_FOCUS_SEARCH }, |
| 241 { ui::VKEY_K, ui::EF_CONTROL_DOWN, IDC_FOCUS_SEARCH }, |
| 242 { ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FOCUS_TOOLBAR }, |
| 243 { ui::VKEY_RIGHT, ui::EF_ALT_DOWN, IDC_FORWARD }, |
| 244 { ui::VKEY_HOME, ui::EF_ALT_DOWN, IDC_HOME }, |
| 245 { ui::VKEY_E, ui::EF_ALT_DOWN, IDC_SHOW_APP_MENU}, |
| 246 { ui::VKEY_F, ui::EF_ALT_DOWN, IDC_SHOW_APP_MENU}, |
| 247 { ui::VKEY_O, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
| 248 IDC_SHOW_BOOKMARK_MANAGER }, |
| 249 { ui::VKEY_J, ui::EF_CONTROL_DOWN, IDC_SHOW_DOWNLOADS }, |
| 250 { ui::VKEY_H, ui::EF_CONTROL_DOWN, IDC_SHOW_HISTORY }, |
| 251 { ui::VKEY_U, ui::EF_CONTROL_DOWN, IDC_VIEW_SOURCE }, |
| 252 #if !defined(OS_CHROMEOS) |
182 // On Chrome OS, these keys are assigned to change UI scale. | 253 // On Chrome OS, these keys are assigned to change UI scale. |
183 { ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_ZOOM_PLUS }, | |
184 { ui::VKEY_OEM_MINUS, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | 254 { ui::VKEY_OEM_MINUS, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
185 IDC_ZOOM_MINUS }, | 255 IDC_ZOOM_MINUS }, |
186 // For each entry here add an entry into kChromeCmdId2AshActionId below | 256 { ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, |
187 // if Ash has a corresponding accelerator. | 257 IDC_ZOOM_PLUS }, |
188 #if defined(GOOGLE_CHROME_BUILD) | 258 #endif // !OS_CHROMEOS |
189 { ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, IDC_FEEDBACK }, | 259 #endif // OS_MACOSX |
190 #endif | |
191 { ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_EXIT }, | |
192 { ui::VKEY_N, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, | |
193 IDC_NEW_INCOGNITO_WINDOW }, | |
194 { ui::VKEY_T, ui::EF_CONTROL_DOWN, IDC_NEW_TAB }, | |
195 { ui::VKEY_N, ui::EF_CONTROL_DOWN, IDC_NEW_WINDOW }, | |
196 { ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_RESTORE_TAB }, | |
197 #endif | |
198 }; | 260 }; |
199 const size_t kAcceleratorMapLength = arraysize(kAcceleratorMap); | |
200 | 261 |
201 const int kRepeatableCommandIds[] = { | 262 const int kRepeatableCommandIds[] = { |
202 IDC_FIND_NEXT, | 263 IDC_FIND_NEXT, |
203 IDC_FIND_PREVIOUS, | 264 IDC_FIND_PREVIOUS, |
204 IDC_FOCUS_NEXT_PANE, | 265 IDC_FOCUS_NEXT_PANE, |
205 IDC_FOCUS_PREVIOUS_PANE, | 266 IDC_FOCUS_PREVIOUS_PANE, |
206 IDC_MOVE_TAB_NEXT, | 267 IDC_MOVE_TAB_NEXT, |
207 IDC_MOVE_TAB_PREVIOUS, | 268 IDC_MOVE_TAB_PREVIOUS, |
208 IDC_SELECT_NEXT_TAB, | 269 IDC_SELECT_NEXT_TAB, |
209 IDC_SELECT_PREVIOUS_TAB, | 270 IDC_SELECT_PREVIOUS_TAB, |
(...skipping 22 matching lines...) Expand all Loading... |
232 { IDC_TOUCH_HUD_PROJECTION_TOGGLE, ash::TOUCH_HUD_PROJECTION_TOGGLE }, | 293 { IDC_TOUCH_HUD_PROJECTION_TOGGLE, ash::TOUCH_HUD_PROJECTION_TOGGLE }, |
233 #endif | 294 #endif |
234 }; | 295 }; |
235 const size_t kChromeCmdId2AshActionIdLength = | 296 const size_t kChromeCmdId2AshActionIdLength = |
236 arraysize(kChromeCmdId2AshActionId); | 297 arraysize(kChromeCmdId2AshActionId); |
237 #endif // defined(USE_ASH) | 298 #endif // defined(USE_ASH) |
238 | 299 |
239 } // namespace | 300 } // namespace |
240 | 301 |
241 std::vector<AcceleratorMapping> GetAcceleratorList() { | 302 std::vector<AcceleratorMapping> GetAcceleratorList() { |
242 return std::vector<AcceleratorMapping>( | 303 CR_DEFINE_STATIC_LOCAL( |
243 kAcceleratorMap, kAcceleratorMap + kAcceleratorMapLength); | 304 std::vector<AcceleratorMapping>, accelerators, |
| 305 (std::begin(kAcceleratorMap), std::end(kAcceleratorMap))); |
| 306 return accelerators; |
244 } | 307 } |
245 | 308 |
246 bool GetAshAcceleratorForCommandId(int command_id, | 309 bool GetAshAcceleratorForCommandId(int command_id, |
247 ui::Accelerator* accelerator) { | 310 ui::Accelerator* accelerator) { |
248 #if defined(USE_ASH) | 311 #if defined(USE_ASH) |
249 for (size_t i = 0; i < kChromeCmdId2AshActionIdLength; ++i) { | 312 for (size_t i = 0; i < kChromeCmdId2AshActionIdLength; ++i) { |
250 if (command_id == kChromeCmdId2AshActionId[i].chrome_cmd_id) { | 313 if (command_id == kChromeCmdId2AshActionId[i].chrome_cmd_id) { |
251 for (size_t j = 0; j < ash::kAcceleratorDataLength; ++j) { | 314 for (size_t j = 0; j < ash::kAcceleratorDataLength; ++j) { |
252 if (kChromeCmdId2AshActionId[i].ash_action_id == | 315 if (kChromeCmdId2AshActionId[i].ash_action_id == |
253 ash::kAcceleratorData[j].action) { | 316 ash::kAcceleratorData[j].action) { |
254 *accelerator = ui::Accelerator(ash::kAcceleratorData[j].keycode, | 317 *accelerator = ui::Accelerator(ash::kAcceleratorData[j].keycode, |
255 ash::kAcceleratorData[j].modifiers); | 318 ash::kAcceleratorData[j].modifiers); |
256 return true; | 319 return true; |
257 } | 320 } |
258 } | 321 } |
259 } | 322 } |
260 } | 323 } |
261 #endif // defined(USE_ASH) | 324 #endif // defined(USE_ASH) |
262 return false; | 325 return false; |
263 } | 326 } |
264 | 327 |
265 bool GetStandardAcceleratorForCommandId(int command_id, | 328 bool GetStandardAcceleratorForCommandId(int command_id, |
266 ui::Accelerator* accelerator) { | 329 ui::Accelerator* accelerator) { |
267 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 330 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
268 // anywhere else. | 331 // anywhere else. |
269 switch (command_id) { | 332 switch (command_id) { |
270 case IDC_CUT: | 333 case IDC_CUT: |
271 *accelerator = ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN); | 334 *accelerator = ui::Accelerator(ui::VKEY_X, kPlatformModifier); |
272 return true; | 335 return true; |
273 case IDC_COPY: | 336 case IDC_COPY: |
274 *accelerator = ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN); | 337 *accelerator = ui::Accelerator(ui::VKEY_C, kPlatformModifier); |
275 return true; | 338 return true; |
276 case IDC_PASTE: | 339 case IDC_PASTE: |
277 *accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN); | 340 *accelerator = ui::Accelerator(ui::VKEY_V, kPlatformModifier); |
278 return true; | 341 return true; |
279 } | 342 } |
280 return false; | 343 return false; |
281 } | 344 } |
282 | 345 |
283 bool IsCommandRepeatable(int command_id) { | 346 bool IsCommandRepeatable(int command_id) { |
284 for (size_t i = 0; i < kRepeatableCommandIdsLength; ++i) { | 347 for (size_t i = 0; i < kRepeatableCommandIdsLength; ++i) { |
285 if (kRepeatableCommandIds[i] == command_id) | 348 if (kRepeatableCommandIds[i] == command_id) |
286 return true; | 349 return true; |
287 } | 350 } |
288 return false; | 351 return false; |
289 } | 352 } |
290 | 353 |
291 } // namespace chrome | 354 } // namespace chrome |
OLD | NEW |