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

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

Issue 14990002: Make sure keybindings removed don't come back during extension update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove command handler Created 7 years, 7 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 | Annotate | Revision Log
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 "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/api/commands/commands.h" 10 #include "chrome/browser/extensions/api/commands/commands.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 return ui::Accelerator(); 225 return ui::Accelerator();
226 } 226 }
227 227
228 void CommandService::AssignInitialKeybindings(const Extension* extension) { 228 void CommandService::AssignInitialKeybindings(const Extension* extension) {
229 const extensions::CommandMap* commands = 229 const extensions::CommandMap* commands =
230 CommandsInfo::GetNamedCommands(extension); 230 CommandsInfo::GetNamedCommands(extension);
231 if (!commands) 231 if (!commands)
232 return; 232 return;
233 233
234 ExtensionService* extension_service =
235 ExtensionSystem::Get(profile_)->extension_service();
236 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
237 if (extension_prefs->InitialBindingsHaveBeenAssigned(extension->id()))
Yoyo Zhou 2013/05/06 18:47:58 We now prefer to have less API-specific knowledge
Finnur 2013/05/06 23:13:54 Do you have a CL I can take a look at to see how t
Yoyo Zhou 2013/05/07 01:21:05 Sure, there's a good example in https://coderevie
238 return;
239 extension_prefs->SetInitialBindingsHaveBeenAssigned(extension->id());
240
234 extensions::CommandMap::const_iterator iter = commands->begin(); 241 extensions::CommandMap::const_iterator iter = commands->begin();
235 for (; iter != commands->end(); ++iter) { 242 for (; iter != commands->end(); ++iter) {
236 if (!chrome::IsChromeAccelerator( 243 if (!chrome::IsChromeAccelerator(
237 iter->second.accelerator(), profile_)) { 244 iter->second.accelerator(), profile_)) {
238 AddKeybindingPref(iter->second.accelerator(), 245 AddKeybindingPref(iter->second.accelerator(),
239 extension->id(), 246 extension->id(),
240 iter->second.command_name(), 247 iter->second.command_name(),
241 false); // Overwriting not allowed. 248 false); // Overwriting not allowed.
242 } 249 }
243 } 250 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return false; 373 return false;
367 374
368 *command = *requested_command; 375 *command = *requested_command;
369 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 376 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
370 command->set_accelerator(shortcut_assigned); 377 command->set_accelerator(shortcut_assigned);
371 378
372 return true; 379 return true;
373 } 380 }
374 381
375 } // namespace extensions 382 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698