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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/extensions/accelerator_priority.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 | |
15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | |
16 bool suspended) { | |
17 views::FocusManager::set_shortcut_handling_suspended(suspended); | |
18 } | |
19 | |
20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( | 14 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( |
21 Profile* profile, | 15 Profile* profile, |
22 views::FocusManager* focus_manager, | 16 views::FocusManager* focus_manager, |
23 ExtensionFilter extension_filter, | 17 ExtensionFilter extension_filter, |
24 Delegate* delegate) | 18 Delegate* delegate) |
25 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), | 19 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), |
26 profile_(profile), | 20 profile_(profile), |
27 focus_manager_(focus_manager) { | 21 focus_manager_(focus_manager) { |
28 Init(); | 22 Init(); |
29 } | 23 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 AddEventTarget(accelerator, extension->id(), iter->second.command_name()); | 57 AddEventTarget(accelerator, extension->id(), iter->second.command_name()); |
64 } | 58 } |
65 } | 59 } |
66 | 60 |
67 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl( | 61 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl( |
68 const ui::Accelerator& accelerator, | 62 const ui::Accelerator& accelerator, |
69 const std::string& command_name) { | 63 const std::string& command_name) { |
70 focus_manager_->UnregisterAccelerator(accelerator, this); | 64 focus_manager_->UnregisterAccelerator(accelerator, this); |
71 } | 65 } |
72 | 66 |
| 67 void ExtensionKeybindingRegistryViews::OnShortcutHandlingSuspended( |
| 68 bool suspended) { |
| 69 focus_manager_->set_shortcut_handling_suspended(suspended); |
| 70 } |
| 71 |
73 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( | 72 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( |
74 const ui::Accelerator& accelerator) { | 73 const ui::Accelerator& accelerator) { |
75 std::string extension_id, command_name; | 74 std::string extension_id, command_name; |
76 GetFirstTarget(accelerator, &extension_id, &command_name); | 75 GetFirstTarget(accelerator, &extension_id, &command_name); |
77 const ui::AcceleratorManager::HandlerPriority priority = | 76 const ui::AcceleratorManager::HandlerPriority priority = |
78 GetAcceleratorPriorityById(accelerator, extension_id, browser_context()); | 77 GetAcceleratorPriorityById(accelerator, extension_id, browser_context()); |
79 // Normal priority shortcuts must be handled via standard browser commands to | 78 // Normal priority shortcuts must be handled via standard browser commands to |
80 // be processed at the proper time. | 79 // be processed at the proper time. |
81 return (priority == ui::AcceleratorManager::kHighPriority) && | 80 return (priority == ui::AcceleratorManager::kHighPriority) && |
82 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 81 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
83 } | 82 } |
84 | 83 |
85 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 84 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
86 return true; | 85 return true; |
87 } | 86 } |
OLD | NEW |