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

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

Issue 10701005: Extension Commands changed by the user now take effect immediately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
===================================================================
--- chrome/browser/extensions/extension_keybinding_registry.cc (revision 144430)
+++ chrome/browser/extensions/extension_keybinding_registry.cc (working copy)
@@ -4,11 +4,12 @@
#include "chrome/browser/extensions/extension_keybinding_registry.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_set.h"
-#include "chrome/browser/extensions/extension_service.h"
namespace extensions {
@@ -18,6 +19,10 @@
content::Source<Profile>(profile->GetOriginalProfile()));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile->GetOriginalProfile()));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED,
+ content::Source<Profile>(profile->GetOriginalProfile()));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED,
+ content::Source<Profile>(profile->GetOriginalProfile()));
}
ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() {
@@ -31,7 +36,7 @@
const ExtensionSet* extensions = service->extensions();
ExtensionSet::const_iterator iter = extensions->begin();
for (; iter != extensions->end(); ++iter)
- AddExtensionKeybinding(*iter);
+ AddExtensionKeybinding(*iter, std::string());
}
bool ExtensionKeybindingRegistry::ShouldIgnoreCommand(
@@ -47,12 +52,34 @@
switch (type) {
case chrome::NOTIFICATION_EXTENSION_LOADED:
AddExtensionKeybinding(
- content::Details<const extensions::Extension>(details).ptr());
+ content::Details<const extensions::Extension>(details).ptr(),
+ std::string());
break;
case chrome::NOTIFICATION_EXTENSION_UNLOADED:
RemoveExtensionKeybinding(
- content::Details<UnloadedExtensionInfo>(details)->extension);
+ content::Details<UnloadedExtensionInfo>(details)->extension,
+ std::string());
break;
+ case chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED:
+ case chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED: {
+ std::pair<const std::string, const std::string>* payload =
+ content::Details<std::pair<const std::string, const std::string> >(
+ details).ptr();
+
+ const extensions::Extension* extension =
+ ExtensionSystem::Get(profile_)->extension_service()->
+ extensions()->GetByID(payload->first);
+ // During install and uninstall the extension won't be found. We'll catch
+ // those events above, with the LOADED/UNLOADED, so we ignore this event.
+ if (!extension)
+ return;
Yoyo Zhou 2012/06/28 22:40:51 ShouldIgnoreCommand could go here instead of in th
Finnur 2012/06/28 22:49:01 No, this is actually deliberate. The Views impleme
+
+ if (type == chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED)
+ AddExtensionKeybinding(extension, payload->second);
+ else
+ RemoveExtensionKeybinding(extension, payload->second);
+ break;
+ }
default:
NOTREACHED();
break;

Powered by Google App Engine
This is Rietveld 408576698