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

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

Issue 64273008: [Windows] Finish global and non-global media keys support on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gclient sync. Created 7 years, 1 month 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 c770563fccb1d6c9c8b6a4ee704cb7c7a07c8f38..94be6c1b4ee32db18d622e1c6347308e5f63c44c 100644
--- a/chrome/browser/extensions/extension_keybinding_registry.cc
+++ b/chrome/browser/extensions/extension_keybinding_registry.cc
@@ -7,6 +7,7 @@
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/active_tab_permission_granter.h"
+#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -37,22 +38,27 @@ ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() {
void ExtensionKeybindingRegistry::RemoveExtensionKeybinding(
const Extension* extension,
const std::string& command_name) {
- EventTargets::iterator iter = event_targets_.begin();
- while (iter != event_targets_.end()) {
- if (iter->second.first != extension->id() ||
- (!command_name.empty() && (iter->second.second != command_name))) {
- ++iter;
- continue; // Not the extension or command we asked for.
+ EventTargets::iterator it = event_targets_.begin();
+ while (it != event_targets_.end()) {
+ TargetList& target_list = it->second;
+ TargetList::iterator target = target_list.begin();
+ while (target != target_list.end()) {
+ if (target->first == extension->id() &&
+ (command_name.empty() || command_name == target->second))
+ target = target_list.erase(target);
+ else
+ target++;
}
- // Let each platform-specific implementation get a chance to clean up.
- RemoveExtensionKeybindingImpl(iter->first, command_name);
-
- EventTargets::iterator old = iter++;
- event_targets_.erase(old);
+ EventTargets::iterator old = it++;
+ if (target_list.empty()) {
+ // Let each platform-specific implementation get a chance to clean up.
+ RemoveExtensionKeybindingImpl(old->first, command_name);
+ event_targets_.erase(old);
+ }
- // If a specific command_name was requested, it has now been deleted so
- // no further work is required.
+ // If a specific command_name was requested, it has now been deleted so no
+ // further work is required.
if (!command_name.empty())
break;
}
@@ -78,6 +84,19 @@ bool ExtensionKeybindingRegistry::ShouldIgnoreCommand(
command == manifest_values::kScriptBadgeCommandEvent;
}
+bool ExtensionKeybindingRegistry::NotifyEventTargets(
+ const ui::Accelerator& accelerator) {
+ EventTargets::iterator targets = event_targets_.find(accelerator);
+ if (targets == event_targets_.end() || targets->second.empty())
+ return false;
+
+ for (TargetList::const_iterator it = targets->second.begin();
+ it != targets->second.end(); it++)
+ CommandExecuted(it->first, it->second);
+
+ return true;
+}
+
void ExtensionKeybindingRegistry::CommandExecuted(
const std::string& extension_id, const std::string& command) {
ExtensionService* service =
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_registry.h ('k') | chrome/browser/extensions/global_shortcut_listener_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698