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

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

Issue 109413003: Refactor GlobalShortcutListener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update as comments. Created 7 years 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
« no previous file with comments | « no previous file | chrome/browser/extensions/global_shortcut_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_commands_global_registry.cc
diff --git a/chrome/browser/extensions/extension_commands_global_registry.cc b/chrome/browser/extensions/extension_commands_global_registry.cc
index aa11b9c5c5cf667de5a315d7573ae6d1bb1fc478..541e82db271dfe693d6a0125b62072e92aa86e79 100644
--- a/chrome/browser/extensions/extension_commands_global_registry.cc
+++ b/chrome/browser/extensions/extension_commands_global_registry.cc
@@ -78,13 +78,19 @@ void ExtensionCommandsGlobalRegistry::AddExtensionKeybinding(
event_targets_[iter->second.accelerator()].push_back(
std::make_pair(extension->id(), iter->second.command_name()));
- // Shortcuts except media keys have only one target in the list. See comment
- // about |event_targets_|.
- if (!extensions::CommandService::IsMediaKey(iter->second.accelerator()))
+ if (!extensions::CommandService::IsMediaKey(iter->second.accelerator())) {
+ // Shortcuts except media keys have only one target in the list. See
+ // comment about |event_targets_|.
DCHECK(event_targets_[iter->second.accelerator()].size() == 1);
+ } else if (event_targets_[iter->second.accelerator()].size() > 1) {
+ // Now the |iter->second.accelerator()| is one of the media keys, we have
+ // registerd it successfully, so pass it by.
+ continue;
+ }
- GlobalShortcutListener::GetInstance()->RegisterAccelerator(
- iter->second.accelerator(), this);
+ if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(
+ iter->second.accelerator(), this))
zhchbin 2013/12/17 13:34:32 You may ask why I didn't call RegisterAccelerator
Finnur 2013/12/17 14:31:40 Wondering if this would be simpler (you'll need to
zhchbin 2013/12/17 15:15:46 Thanks very much! In this case we should also pus
+ event_targets_.erase(iter->second.accelerator());
}
}
« no previous file with comments | « no previous file | chrome/browser/extensions/global_shortcut_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698