summaryrefslogtreecommitdiffstats
path: root/chrome/browser/global_keyboard_shortcuts_mac.mm
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 08:56:18 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 08:56:18 +0000
commit1ade7b6573cd86b9969740d7cc0376a6be23f385 (patch)
tree803722693e07073c11e30b7e31a56bd6c6a0d820 /chrome/browser/global_keyboard_shortcuts_mac.mm
parent82bf749a2af4de1a5e1dcafd3f211993582bf24b (diff)
downloadchromium_src-1ade7b6573cd86b9969740d7cc0376a6be23f385.zip
chromium_src-1ade7b6573cd86b9969740d7cc0376a6be23f385.tar.gz
chromium_src-1ade7b6573cd86b9969740d7cc0376a6be23f385.tar.bz2
Add a keyboard shortcut on Escape that emits the IDC_STOP command.
BUG=20916 TEST=Load something big (http://cnn.com/) and hit escape. Page load will stop. Review URL: http://codereview.chromium.org/491023 Patch from Jochen Eisinger. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/global_keyboard_shortcuts_mac.mm')
-rw-r--r--chrome/browser/global_keyboard_shortcuts_mac.mm27
1 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/global_keyboard_shortcuts_mac.mm b/chrome/browser/global_keyboard_shortcuts_mac.mm
index 1d97f99..4872a40 100644
--- a/chrome/browser/global_keyboard_shortcuts_mac.mm
+++ b/chrome/browser/global_keyboard_shortcuts_mac.mm
@@ -9,6 +9,14 @@
#include "base/basictypes.h"
#include "chrome/app/chrome_dll_resource.h"
+// Basically, there are two kinds of keyboard shortcuts: Ones that should work
+// only if the tab contents is focused (BrowserKeyboardShortcut), and ones that
+// should work in all other cases (WindowKeyboardShortcut). In the latter case,
+// we differentiate between shortcuts that are checked before any other view
+// gets the chance to handle them (WindowKeyboardShortcut) or after all views
+// had a chance but did not handle the keypress event
+// (DelayedWindowKeyboardShortcut)
+
const KeyboardShortcutData* GetWindowKeyboardShortcutTable
(size_t* num_entries) {
static const KeyboardShortcutData keyboard_shortcuts[] = {
@@ -35,6 +43,17 @@ const KeyboardShortcutData* GetWindowKeyboardShortcutTable
return keyboard_shortcuts;
}
+const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable
+ (size_t* num_entries) {
+ static const KeyboardShortcutData keyboard_shortcuts[] = {
+ {false, false, false, false, kVK_Escape, IDC_STOP},
+ };
+
+ *num_entries = arraysize(keyboard_shortcuts);
+
+ return keyboard_shortcuts;
+}
+
const KeyboardShortcutData* GetBrowserKeyboardShortcutTable
(size_t* num_entries) {
static const KeyboardShortcutData keyboard_shortcuts[] = {
@@ -82,6 +101,14 @@ int CommandForWindowKeyboardShortcut(
cntrl_key, opt_key, vkey_code);
}
+int CommandForDelayedWindowKeyboardShortcut(
+ bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
+ int vkey_code) {
+ return CommandForKeyboardShortcut(GetDelayedWindowKeyboardShortcutTable,
+ command_key, shift_key,
+ cntrl_key, opt_key, vkey_code);
+}
+
int CommandForBrowserKeyboardShortcut(
bool command_key, bool shift_key, bool cntrl_key, bool opt_key,
int vkey_code) {