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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.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 6 years 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
« no previous file with comments | « chrome/browser/extensions/api/commands/command_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/api/commands/command_service.h" 5 #include "chrome/browser/extensions/api/commands/command_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 std::make_pair(extension_id, command_name); 287 std::make_pair(extension_id, command_name);
288 content::NotificationService::current()->Notify( 288 content::NotificationService::current()->Notify(
289 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, 289 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED,
290 content::Source<Profile>(profile_), 290 content::Source<Profile>(profile_),
291 content::Details<std::pair<const std::string, const std::string> >( 291 content::Details<std::pair<const std::string, const std::string> >(
292 &details)); 292 &details));
293 293
294 return true; 294 return true;
295 } 295 }
296 296
297 void CommandService::OnExtensionWillBeInstalled( 297 void CommandService::OnExtensionLoaded(content::BrowserContext* browser_context,
298 content::BrowserContext* browser_context, 298 const Extension* extension) {
299 const Extension* extension,
300 bool is_update,
301 bool from_ephemeral,
302 const std::string& old_name) {
303 UpdateKeybindings(extension); 299 UpdateKeybindings(extension);
304 } 300 }
305 301
306 void CommandService::OnExtensionUninstalled( 302 void CommandService::OnExtensionUnloaded(
307 content::BrowserContext* browser_context, 303 content::BrowserContext* browser_context,
308 const Extension* extension, 304 const Extension* extension,
309 extensions::UninstallReason reason) { 305 UnloadedExtensionInfo::Reason reason) {
310 RemoveKeybindingPrefs(extension->id(), std::string()); 306 RemoveKeybindingPrefs(extension->id(), std::string());
Finnur 2014/12/10 12:25:38 If I temporarily disable an extension/it crashes,
David Tseng 2014/12/10 17:27:51 Done. Yup; that's the right way to do this; had on
311 } 307 }
312 308
313 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, 309 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id,
314 const std::string& command_name, 310 const std::string& command_name,
315 const std::string& keystroke) { 311 const std::string& keystroke) {
316 Command command = FindCommandByName(extension_id, command_name); 312 Command command = FindCommandByName(extension_id, command_name);
317 313
318 // The extension command might be assigned another shortcut. Remove that 314 // The extension command might be assigned another shortcut. Remove that
319 // shortcut before proceeding. 315 // shortcut before proceeding.
320 RemoveKeybindingPrefs(extension_id, command_name); 316 RemoveKeybindingPrefs(extension_id, command_name);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 return true; 859 return true;
864 } 860 }
865 861
866 template <> 862 template <>
867 void 863 void
868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { 864 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() {
869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); 865 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance());
870 } 866 }
871 867
872 } // namespace extensions 868 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/commands/command_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698