OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 5 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 8 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/extensions/command.h" | 10 #include "chrome/common/extensions/command.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 const Extension* extension = ExtensionRegistry::Get(browser_context_) | 191 const Extension* extension = ExtensionRegistry::Get(browser_context_) |
192 ->enabled_extensions() | 192 ->enabled_extensions() |
193 .GetByID(payload->extension_id); | 193 .GetByID(payload->extension_id); |
194 // During install and uninstall the extension won't be found. We'll catch | 194 // During install and uninstall the extension won't be found. We'll catch |
195 // those events above, with the LOADED/UNLOADED, so we ignore this event. | 195 // those events above, with the LOADED/UNLOADED, so we ignore this event. |
196 if (!extension) | 196 if (!extension) |
197 return; | 197 return; |
198 | 198 |
199 if (ExtensionMatchesFilter(extension)) { | 199 if (ExtensionMatchesFilter(extension)) { |
200 if (type == extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED) | 200 if (type == extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED) { |
| 201 // Component extensions triggers OnExtensionLoaded for extension |
| 202 // installs as well as loads. This can cause adding of multiple key |
| 203 // targets. |
| 204 if (extension->location() == Manifest::COMPONENT) |
| 205 return; |
| 206 |
201 AddExtensionKeybindings(extension, payload->command_name); | 207 AddExtensionKeybindings(extension, payload->command_name); |
202 else | 208 } else { |
203 RemoveExtensionKeybinding(extension, payload->command_name); | 209 RemoveExtensionKeybinding(extension, payload->command_name); |
| 210 } |
204 } | 211 } |
205 break; | 212 break; |
206 } | 213 } |
207 default: | 214 default: |
208 NOTREACHED(); | 215 NOTREACHED(); |
209 break; | 216 break; |
210 } | 217 } |
211 } | 218 } |
212 | 219 |
213 bool ExtensionKeybindingRegistry::ExtensionMatchesFilter( | 220 bool ExtensionKeybindingRegistry::ExtensionMatchesFilter( |
(...skipping 27 matching lines...) Expand all Loading... |
241 if (extension_id.empty() || it->first == extension_id) { | 248 if (extension_id.empty() || it->first == extension_id) { |
242 CommandExecuted(it->first, it->second); | 249 CommandExecuted(it->first, it->second); |
243 executed = true; | 250 executed = true; |
244 } | 251 } |
245 } | 252 } |
246 | 253 |
247 return executed; | 254 return executed; |
248 } | 255 } |
249 | 256 |
250 } // namespace extensions | 257 } // namespace extensions |
OLD | NEW |