| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 return g_factory.Pointer(); | 45 return g_factory.Pointer(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 ExtensionCommandsGlobalRegistry* ExtensionCommandsGlobalRegistry::Get( | 49 ExtensionCommandsGlobalRegistry* ExtensionCommandsGlobalRegistry::Get( |
| 50 content::BrowserContext* context) { | 50 content::BrowserContext* context) { |
| 51 return BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>::Get( | 51 return BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>::Get( |
| 52 context); | 52 context); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // static | |
| 56 void ExtensionCommandsGlobalRegistry::SetShortcutHandlingSuspended( | |
| 57 bool suspended) { | |
| 58 GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended( | |
| 59 suspended); | |
| 60 } | |
| 61 | |
| 62 bool ExtensionCommandsGlobalRegistry::IsRegistered( | 55 bool ExtensionCommandsGlobalRegistry::IsRegistered( |
| 63 const ui::Accelerator& accelerator) { | 56 const ui::Accelerator& accelerator) { |
| 64 return (registry_for_active_window() && | 57 return (registry_for_active_window() && |
| 65 registry_for_active_window()->IsAcceleratorRegistered(accelerator)) || | 58 registry_for_active_window()->IsAcceleratorRegistered(accelerator)) || |
| 66 IsAcceleratorRegistered(accelerator); | 59 IsAcceleratorRegistered(accelerator); |
| 67 } | 60 } |
| 68 | 61 |
| 69 void ExtensionCommandsGlobalRegistry::AddExtensionKeybindings( | 62 void ExtensionCommandsGlobalRegistry::AddExtensionKeybindings( |
| 70 const extensions::Extension* extension, | 63 const extensions::Extension* extension, |
| 71 const std::string& command_name) { | 64 const std::string& command_name) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 99 |
| 107 void ExtensionCommandsGlobalRegistry::RemoveExtensionKeybindingImpl( | 100 void ExtensionCommandsGlobalRegistry::RemoveExtensionKeybindingImpl( |
| 108 const ui::Accelerator& accelerator, | 101 const ui::Accelerator& accelerator, |
| 109 const std::string& command_name) { | 102 const std::string& command_name) { |
| 110 VLOG(0) << "Removing keybinding for " << command_name.c_str(); | 103 VLOG(0) << "Removing keybinding for " << command_name.c_str(); |
| 111 | 104 |
| 112 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( | 105 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( |
| 113 accelerator, this); | 106 accelerator, this); |
| 114 } | 107 } |
| 115 | 108 |
| 109 void ExtensionCommandsGlobalRegistry::OnShortcutHandlingSuspended( |
| 110 bool suspended) { |
| 111 GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended( |
| 112 suspended); |
| 113 registry_for_active_window()->set_shortcut_handling_suspended(suspended); |
| 114 } |
| 115 |
| 116 void ExtensionCommandsGlobalRegistry::OnKeyPressed( | 116 void ExtensionCommandsGlobalRegistry::OnKeyPressed( |
| 117 const ui::Accelerator& accelerator) { | 117 const ui::Accelerator& accelerator) { |
| 118 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 118 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace extensions | 121 } // namespace extensions |
| OLD | NEW |