Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/global_keyboard_shortcuts_mac.mm

Issue 491023: Add a keyboard shortcut on Escape that emits the IDC_STOP command.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <Carbon/Carbon.h> 5 #include <Carbon/Carbon.h>
6 6
7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
11 11
12 // Basically, there are two kinds of keyboard shortcuts: Ones that should work
13 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that
14 // should work in all other cases (WindowKeyboardShortcut). In the latter case,
15 // we differentiate between shortcuts that are checked before any other view
16 // gets the chance to handle them (WindowKeyboardShortcut) or after all views
17 // had a chance but did not handle the keypress event
18 // (DelayedWindowKeyboardShortcut)
19
12 const KeyboardShortcutData* GetWindowKeyboardShortcutTable 20 const KeyboardShortcutData* GetWindowKeyboardShortcutTable
13 (size_t* num_entries) { 21 (size_t* num_entries) {
14 static const KeyboardShortcutData keyboard_shortcuts[] = { 22 static const KeyboardShortcutData keyboard_shortcuts[] = {
15 {true, true, false, false, kVK_ANSI_RightBracket, IDC_SELECT_NEXT_TAB}, 23 {true, true, false, false, kVK_ANSI_RightBracket, IDC_SELECT_NEXT_TAB},
16 {false, false, true, false, kVK_PageDown, IDC_SELECT_NEXT_TAB}, 24 {false, false, true, false, kVK_PageDown, IDC_SELECT_NEXT_TAB},
17 {false, false, true, false, kVK_Tab, IDC_SELECT_NEXT_TAB}, 25 {false, false, true, false, kVK_Tab, IDC_SELECT_NEXT_TAB},
18 {true, true, false, false, kVK_ANSI_LeftBracket, IDC_SELECT_PREVIOUS_TAB}, 26 {true, true, false, false, kVK_ANSI_LeftBracket, IDC_SELECT_PREVIOUS_TAB},
19 {false, false, true, false, kVK_PageUp, IDC_SELECT_PREVIOUS_TAB}, 27 {false, false, true, false, kVK_PageUp, IDC_SELECT_PREVIOUS_TAB},
20 {false, true, true, false, kVK_Tab, IDC_SELECT_PREVIOUS_TAB}, 28 {false, true, true, false, kVK_Tab, IDC_SELECT_PREVIOUS_TAB},
21 // Cmd-0..8 select the Nth tab, with cmd-9 being "last tab". 29 // Cmd-0..8 select the Nth tab, with cmd-9 being "last tab".
22 {true, false, false, false, kVK_ANSI_1, IDC_SELECT_TAB_0}, 30 {true, false, false, false, kVK_ANSI_1, IDC_SELECT_TAB_0},
23 {true, false, false, false, kVK_ANSI_2, IDC_SELECT_TAB_1}, 31 {true, false, false, false, kVK_ANSI_2, IDC_SELECT_TAB_1},
24 {true, false, false, false, kVK_ANSI_3, IDC_SELECT_TAB_2}, 32 {true, false, false, false, kVK_ANSI_3, IDC_SELECT_TAB_2},
25 {true, false, false, false, kVK_ANSI_4, IDC_SELECT_TAB_3}, 33 {true, false, false, false, kVK_ANSI_4, IDC_SELECT_TAB_3},
26 {true, false, false, false, kVK_ANSI_5, IDC_SELECT_TAB_4}, 34 {true, false, false, false, kVK_ANSI_5, IDC_SELECT_TAB_4},
27 {true, false, false, false, kVK_ANSI_6, IDC_SELECT_TAB_5}, 35 {true, false, false, false, kVK_ANSI_6, IDC_SELECT_TAB_5},
28 {true, false, false, false, kVK_ANSI_7, IDC_SELECT_TAB_6}, 36 {true, false, false, false, kVK_ANSI_7, IDC_SELECT_TAB_6},
29 {true, false, false, false, kVK_ANSI_8, IDC_SELECT_TAB_7}, 37 {true, false, false, false, kVK_ANSI_8, IDC_SELECT_TAB_7},
30 {true, false, false, false, kVK_ANSI_9, IDC_SELECT_LAST_TAB}, 38 {true, false, false, false, kVK_ANSI_9, IDC_SELECT_LAST_TAB},
31 }; 39 };
32 40
33 *num_entries = arraysize(keyboard_shortcuts); 41 *num_entries = arraysize(keyboard_shortcuts);
34 42
35 return keyboard_shortcuts; 43 return keyboard_shortcuts;
36 } 44 }
37 45
46 const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable
47 (size_t* num_entries) {
48 static const KeyboardShortcutData keyboard_shortcuts[] = {
49 {false, false, false, false, kVK_Escape, IDC_STOP},
50 };
51
52 *num_entries = arraysize(keyboard_shortcuts);
53
54 return keyboard_shortcuts;
55 }
56
38 const KeyboardShortcutData* GetBrowserKeyboardShortcutTable 57 const KeyboardShortcutData* GetBrowserKeyboardShortcutTable
39 (size_t* num_entries) { 58 (size_t* num_entries) {
40 static const KeyboardShortcutData keyboard_shortcuts[] = { 59 static const KeyboardShortcutData keyboard_shortcuts[] = {
41 {true, false, false, false, kVK_LeftArrow, IDC_BACK}, 60 {true, false, false, false, kVK_LeftArrow, IDC_BACK},
42 {true, false, false, false, kVK_RightArrow, IDC_FORWARD}, 61 {true, false, false, false, kVK_RightArrow, IDC_FORWARD},
43 {false, false, false, false, kVK_Delete, IDC_BACK}, 62 {false, false, false, false, kVK_Delete, IDC_BACK},
44 {false, true, false, false, kVK_Delete, IDC_FORWARD}, 63 {false, true, false, false, kVK_Delete, IDC_FORWARD},
45 }; 64 };
46 65
47 *num_entries = arraysize(keyboard_shortcuts); 66 *num_entries = arraysize(keyboard_shortcuts);
(...skipping 27 matching lines...) Expand all
75 } 94 }
76 95
77 int CommandForWindowKeyboardShortcut( 96 int CommandForWindowKeyboardShortcut(
78 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, 97 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
79 int vkey_code) { 98 int vkey_code) {
80 return CommandForKeyboardShortcut(GetWindowKeyboardShortcutTable, 99 return CommandForKeyboardShortcut(GetWindowKeyboardShortcutTable,
81 command_key, shift_key, 100 command_key, shift_key,
82 cntrl_key, opt_key, vkey_code); 101 cntrl_key, opt_key, vkey_code);
83 } 102 }
84 103
104 int CommandForDelayedWindowKeyboardShortcut(
105 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
106 int vkey_code) {
107 return CommandForKeyboardShortcut(GetDelayedWindowKeyboardShortcutTable,
108 command_key, shift_key,
109 cntrl_key, opt_key, vkey_code);
110 }
111
85 int CommandForBrowserKeyboardShortcut( 112 int CommandForBrowserKeyboardShortcut(
86 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, 113 bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
87 int vkey_code) { 114 int vkey_code) {
88 return CommandForKeyboardShortcut(GetBrowserKeyboardShortcutTable, 115 return CommandForKeyboardShortcut(GetBrowserKeyboardShortcutTable,
89 command_key, shift_key, 116 command_key, shift_key,
90 cntrl_key, opt_key, vkey_code); 117 cntrl_key, opt_key, vkey_code);
91 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/global_keyboard_shortcuts_mac.h ('k') | chrome/browser/global_keyboard_shortcuts_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698