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

Unified Diff: chrome/browser/ui/views/extensions/extension_keybinding_registry_views.cc

Issue 10201016: Conflict detection for Extension Keybinding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed comments Created 8 years, 8 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/ui/views/extensions/extension_keybinding_registry_views.cc
===================================================================
--- chrome/browser/ui/views/extensions/extension_keybinding_registry_views.cc (revision 134889)
+++ chrome/browser/ui/views/extensions/extension_keybinding_registry_views.cc (working copy)
@@ -5,6 +5,8 @@
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
+#include "chrome/browser/extensions/extension_command_service.h"
+#include "chrome/browser/extensions/extension_command_service_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension.h"
@@ -26,9 +28,12 @@
void ExtensionKeybindingRegistryViews::AddExtensionKeybinding(
const Extension* extension) {
- // Add all the keybindings (except pageAction and browserAction, which are
- // handled elsewhere).
- const Extension::CommandMap& commands = extension->named_commands();
+ ExtensionCommandService* command_service =
+ ExtensionCommandServiceFactory::GetForProfile(profile_);
+ // Add all the active keybindings (except page actions and browser actions,
+ // which are handled elsewhere).
+ const Extension::CommandMap& commands =
+ command_service->GetActiveNamedCommands(extension->id());
Extension::CommandMap::const_iterator iter = commands.begin();
for (; iter != commands.end(); ++iter) {
event_targets_[iter->second.accelerator()] =
@@ -41,12 +46,17 @@
void ExtensionKeybindingRegistryViews::RemoveExtensionKeybinding(
const Extension* extension) {
- EventTargets::const_iterator iter;
- for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) {
- if (iter->second.first != extension->id())
+ EventTargets::iterator iter = event_targets_.begin();
+ while (iter != event_targets_.end()) {
+ if (iter->second.first != extension->id()) {
+ ++iter;
continue; // Not the extension we asked for.
+ }
focus_manager_->UnregisterAccelerator(iter->first, this);
+
+ EventTargets::iterator old = iter++;
+ event_targets_.erase(old);
}
}

Powered by Google App Engine
This is Rietveld 408576698