| 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/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( | 58 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( |
| 59 const extensions::Extension* extension, | 59 const extensions::Extension* extension, |
| 60 const std::string& command_name) { | 60 const std::string& command_name) { |
| 61 extensions::CommandService* command_service = | 61 extensions::CommandService* command_service = |
| 62 extensions::CommandService::Get(profile_); | 62 extensions::CommandService::Get(profile_); |
| 63 extensions::CommandMap commands; | 63 extensions::CommandMap commands; |
| 64 command_service->GetNamedCommands( | 64 command_service->GetNamedCommands( |
| 65 extension->id(), | 65 extension->id(), |
| 66 extensions::CommandService::ACTIVE_ONLY, | 66 extensions::CommandService::ACTIVE_ONLY, |
| 67 extensions::CommandService::REGULAR, |
| 67 &commands); | 68 &commands); |
| 68 | 69 |
| 69 for (extensions::CommandMap::const_iterator iter = commands.begin(); | 70 for (extensions::CommandMap::const_iterator iter = commands.begin(); |
| 70 iter != commands.end(); ++iter) { | 71 iter != commands.end(); ++iter) { |
| 71 if (!command_name.empty() && (iter->second.command_name() != command_name)) | 72 if (!command_name.empty() && (iter->second.command_name() != command_name)) |
| 72 continue; | 73 continue; |
| 73 | 74 |
| 74 ui::Accelerator accelerator(iter->second.accelerator()); | 75 ui::Accelerator accelerator(iter->second.accelerator()); |
| 75 event_targets_[accelerator] = | 76 event_targets_[accelerator] = |
| 76 std::make_pair(extension->id(), iter->second.command_name()); | 77 std::make_pair(extension->id(), iter->second.command_name()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 163 |
| 163 EventTargets::iterator it = event_targets_.find(accelerator); | 164 EventTargets::iterator it = event_targets_.find(accelerator); |
| 164 if (it == event_targets_.end()) { | 165 if (it == event_targets_.end()) { |
| 165 NOTREACHED(); // Shouldn't get this event for something not registered. | 166 NOTREACHED(); // Shouldn't get this event for something not registered. |
| 166 return FALSE; | 167 return FALSE; |
| 167 } | 168 } |
| 168 | 169 |
| 169 CommandExecuted(it->second.first, it->second.second); | 170 CommandExecuted(it->second.first, it->second.second); |
| 170 return TRUE; | 171 return TRUE; |
| 171 } | 172 } |
| OLD | NEW |