Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: chrome/browser/extensions/extension_keybinding_registry.cc

Issue 504183004: Continue key propagation for extensions without any listeners to chrome.commands.onCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Change manifest to use MacCtrl. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_keybinding_registry.cc
diff --git a/chrome/browser/extensions/extension_keybinding_registry.cc b/chrome/browser/extensions/extension_keybinding_registry.cc
index 86b9116d0b1fb951c3886dc36f0df7c98b74269f..deeb0a4ed6886fa26127a7ec70e3489051db5d9d 100644
--- a/chrome/browser/extensions/extension_keybinding_registry.cc
+++ b/chrome/browser/extensions/extension_keybinding_registry.cc
@@ -17,6 +17,10 @@
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest_constants.h"
+namespace {
+const char kOnCommandEventName[] = "commands.onCommand";
+} // namespace
+
namespace extensions {
ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(
@@ -115,7 +119,7 @@ void ExtensionKeybindingRegistry::CommandExecuted(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(new base::StringValue(command));
- scoped_ptr<Event> event(new Event("commands.onCommand", args.Pass()));
+ scoped_ptr<Event> event(new Event(kOnCommandEventName, args.Pass()));
event->restrict_to_browser_context = browser_context_;
event->user_gesture = EventRouter::USER_GESTURE_ENABLED;
EventRouter::Get(browser_context_)
@@ -234,6 +238,11 @@ bool ExtensionKeybindingRegistry::ExecuteCommands(
if (targets == event_targets_.end() || targets->second.empty())
return false;
+ if (!extension_id.empty() &&
+ !extensions::EventRouter::Get(browser_context_)
+ ->ExtensionHasEventListener(extension_id, kOnCommandEventName))
+ return false;
+
bool executed = false;
for (TargetList::const_iterator it = targets->second.begin();
it != targets->second.end(); it++) {

Powered by Google App Engine
This is Rietveld 408576698