OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 5 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/api/commands/command_service.h" | 8 #include "chrome/browser/extensions/api/commands/command_service.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/extensions/accelerator_priority.h" |
11 #include "content/public/browser/native_web_keyboard_event.h" | 12 #include "content/public/browser/native_web_keyboard_event.h" |
12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
13 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
14 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
15 | 16 |
16 namespace values = extensions::manifest_values; | 17 namespace values = extensions::manifest_values; |
17 | 18 |
18 // static | 19 // static |
19 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 20 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
20 bool suspended) { | 21 bool suspended) { |
(...skipping 10 matching lines...) Expand all Loading... |
31 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), | 32 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), |
32 profile_(profile), | 33 profile_(profile), |
33 window_(window) { | 34 window_(window) { |
34 Init(); | 35 Init(); |
35 } | 36 } |
36 | 37 |
37 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() { | 38 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() { |
38 } | 39 } |
39 | 40 |
40 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent( | 41 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent( |
41 const content::NativeWebKeyboardEvent& event) { | 42 const content::NativeWebKeyboardEvent& event, |
| 43 ui::AcceleratorManager::HandlerPriority priority) { |
42 if (shortcut_handling_suspended_) | 44 if (shortcut_handling_suspended_) |
43 return false; | 45 return false; |
44 | 46 |
45 ui::Accelerator accelerator( | 47 ui::Accelerator accelerator( |
46 static_cast<ui::KeyboardCode>(event.windowsKeyCode), | 48 static_cast<ui::KeyboardCode>(event.windowsKeyCode), |
47 content::GetModifiersFromNativeWebKeyboardEvent(event)); | 49 content::GetModifiersFromNativeWebKeyboardEvent(event)); |
48 | 50 |
49 std::string extension_id; | 51 std::string extension_id; |
50 std::string command_name; | 52 std::string command_name; |
51 if (!GetFirstTarget(accelerator, &extension_id, &command_name)) | 53 if (!GetFirstTarget(accelerator, &extension_id, &command_name)) |
52 return false; | 54 return false; |
53 | 55 |
| 56 const ui::AcceleratorManager::HandlerPriority accelerator_priority = |
| 57 GetAcceleratorPriorityById(accelerator, extension_id, profile_); |
| 58 // Only handle the event if it has the right priority. |
| 59 if (priority != accelerator_priority) |
| 60 return false; |
| 61 |
54 int type = 0; | 62 int type = 0; |
55 if (command_name == values::kPageActionCommandEvent) { | 63 if (command_name == values::kPageActionCommandEvent) { |
56 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC; | 64 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC; |
57 } else if (command_name == values::kBrowserActionCommandEvent) { | 65 } else if (command_name == values::kBrowserActionCommandEvent) { |
58 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC; | 66 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC; |
59 } else { | 67 } else { |
60 // Not handled by using notifications. Route it through the Browser Event | 68 // Not handled by using notifications. Route it through the Browser Event |
61 // Router using the base class (it will iterate through all targets). | 69 // Router using the base class (it will iterate through all targets). |
62 return ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 70 return ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
63 } | 71 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 AddEventTarget(page_action.accelerator(), | 127 AddEventTarget(page_action.accelerator(), |
120 extension->id(), | 128 extension->id(), |
121 page_action.command_name()); | 129 page_action.command_name()); |
122 } | 130 } |
123 } | 131 } |
124 | 132 |
125 void ExtensionKeybindingRegistryCocoa::RemoveExtensionKeybindingImpl( | 133 void ExtensionKeybindingRegistryCocoa::RemoveExtensionKeybindingImpl( |
126 const ui::Accelerator& accelerator, | 134 const ui::Accelerator& accelerator, |
127 const std::string& command_name) { | 135 const std::string& command_name) { |
128 } | 136 } |
OLD | NEW |