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

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: Address comments. 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 dc675658e4eab5db9db1374d32f0292674acb75e..b292b76bf0ccfdd5f6f65c6da8d80bd3b1139d27 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/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -37,24 +38,30 @@ 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);
Finnur 2013/11/18 11:16:14 Um, how does this work? Don't you need to advance
zhchbin 2013/11/18 13:10:13 The return value is an iterator pointing to the ne
Finnur 2013/11/18 14:14:53 Oh, I missed the assignment there.
+ } else {
+ target++;
+ }
Finnur 2013/11/18 11:16:14 Nit: Both of these are single-line so no braces ne
zhchbin 2013/11/18 13:10:13 Done.
}
- // 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 (!command_name.empty())
- break;
+ // If a specific command_name was requested, it has now been deleted so
+ // no further work is required.
+ if (!command_name.empty())
+ break;
Finnur 2013/11/18 11:16:14 I think this should be outside the if clause that
zhchbin 2013/11/18 13:10:13 Done.
+ }
}
}
@@ -78,6 +85,18 @@ bool ExtensionKeybindingRegistry::ShouldIgnoreCommand(
command == manifest_values::kScriptBadgeCommandEvent;
}
+bool ExtensionKeybindingRegistry::NotifyEventTargetsByAccelerator(
+ 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;
Finnur 2013/11/18 11:16:14 nit: Line break above.
zhchbin 2013/11/18 13:10:13 Done.
+}
+
void ExtensionKeybindingRegistry::CommandExecuted(
const std::string& extension_id, const std::string& command) {
ExtensionService* service =

Powered by Google App Engine
This is Rietveld 408576698