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/views/extensions/extension_keybinding_registry_views
.h" | 5 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/commands/command_service.h" | 7 #include "chrome/browser/extensions/api/commands/command_service.h" |
8 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 8 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
9 #include "chrome/browser/extensions/extension_service.h" | |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/extensions/accelerator_priority.h" |
11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
12 #include "ui/views/focus/focus_manager.h" | 12 #include "ui/views/focus/focus_manager.h" |
13 | 13 |
14 // static | 14 // static |
15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
16 bool suspended) { | 16 bool suspended) { |
17 views::FocusManager::set_shortcut_handling_suspended(suspended); | 17 views::FocusManager::set_shortcut_handling_suspended(suspended); |
18 } | 18 } |
19 | 19 |
20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( | 20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( |
(...skipping 28 matching lines...) Expand all Loading... |
49 extensions::CommandService::ACTIVE_ONLY, | 49 extensions::CommandService::ACTIVE_ONLY, |
50 extensions::CommandService::REGULAR, | 50 extensions::CommandService::REGULAR, |
51 &commands)) | 51 &commands)) |
52 return; | 52 return; |
53 extensions::CommandMap::const_iterator iter = commands.begin(); | 53 extensions::CommandMap::const_iterator iter = commands.begin(); |
54 for (; iter != commands.end(); ++iter) { | 54 for (; iter != commands.end(); ++iter) { |
55 if (!command_name.empty() && (iter->second.command_name() != command_name)) | 55 if (!command_name.empty() && (iter->second.command_name() != command_name)) |
56 continue; | 56 continue; |
57 if (!IsAcceleratorRegistered(iter->second.accelerator())) { | 57 if (!IsAcceleratorRegistered(iter->second.accelerator())) { |
58 focus_manager_->RegisterAccelerator(iter->second.accelerator(), | 58 focus_manager_->RegisterAccelerator(iter->second.accelerator(), |
59 ui::AcceleratorManager::kHighPriority, | 59 GetAcceleratorPriority( |
| 60 iter->second.accelerator(), |
| 61 extension), |
60 this); | 62 this); |
61 } | 63 } |
62 | 64 |
63 AddEventTarget(iter->second.accelerator(), | 65 AddEventTarget(iter->second.accelerator(), |
64 extension->id(), | 66 extension->id(), |
65 iter->second.command_name()); | 67 iter->second.command_name()); |
66 } | 68 } |
67 } | 69 } |
68 | 70 |
69 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl( | 71 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl( |
70 const ui::Accelerator& accelerator, | 72 const ui::Accelerator& accelerator, |
71 const std::string& command_name) { | 73 const std::string& command_name) { |
72 focus_manager_->UnregisterAccelerator(accelerator, this); | 74 focus_manager_->UnregisterAccelerator(accelerator, this); |
73 } | 75 } |
74 | 76 |
75 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( | 77 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( |
76 const ui::Accelerator& accelerator) { | 78 const ui::Accelerator& accelerator) { |
| 79 std::string extension_id, command_name; |
| 80 GetFirstTarget(accelerator, &extension_id, &command_name); |
| 81 // Normal priority shortcuts must be handled via the standard browser command |
| 82 // processing to be effective. |
| 83 if (GetAcceleratorPriority(accelerator, extension_id, browser_context()) == |
| 84 ui::AcceleratorManager::kNormalPriority) |
| 85 return false; |
| 86 |
77 return ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 87 return ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
78 } | 88 } |
79 | 89 |
80 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 90 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
81 return true; | 91 return true; |
82 } | 92 } |
OLD | NEW |