| 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/gtk/extensions/extension_keybinding_registry_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_browser_event_router.h" | 7 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 8 #include "chrome/browser/extensions/extension_command_service.h" |
| 9 #include "chrome/browser/extensions/extension_command_service_factory.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 11 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 13 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 12 | 14 |
| 13 ExtensionKeybindingRegistryGtk::ExtensionKeybindingRegistryGtk( | 15 ExtensionKeybindingRegistryGtk::ExtensionKeybindingRegistryGtk( |
| 14 Profile* profile, gfx::NativeWindow window) | 16 Profile* profile, gfx::NativeWindow window) |
| 15 : ExtensionKeybindingRegistry(profile), | 17 : ExtensionKeybindingRegistry(profile), |
| 16 profile_(profile), | 18 profile_(profile), |
| 17 window_(window), | 19 window_(window), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 const GdkEventKey* event) const { | 37 const GdkEventKey* event) const { |
| 36 ui::AcceleratorGtk accelerator(ui::WindowsKeyCodeForGdkKeyCode(event->keyval), | 38 ui::AcceleratorGtk accelerator(ui::WindowsKeyCodeForGdkKeyCode(event->keyval), |
| 37 event->state & GDK_SHIFT_MASK, | 39 event->state & GDK_SHIFT_MASK, |
| 38 event->state & GDK_CONTROL_MASK, | 40 event->state & GDK_CONTROL_MASK, |
| 39 event->state & GDK_MOD1_MASK); | 41 event->state & GDK_MOD1_MASK); |
| 40 return event_targets_.find(accelerator) != event_targets_.end(); | 42 return event_targets_.find(accelerator) != event_targets_.end(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( | 45 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( |
| 44 const Extension* extension) { | 46 const Extension* extension) { |
| 45 // Add all the keybindings (except pageAction and browserAction, which are | 47 // Add all the active keybindings (except page actions and browser actions, |
| 46 // handled elsewhere). | 48 // which are handled elsewhere). |
| 47 const Extension::CommandMap& commands = extension->named_commands(); | 49 ExtensionCommandService* command_service = |
| 50 ExtensionCommandServiceFactory::GetForProfile(profile_); |
| 51 const Extension::CommandMap& commands = |
| 52 command_service->GetActiveNamedCommands(extension->id()); |
| 48 Extension::CommandMap::const_iterator iter = commands.begin(); | 53 Extension::CommandMap::const_iterator iter = commands.begin(); |
| 49 for (; iter != commands.end(); ++iter) { | 54 for (; iter != commands.end(); ++iter) { |
| 50 ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(), | 55 ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(), |
| 51 iter->second.accelerator().IsShiftDown(), | 56 iter->second.accelerator().IsShiftDown(), |
| 52 iter->second.accelerator().IsCtrlDown(), | 57 iter->second.accelerator().IsCtrlDown(), |
| 53 iter->second.accelerator().IsAltDown()); | 58 iter->second.accelerator().IsAltDown()); |
| 54 event_targets_[accelerator] = | 59 event_targets_[accelerator] = |
| 55 std::make_pair(extension->id(), iter->second.command_name()); | 60 std::make_pair(extension->id(), iter->second.command_name()); |
| 56 | 61 |
| 57 if (ShouldIgnoreCommand(iter->second.command_name())) | 62 if (ShouldIgnoreCommand(iter->second.command_name())) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (it == event_targets_.end()) { | 112 if (it == event_targets_.end()) { |
| 108 NOTREACHED(); // Shouldn't get this event for something not registered. | 113 NOTREACHED(); // Shouldn't get this event for something not registered. |
| 109 return FALSE; | 114 return FALSE; |
| 110 } | 115 } |
| 111 | 116 |
| 112 service->browser_event_router()->CommandExecuted( | 117 service->browser_event_router()->CommandExecuted( |
| 113 profile_, it->second.first, it->second.second); | 118 profile_, it->second.first, it->second.second); |
| 114 | 119 |
| 115 return TRUE; | 120 return TRUE; |
| 116 } | 121 } |
| OLD | NEW |