Chromium Code Reviews| 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/extensions/extension_commands_global_registry.h" | 5 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.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/global_shortcut_listener.h" | 9 #include "chrome/browser/extensions/global_shortcut_listener.h" |
| 10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 extensions::CommandService::GLOBAL, | 76 extensions::CommandService::GLOBAL, |
| 77 &commands)) | 77 &commands)) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 extensions::CommandMap::const_iterator iter = commands.begin(); | 80 extensions::CommandMap::const_iterator iter = commands.begin(); |
| 81 for (; iter != commands.end(); ++iter) { | 81 for (; iter != commands.end(); ++iter) { |
| 82 if (!command_name.empty() && (iter->second.command_name() != command_name)) | 82 if (!command_name.empty() && (iter->second.command_name() != command_name)) |
| 83 continue; | 83 continue; |
| 84 const ui::Accelerator& accelerator = iter->second.accelerator(); | 84 const ui::Accelerator& accelerator = iter->second.accelerator(); |
| 85 | 85 |
| 86 VLOG(0) << "Adding global keybinding for " << extension->name().c_str() | |
| 87 << " " << command_name.c_str() | |
| 88 << " key: " << accelerator.GetShortcutText(); | |
| 89 | |
| 90 if (!IsAcceleratorRegistered(accelerator)) { | 86 if (!IsAcceleratorRegistered(accelerator)) { |
| 91 if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator( | 87 if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator( |
| 92 accelerator, this)) | 88 accelerator, this)) |
| 93 continue; | 89 continue; |
| 94 } | 90 } |
| 95 | 91 |
| 96 AddEventTarget(accelerator, extension->id(), iter->second.command_name()); | 92 AddEventTarget(accelerator, extension->id(), iter->second.command_name()); |
| 97 } | 93 } |
| 98 } | 94 } |
| 99 | 95 |
| 100 void ExtensionCommandsGlobalRegistry::RemoveExtensionKeybindingImpl( | 96 void ExtensionCommandsGlobalRegistry::RemoveExtensionKeybindingImpl( |
| 101 const ui::Accelerator& accelerator, | 97 const ui::Accelerator& accelerator, |
| 102 const std::string& command_name) { | 98 const std::string& command_name) { |
| 103 VLOG(0) << "Removing keybinding for " << command_name.c_str(); | 99 VLOG(0) << "Removing keybinding for " << command_name.c_str(); |
|
Finnur
2016/10/13 09:59:16
Can you remove this also, then?
Mike Wittman
2016/10/13 16:07:35
Done.
| |
| 104 | 100 |
| 105 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( | 101 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( |
| 106 accelerator, this); | 102 accelerator, this); |
| 107 } | 103 } |
| 108 | 104 |
| 109 void ExtensionCommandsGlobalRegistry::OnShortcutHandlingSuspended( | 105 void ExtensionCommandsGlobalRegistry::OnShortcutHandlingSuspended( |
| 110 bool suspended) { | 106 bool suspended) { |
| 111 GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended( | 107 GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended( |
| 112 suspended); | 108 suspended); |
| 113 if (registry_for_active_window()) | 109 if (registry_for_active_window()) |
| 114 registry_for_active_window()->SetShortcutHandlingSuspended(suspended); | 110 registry_for_active_window()->SetShortcutHandlingSuspended(suspended); |
| 115 } | 111 } |
| 116 | 112 |
| 117 void ExtensionCommandsGlobalRegistry::OnKeyPressed( | 113 void ExtensionCommandsGlobalRegistry::OnKeyPressed( |
| 118 const ui::Accelerator& accelerator) { | 114 const ui::Accelerator& accelerator) { |
| 119 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 115 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
| 120 } | 116 } |
| 121 | 117 |
| 122 } // namespace extensions | 118 } // namespace extensions |
| OLD | NEW |