| 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 |
| 62 void ExtensionCommandsGlobalRegistry::SetShortcutHandlingSuspended( |
| 63 bool suspended) { |
| 64 ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(suspended); |
| 65 GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended( |
| 66 suspended); |
| 67 } |
| 68 |
| 69 void ExtensionCommandsGlobalRegistry::AddExtensionKeybindings( | 69 void ExtensionCommandsGlobalRegistry::AddExtensionKeybindings( |
| 70 const extensions::Extension* extension, | 70 const extensions::Extension* extension, |
| 71 const std::string& command_name) { | 71 const std::string& command_name) { |
| 72 // This object only handles named commands, not browser/page actions. | 72 // This object only handles named commands, not browser/page actions. |
| 73 if (ShouldIgnoreCommand(command_name)) | 73 if (ShouldIgnoreCommand(command_name)) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 extensions::CommandService* command_service = | 76 extensions::CommandService* command_service = |
| 77 extensions::CommandService::Get(browser_context_); | 77 extensions::CommandService::Get(browser_context_); |
| 78 // Add all the active global keybindings, if any. | 78 // Add all the active global keybindings, if any. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( | 112 GlobalShortcutListener::GetInstance()->UnregisterAccelerator( |
| 113 accelerator, this); | 113 accelerator, this); |
| 114 } | 114 } |
| 115 | 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 |