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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.cc

Issue 904943003: Fixes component extension commands assignment on reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 return true; 302 return true;
303 } 303 }
304 304
305 void CommandService::OnExtensionWillBeInstalled( 305 void CommandService::OnExtensionWillBeInstalled(
306 content::BrowserContext* browser_context, 306 content::BrowserContext* browser_context,
307 const Extension* extension, 307 const Extension* extension,
308 bool is_update, 308 bool is_update,
309 bool from_ephemeral, 309 bool from_ephemeral,
310 const std::string& old_name) { 310 const std::string& old_name) {
311 // Component extensions don't generate normal install and uninstall events so 311 UpdateKeybindings(extension);
312 // those are handled in OnExtensionLoaded.
313 if (extension->location() != Manifest::COMPONENT)
Finnur 2015/02/18 11:51:31 It is good to see these special-cases go away.
314 UpdateKeybindings(extension);
315 } 312 }
316 313
317 void CommandService::OnExtensionUninstalled( 314 void CommandService::OnExtensionUninstalled(
318 content::BrowserContext* browser_context, 315 content::BrowserContext* browser_context,
319 const Extension* extension, 316 const Extension* extension,
320 extensions::UninstallReason reason) { 317 extensions::UninstallReason reason) {
318 if (reason == extensions::UNINSTALL_REASON_COMPONENT)
319 return;
Finnur 2015/02/18 11:51:31 A casual reader would benefit from an explanation
David Tseng 2015/02/18 18:24:40 Correct.
tapted 2015/02/18 23:10:55 Wow - those were some of my first patches on Chrom
David Tseng 2015/02/18 23:22:26 It does get triggered, but only on a version upgra
320
321 RemoveKeybindingPrefs(extension->id(), std::string()); 321 RemoveKeybindingPrefs(extension->id(), std::string());
322 } 322 }
323 323
324 void CommandService::OnExtensionLoaded(content::BrowserContext* browser_context,
325 const Extension* extension) {
326 if (extension->location() == Manifest::COMPONENT)
327 UpdateKeybindings(extension);
328 }
329
330 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, 324 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id,
331 const std::string& command_name, 325 const std::string& command_name,
332 const std::string& keystroke) { 326 const std::string& keystroke) {
333 Command command = FindCommandByName(extension_id, command_name); 327 Command command = FindCommandByName(extension_id, command_name);
334 328
335 // The extension command might be assigned another shortcut. Remove that 329 // The extension command might be assigned another shortcut. Remove that
336 // shortcut before proceeding. 330 // shortcut before proceeding.
337 RemoveKeybindingPrefs(extension_id, command_name); 331 RemoveKeybindingPrefs(extension_id, command_name);
338 332
339 ui::Accelerator accelerator = 333 ui::Accelerator accelerator =
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return true; 879 return true;
886 } 880 }
887 881
888 template <> 882 template <>
889 void 883 void
890 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { 884 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() {
891 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); 885 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance());
892 } 886 }
893 887
894 } // namespace extensions 888 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698