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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 case PLATFORM_APPS_ONLY: | 226 case PLATFORM_APPS_ONLY: |
227 return extension->is_platform_app(); | 227 return extension->is_platform_app(); |
228 default: | 228 default: |
229 NOTREACHED(); | 229 NOTREACHED(); |
230 } | 230 } |
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) { |
Finnur
2014/09/08 15:23:15
I wonder if we should add a comment in here, since
| |
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 | |
246 bool executed = false; | 241 bool executed = false; |
247 for (TargetList::const_iterator it = targets->second.begin(); | 242 for (TargetList::const_iterator it = targets->second.begin(); |
248 it != targets->second.end(); it++) { | 243 it != targets->second.end(); it++) { |
244 if (!extensions::EventRouter::Get(browser_context_) | |
245 ->ExtensionHasEventListener(it->first, kOnCommandEventName)) | |
246 continue; | |
247 | |
249 if (extension_id.empty() || it->first == extension_id) { | 248 if (extension_id.empty() || it->first == extension_id) { |
250 CommandExecuted(it->first, it->second); | 249 CommandExecuted(it->first, it->second); |
251 executed = true; | 250 executed = true; |
252 } | 251 } |
253 } | 252 } |
254 | 253 |
255 return executed; | 254 return executed; |
256 } | 255 } |
257 | 256 |
258 } // namespace extensions | 257 } // namespace extensions |
OLD | NEW |