| 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 1d6001e280b12cde9da61c881be6af3164d68353..cb584b21b6b1d492b54680393b1a4de1ef3c9554 100644
|
| --- a/chrome/browser/extensions/extension_keybinding_registry.cc
|
| +++ b/chrome/browser/extensions/extension_keybinding_registry.cc
|
| @@ -13,8 +13,9 @@
|
|
|
| namespace extensions {
|
|
|
| -ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(Profile* profile)
|
| - : profile_(profile) {
|
| +ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(
|
| + Profile* profile, ExtensionFilter extension_filter)
|
| + : profile_(profile), extension_filter_(extension_filter) {
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
|
| content::Source<Profile>(profile->GetOriginalProfile()));
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| @@ -36,7 +37,8 @@ void ExtensionKeybindingRegistry::Init() {
|
| const ExtensionSet* extensions = service->extensions();
|
| ExtensionSet::const_iterator iter = extensions->begin();
|
| for (; iter != extensions->end(); ++iter)
|
| - AddExtensionKeybinding(*iter, std::string());
|
| + if (ExtensionMatchesFilter(*iter))
|
| + AddExtensionKeybinding(*iter, std::string());
|
| }
|
|
|
| bool ExtensionKeybindingRegistry::ShouldIgnoreCommand(
|
| @@ -51,16 +53,20 @@ void ExtensionKeybindingRegistry::Observe(
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| switch (type) {
|
| - case chrome::NOTIFICATION_EXTENSION_LOADED:
|
| - AddExtensionKeybinding(
|
| - content::Details<const extensions::Extension>(details).ptr(),
|
| - std::string());
|
| + case chrome::NOTIFICATION_EXTENSION_LOADED: {
|
| + const extensions::Extension* extension =
|
| + content::Details<const extensions::Extension>(details).ptr();
|
| + if (ExtensionMatchesFilter(extension))
|
| + AddExtensionKeybinding(extension, std::string());
|
| break;
|
| - case chrome::NOTIFICATION_EXTENSION_UNLOADED:
|
| - RemoveExtensionKeybinding(
|
| - content::Details<UnloadedExtensionInfo>(details)->extension,
|
| - std::string());
|
| + }
|
| + case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
|
| + const extensions::Extension* extension =
|
| + content::Details<UnloadedExtensionInfo>(details)->extension;
|
| + if (ExtensionMatchesFilter(extension))
|
| + RemoveExtensionKeybinding(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 =
|
| @@ -75,10 +81,12 @@ void ExtensionKeybindingRegistry::Observe(
|
| if (!extension)
|
| return;
|
|
|
| - if (type == chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED)
|
| - AddExtensionKeybinding(extension, payload->second);
|
| - else
|
| - RemoveExtensionKeybinding(extension, payload->second);
|
| + if (ExtensionMatchesFilter(extension)) {
|
| + if (type == chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED)
|
| + AddExtensionKeybinding(extension, payload->second);
|
| + else
|
| + RemoveExtensionKeybinding(extension, payload->second);
|
| + }
|
| break;
|
| }
|
| default:
|
| @@ -87,4 +95,18 @@ void ExtensionKeybindingRegistry::Observe(
|
| }
|
| }
|
|
|
| +bool ExtensionKeybindingRegistry::ExtensionMatchesFilter(
|
| + const extensions::Extension* extension)
|
| +{
|
| + switch (extension_filter_) {
|
| + case ALL_EXTENSIONS:
|
| + return true;
|
| + case PLATFORM_APP_ONLY:
|
| + return extension->is_platform_app();
|
| + default:
|
| + NOTREACHED();
|
| + }
|
| + return false;
|
| +}
|
| +
|
| } // namespace extensions
|
|
|