OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 5 #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
6 #define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 6 #define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 struct KeyboardShortcutData { | 10 struct KeyboardShortcutData { |
11 bool command_key; | 11 bool command_key; |
12 bool shift_key; | 12 bool shift_key; |
13 bool cntrl_key; | 13 bool cntrl_key; |
14 bool opt_key; | 14 bool opt_key; |
15 int vkey_code; // Virtual Key code for the command. | 15 int vkey_code; // Virtual Key code for the command. |
16 int chrome_command; // The chrome command # to execute for this shortcut. | 16 int chrome_command; // The chrome command # to execute for this shortcut. |
17 }; | 17 }; |
18 | 18 |
19 // Check if a given keycode + modifiers correspond to a given Chrome command. | 19 // Check if a given keycode + modifiers correspond to a given Chrome command. |
20 // returns: Command number (as passed to Browser::ExecuteCommand) or -1 if there | 20 // returns: Command number (as passed to Browser::ExecuteCommand) or -1 if there |
21 // was no match. | 21 // was no match. |
22 // | 22 // |
23 // |performKeyEquivalent:| bubbles events up from the window to the views. | 23 // |performKeyEquivalent:| bubbles events up from the window to the views. If |
24 // If we let it bubble up to the Omnibox, then the Omnibox handles | 24 // we let it bubble up to the Omnibox, then the Omnibox handles cmd-left/right |
25 // cmd-left/right just fine, but it swallows cmd-1 and doesn't give us a chance | 25 // just fine, but it swallows cmd-1 and doesn't give us a chance to intercept |
26 // to intercept this. Hence, we need two types of keyboard shortcuts. | 26 // this. Hence, we need three types of keyboard shortcuts: shortcuts that are |
| 27 // intercepted before the Omnibox handles events, shortcuts that are |
| 28 // intercepted after the Omnibox had a chance but did not handle them, and |
| 29 // shortcuts that are only handled when tab contents is focused. |
27 // | 30 // |
28 // This means cmd-left doesn't work if you hit cmd-l tab, which focusses | 31 // This means cmd-left doesn't work if you hit cmd-l tab, which focusses |
29 // something that's neither omnibox nor tab contents. This behavior is | 32 // something that's neither omnibox nor tab contents. This behavior is |
30 // consistent with safari and camino, and I think it's the best we can do | 33 // consistent with safari and camino, and I think it's the best we can do |
31 // without rewriting event dispatching ( http://crbug.com/251069 ). | 34 // without rewriting event dispatching ( http://crbug.com/251069 ). |
32 | 35 |
33 // This returns shortcuts that should work no matter what component of the | 36 // This returns shortcuts that should work no matter what component of the |
34 // browser is focused. They are executed by the window, before any view has the | 37 // browser is focused. They are executed by the window, before any view has the |
35 // opportunity to override the shortcut (with the exception of the tab contents, | 38 // opportunity to override the shortcut (with the exception of the tab contents, |
36 // which first checks if the current web page wants to handle the shortcut). | 39 // which first checks if the current web page wants to handle the shortcut). |
37 int CommandForWindowKeyboardShortcut( | 40 int CommandForWindowKeyboardShortcut( |
38 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, | 41 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
39 int vkey_code); | 42 int vkey_code); |
40 | 43 |
| 44 // This returns shortcuts that should work no matter what component of the |
| 45 // browser is focused. They are executed by the window, after any view has the |
| 46 // opportunity to override the shortcut |
| 47 int CommandForDelayedWindowKeyboardShortcut( |
| 48 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
| 49 int vkey_code); |
| 50 |
41 // This returns shortcuts that should work only if the tab contents have focus | 51 // This returns shortcuts that should work only if the tab contents have focus |
42 // (e.g. cmd-left, which shouldn't do history navigation if e.g. the omnibox has | 52 // (e.g. cmd-left, which shouldn't do history navigation if e.g. the omnibox has |
43 // focus). | 53 // focus). |
44 int CommandForBrowserKeyboardShortcut( | 54 int CommandForBrowserKeyboardShortcut( |
45 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, | 55 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
46 int vkey_code); | 56 int vkey_code); |
47 | 57 |
48 // For testing purposes. | 58 // For testing purposes. |
49 const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries); | 59 const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries); |
50 const KeyboardShortcutData* | 60 const KeyboardShortcutData* |
| 61 GetDelayedWindowKeyboardShortcutTable(size_t* num_entries); |
| 62 const KeyboardShortcutData* |
51 GetBrowserKeyboardShortcutTable(size_t* num_entries); | 63 GetBrowserKeyboardShortcutTable(size_t* num_entries); |
52 | 64 |
53 #endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 65 #endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
OLD | NEW |