OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 |
| 10 const KeyboardShortcutData* GetKeyboardShortCutTable(size_t* num_entries) { |
| 11 static const KeyboardShortcutData keyboard_shortcuts[] = { |
| 12 {true, true, false, 30 /* ] */, IDC_SELECT_NEXT_TAB}, |
| 13 {false, false, true, 121 /* pg down */, IDC_SELECT_NEXT_TAB}, |
| 14 {true, true, false, 33 /* [ */, IDC_SELECT_PREVIOUS_TAB}, |
| 15 {false, false, true, 116 /* pg_up */, IDC_SELECT_PREVIOUS_TAB}, |
| 16 }; |
| 17 |
| 18 *num_entries = arraysize(keyboard_shortcuts); |
| 19 |
| 20 return keyboard_shortcuts; |
| 21 } |
| 22 |
| 23 int CommandForKeyboardShortcut(bool command_key, bool shift_key, bool cntrl_key, |
| 24 int vkey_code) { |
| 25 |
| 26 // Scan through keycodes and see if it corresponds to one of the global |
| 27 // shortcuts on file. |
| 28 // |
| 29 // TODO(jeremy): Change this into a hash table once we get enough |
| 30 // entries in the array to make a difference. |
| 31 size_t num_shortcuts = 0; |
| 32 const KeyboardShortcutData *it = GetKeyboardShortCutTable(&num_shortcuts); |
| 33 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { |
| 34 if (it->command_key == command_key && |
| 35 it->shift_key == shift_key && |
| 36 it->cntrl_key == cntrl_key && |
| 37 it->vkey_code == vkey_code) { |
| 38 return it->chrome_command; |
| 39 } |
| 40 } |
| 41 |
| 42 return -1; |
| 43 } |
OLD | NEW |