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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "chrome/browser/extensions/api/commands/command_service.h" | 9 #include "chrome/browser/extensions/api/commands/command_service.h" |
10 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | |
11 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
14 #include "ui/base/accelerators/platform_accelerator_gtk.h" | 13 #include "ui/base/accelerators/platform_accelerator_gtk.h" |
15 | 14 |
16 // static | 15 // static |
17 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 16 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
18 bool suspended) { | 17 bool suspended) { |
19 ExtensionKeybindingRegistryGtk::set_shortcut_handling_suspended(suspended); | 18 ExtensionKeybindingRegistryGtk::set_shortcut_handling_suspended(suspended); |
20 } | 19 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier( | 52 ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier( |
54 event->keyval, static_cast<GdkModifierType>(event->state)); | 53 event->keyval, static_cast<GdkModifierType>(event->state)); |
55 | 54 |
56 return event_targets_.find(accelerator) != event_targets_.end(); | 55 return event_targets_.find(accelerator) != event_targets_.end(); |
57 } | 56 } |
58 | 57 |
59 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( | 58 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( |
60 const extensions::Extension* extension, | 59 const extensions::Extension* extension, |
61 const std::string& command_name) { | 60 const std::string& command_name) { |
62 extensions::CommandService* command_service = | 61 extensions::CommandService* command_service = |
63 extensions::CommandServiceFactory::GetForProfile(profile_); | 62 extensions::CommandService::Get(profile_); |
64 extensions::CommandMap commands; | 63 extensions::CommandMap commands; |
65 command_service->GetNamedCommands( | 64 command_service->GetNamedCommands( |
66 extension->id(), | 65 extension->id(), |
67 extensions::CommandService::ACTIVE_ONLY, | 66 extensions::CommandService::ACTIVE_ONLY, |
68 &commands); | 67 &commands); |
69 | 68 |
70 for (extensions::CommandMap::const_iterator iter = commands.begin(); | 69 for (extensions::CommandMap::const_iterator iter = commands.begin(); |
71 iter != commands.end(); ++iter) { | 70 iter != commands.end(); ++iter) { |
72 if (!command_name.empty() && (iter->second.command_name() != command_name)) | 71 if (!command_name.empty() && (iter->second.command_name() != command_name)) |
73 continue; | 72 continue; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 162 |
164 EventTargets::iterator it = event_targets_.find(accelerator); | 163 EventTargets::iterator it = event_targets_.find(accelerator); |
165 if (it == event_targets_.end()) { | 164 if (it == event_targets_.end()) { |
166 NOTREACHED(); // Shouldn't get this event for something not registered. | 165 NOTREACHED(); // Shouldn't get this event for something not registered. |
167 return FALSE; | 166 return FALSE; |
168 } | 167 } |
169 | 168 |
170 CommandExecuted(it->second.first, it->second.second); | 169 CommandExecuted(it->second.first, it->second.second); |
171 return TRUE; | 170 return TRUE; |
172 } | 171 } |
OLD | NEW |