blob: 13a4587eeed8d77d7eda34bda6009a5f1d2dbed5 [file] [log] [blame]
[email protected]3641da6c2009-07-08 14:59:061// 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.
4
5#ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_
6#define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_
7
[email protected]70be00a2009-07-08 23:40:088#include "base/basictypes.h"
[email protected]3641da6c2009-07-08 14:59:069
10struct KeyboardShortcutData {
11 bool command_key;
12 bool shift_key;
13 bool cntrl_key;
[email protected]f7378a32009-10-21 17:15:2814 bool opt_key;
[email protected]3641da6c2009-07-08 14:59:0615 int vkey_code; // Virtual Key code for the command.
16 int chrome_command; // The chrome command # to execute for this shortcut.
17};
18
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
21// was no match.
[email protected]1d313b832009-10-09 01:26:2022//
23// |performKeyEquivalent:| bubbles events up from the window to the views.
24// If we let it bubble up to the Omnibox, then the Omnibox handles
25// cmd-left/right just fine, but it swallows cmd-1 and doesn't give us a chance
[email protected]972cec22009-10-09 16:49:2226// to intercept this. Hence, we need two types of keyboard shortcuts.
[email protected]1d313b832009-10-09 01:26:2027//
28// 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
30// consistent with safari and camino, and I think it's the best we can do
31// without rewriting event dispatching ( http://crbug.com/251069 ).
32
33// 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
35// 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).
37int CommandForWindowKeyboardShortcut(
[email protected]f7378a32009-10-21 17:15:2838 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
39 int vkey_code);
[email protected]1d313b832009-10-09 01:26:2040
41// 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
43// focus).
44int CommandForBrowserKeyboardShortcut(
[email protected]f7378a32009-10-21 17:15:2845 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
46 int vkey_code);
[email protected]3641da6c2009-07-08 14:59:0647
48// For testing purposes.
[email protected]1d313b832009-10-09 01:26:2049const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries);
50const KeyboardShortcutData*
51 GetBrowserKeyboardShortcutTable(size_t* num_entries);
[email protected]3641da6c2009-07-08 14:59:0652
53#endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_