| 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/views/extensions/extension_keybinding_registry_views
.h" | 5 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.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_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { | 21 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { |
| 22 EventTargets::const_iterator iter; | 22 EventTargets::const_iterator iter; |
| 23 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) | 23 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) |
| 24 focus_manager_->UnregisterAccelerator(iter->first, this); | 24 focus_manager_->UnregisterAccelerator(iter->first, this); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ExtensionKeybindingRegistryViews::AddExtensionKeybinding( | 27 void ExtensionKeybindingRegistryViews::AddExtensionKeybinding( |
| 28 const Extension* extension) { | 28 const Extension* extension) { |
| 29 // Add all the keybindings (except pageAction and browserAction, which are | 29 // Add all the keybindings (except pageAction and browserAction, which are |
| 30 // handled elsewhere). | 30 // handled elsewhere). |
| 31 const std::vector<Extension::ExtensionKeybinding> commands = | 31 const Extension::CommandMap& commands = extension->named_commands(); |
| 32 extension->keybindings(); | 32 Extension::CommandMap::const_iterator iter = commands.begin(); |
| 33 for (size_t i = 0; i < commands.size(); ++i) { | 33 for (; iter != commands.end(); ++iter) { |
| 34 if (ShouldIgnoreCommand(commands[i].command_name())) | 34 event_targets_[iter->second.accelerator()] = |
| 35 continue; | 35 std::make_pair(extension->id(), iter->second.command_name()); |
| 36 | |
| 37 event_targets_[commands[i].accelerator()] = | |
| 38 std::make_pair(extension->id(), commands[i].command_name()); | |
| 39 focus_manager_->RegisterAccelerator( | 36 focus_manager_->RegisterAccelerator( |
| 40 commands[i].accelerator(), ui::AcceleratorManager::kHighPriority, this); | 37 iter->second.accelerator(), |
| 38 ui::AcceleratorManager::kHighPriority, this); |
| 41 } | 39 } |
| 42 } | 40 } |
| 43 | 41 |
| 44 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybinding( | 42 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybinding( |
| 45 const Extension* extension) { | 43 const Extension* extension) { |
| 46 EventTargets::const_iterator iter; | 44 EventTargets::const_iterator iter; |
| 47 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) { | 45 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) { |
| 48 if (iter->second.first != extension->id()) | 46 if (iter->second.first != extension->id()) |
| 49 continue; // Not the extension we asked for. | 47 continue; // Not the extension we asked for. |
| 50 | 48 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 | 62 |
| 65 service->browser_event_router()->CommandExecuted( | 63 service->browser_event_router()->CommandExecuted( |
| 66 profile_, it->second.first, it->second.second); | 64 profile_, it->second.first, it->second.second); |
| 67 | 65 |
| 68 return true; | 66 return true; |
| 69 } | 67 } |
| 70 | 68 |
| 71 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 69 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
| 72 return true; | 70 return true; |
| 73 } | 71 } |
| OLD | NEW |