Chromium Code Reviews| 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/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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |