| 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/extensions/extension_keybinding_registry.h" | 5 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 8 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return false; | 231 return false; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool ExtensionKeybindingRegistry::ExecuteCommands( | 234 bool ExtensionKeybindingRegistry::ExecuteCommands( |
| 235 const ui::Accelerator& accelerator, | 235 const ui::Accelerator& accelerator, |
| 236 const std::string& extension_id) { | 236 const std::string& extension_id) { |
| 237 EventTargets::iterator targets = event_targets_.find(accelerator); | 237 EventTargets::iterator targets = event_targets_.find(accelerator); |
| 238 if (targets == event_targets_.end() || targets->second.empty()) | 238 if (targets == event_targets_.end() || targets->second.empty()) |
| 239 return false; | 239 return false; |
| 240 | 240 |
| 241 if (!extension_id.empty() && |
| 242 !extensions::EventRouter::Get(browser_context_) |
| 243 ->ExtensionHasEventListener(extension_id, kOnCommandEventName)) |
| 244 return false; |
| 245 |
| 241 bool executed = false; | 246 bool executed = false; |
| 242 for (TargetList::const_iterator it = targets->second.begin(); | 247 for (TargetList::const_iterator it = targets->second.begin(); |
| 243 it != targets->second.end(); it++) { | 248 it != targets->second.end(); it++) { |
| 244 if (!extensions::EventRouter::Get(browser_context_) | |
| 245 ->ExtensionHasEventListener(it->first, kOnCommandEventName)) | |
| 246 continue; | |
| 247 | |
| 248 if (extension_id.empty() || it->first == extension_id) { | 249 if (extension_id.empty() || it->first == extension_id) { |
| 249 CommandExecuted(it->first, it->second); | 250 CommandExecuted(it->first, it->second); |
| 250 executed = true; | 251 executed = true; |
| 251 } | 252 } |
| 252 } | 253 } |
| 253 | 254 |
| 254 return executed; | 255 return executed; |
| 255 } | 256 } |
| 256 | 257 |
| 257 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |