BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / global_keyboard_shortcuts_mac.h
blobb478005e2ba9e711d53a1ab148b7bb9b0603256d
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_
6 #define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_
8 #include <Carbon/Carbon.h> // For unichar.
10 #include "base/basictypes.h"
12 @class NSEvent;
14 struct KeyboardShortcutData {
15 bool command_key;
16 bool shift_key;
17 bool cntrl_key;
18 bool opt_key;
19 // Either one of vkey_code or key_char must be specified. For keys
20 // whose virtual key code is hardware-dependent (kVK_ANSI_*) key_char
21 // should be specified instead.
22 // Set 0 for the one you do not want to specify.
23 int vkey_code; // Virtual Key code for the command.
24 unichar key_char; // Key event characters for the command as reported by
25 // [NSEvent charactersIgnoringModifiers].
26 int chrome_command; // The chrome command # to execute for this shortcut.
29 // Check if a given keycode + modifiers (or keychar + modifiers if the
30 // |key_char| is specified) correspond to a given Chrome command.
31 // returns: Command number (as passed to
32 // BrowserCommandController::ExecuteCommand) or -1 if there was no match.
34 // |performKeyEquivalent:| bubbles events up from the window to the views. If
35 // we let it bubble up to the Omnibox, then the Omnibox handles cmd-left/right
36 // just fine, but it swallows cmd-1 and doesn't give us a chance to intercept
37 // this. Hence, we need three types of keyboard shortcuts: shortcuts that are
38 // intercepted before the Omnibox handles events, shortcuts that are
39 // intercepted after the Omnibox had a chance but did not handle them, and
40 // shortcuts that are only handled when tab contents is focused.
42 // This means cmd-left doesn't work if you hit cmd-l tab, which focusses
43 // something that's neither omnibox nor tab contents. This behavior is
44 // consistent with safari and camino, and I think it's the best we can do
45 // without rewriting event dispatching ( http://crbug.com/251069 ).
47 // This returns shortcuts that should work no matter what component of the
48 // browser is focused. They are executed by the window, before any view has the
49 // opportunity to override the shortcut (with the exception of the tab contents,
50 // which first checks if the current web page wants to handle the shortcut).
51 int CommandForWindowKeyboardShortcut(
52 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
53 int vkey_code, unichar key_char);
55 // This returns shortcuts that should work no matter what component of the
56 // browser is focused. They are executed by the window, after any view has the
57 // opportunity to override the shortcut
58 int CommandForDelayedWindowKeyboardShortcut(
59 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
60 int vkey_code, unichar key_char);
62 // This returns shortcuts that should work only if the tab contents have focus
63 // (e.g. cmd-left, which shouldn't do history navigation if e.g. the omnibox has
64 // focus).
65 int CommandForBrowserKeyboardShortcut(
66 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
67 int vkey_code, unichar key_char);
69 // Returns the Chrome command associated with |event|, or -1 if not found.
70 int CommandForKeyEvent(NSEvent* event);
72 // Returns a keyboard event character for the given |event|. In most cases
73 // this returns the first character of [NSEvent charactersIgnoringModifiers],
74 // but when [NSEvent character] has different printable ascii character
75 // we may return the first character of [NSEvent characters] instead.
76 // (E.g. for dvorak-qwerty layout we want [NSEvent characters] rather than
77 // [charactersIgnoringModifiers] for command keys. Similarly, on german
78 // layout we want '{' character rather than '8' for opt-8.)
79 unichar KeyCharacterForEvent(NSEvent* event);
81 // For testing purposes.
82 const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries);
83 const KeyboardShortcutData*
84 GetDelayedWindowKeyboardShortcutTable(size_t* num_entries);
85 const KeyboardShortcutData*
86 GetBrowserKeyboardShortcutTable(size_t* num_entries);
88 #endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_