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

Side by Side Diff: chrome/browser/extensions/extension_keybinding_registry.cc

Issue 788973002: Observe OnExtensionLoaded to trigger update of chrome.commands keybindings for component extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 const Extension* extension = ExtensionRegistry::Get(browser_context_) 192 const Extension* extension = ExtensionRegistry::Get(browser_context_)
193 ->enabled_extensions() 193 ->enabled_extensions()
194 .GetByID(payload->first); 194 .GetByID(payload->first);
195 // During install and uninstall the extension won't be found. We'll catch 195 // During install and uninstall the extension won't be found. We'll catch
196 // those events above, with the LOADED/UNLOADED, so we ignore this event. 196 // those events above, with the LOADED/UNLOADED, so we ignore this event.
197 if (!extension) 197 if (!extension)
198 return; 198 return;
199 199
200 if (ExtensionMatchesFilter(extension)) { 200 if (ExtensionMatchesFilter(extension)) {
201 // Component extensions triggers OnExtensionLoaded for extension
202 // installs as well as loads. This can cause adding of multiple key
Finnur 2015/01/08 14:13:50 It seems weird that OnExtensionLoaded is called tw
David Tseng 2015/01/08 20:34:41 It is clear after I got the right logging in. OnEx
203 // targets.
204 if (extension->location() == Manifest::COMPONENT)
205 return;
Finnur 2015/01/08 14:13:50 We don't need to early-return when type == COMMAND
David Tseng 2015/01/08 20:34:41 Done. (since we don't process OnExtensionUnloaded
206
201 if (type == extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED) 207 if (type == extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED)
202 AddExtensionKeybinding(extension, payload->second); 208 AddExtensionKeybinding(extension, payload->second);
203 else 209 else
204 RemoveExtensionKeybinding(extension, payload->second); 210 RemoveExtensionKeybinding(extension, payload->second);
205 } 211 }
206 break; 212 break;
207 } 213 }
208 default: 214 default:
209 NOTREACHED(); 215 NOTREACHED();
210 break; 216 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (extension_id.empty() || it->first == extension_id) { 248 if (extension_id.empty() || it->first == extension_id) {
243 CommandExecuted(it->first, it->second); 249 CommandExecuted(it->first, it->second);
244 executed = true; 250 executed = true;
245 } 251 }
246 } 252 }
247 253
248 return executed; 254 return executed;
249 } 255 }
250 256
251 } // namespace extensions 257 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698