OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/profiles/profile.h" | 5 #include "chrome/browser/ui/accelerator_utils.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
6 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" | 10 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
7 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | |
8 #include "content/public/browser/native_web_keyboard_event.h" | |
9 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
10 #import "ui/base/accelerators/platform_accelerator_cocoa.h" | 12 #import "ui/base/accelerators/platform_accelerator_cocoa.h" |
11 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 13 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
12 | 14 |
13 namespace chrome { | 15 namespace chrome { |
14 | 16 |
15 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) { | 17 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) { |
16 // The |accelerator| passed in contains a Windows key code but no platform | 18 // The |accelerator| passed in contains a Windows key code but no platform |
17 // accelerator info. The Accelerator list is the opposite: It has accelerators | 19 // accelerator info. The Accelerator list is the opposite: It has accelerators |
18 // that have key_code() == VKEY_UNKNOWN but they contain a platform | 20 // that have key_code() == VKEY_UNKNOWN but they contain a platform |
(...skipping 17 matching lines...) Expand all Loading... |
36 location:NSZeroPoint | 38 location:NSZeroPoint |
37 modifierFlags:modifiers | 39 modifierFlags:modifiers |
38 timestamp:0 | 40 timestamp:0 |
39 windowNumber:0 | 41 windowNumber:0 |
40 context:nil | 42 context:nil |
41 characters:characters | 43 characters:characters |
42 charactersIgnoringModifiers:characters | 44 charactersIgnoringModifiers:characters |
43 isARepeat:NO | 45 isARepeat:NO |
44 keyCode:accelerator.key_code()]; | 46 keyCode:accelerator.key_code()]; |
45 | 47 |
46 content::NativeWebKeyboardEvent keyboard_event(event); | 48 return CommandForKeyEvent(event) != -1; |
47 int id = [BrowserWindowUtils getCommandId:keyboard_event]; | |
48 return id != -1; | |
49 } | 49 } |
50 | 50 |
51 ui::Accelerator GetPrimaryChromeAcceleratorForCommandId(int command_id) { | 51 ui::Accelerator GetPrimaryChromeAcceleratorForCommandId(int command_id) { |
52 const ui::Accelerator* accelerator = | 52 const ui::Accelerator* accelerator = |
53 AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(command_id); | 53 AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(command_id); |
54 | 54 |
55 return accelerator ? *accelerator : ui::Accelerator(); | 55 return accelerator ? *accelerator : ui::Accelerator(); |
56 } | 56 } |
57 | 57 |
58 } // namespace chrome | 58 } // namespace chrome |
OLD | NEW |