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 <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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 item->GetString(kCommandName, &command_name); | 382 item->GetString(kCommandName, &command_name); |
383 if (command != command_name) | 383 if (command != command_name) |
384 continue; | 384 continue; |
385 // Format stored in Preferences is: "Platform:Shortcut[:ExtensionId]". | 385 // Format stored in Preferences is: "Platform:Shortcut[:ExtensionId]". |
386 std::string shortcut = it.key(); | 386 std::string shortcut = it.key(); |
387 if (!IsForCurrentPlatform(shortcut)) | 387 if (!IsForCurrentPlatform(shortcut)) |
388 continue; | 388 continue; |
389 bool global = false; | 389 bool global = false; |
390 item->GetBoolean(kGlobal, &global); | 390 item->GetBoolean(kGlobal, &global); |
391 | 391 |
392 std::vector<std::string> tokens; | 392 std::vector<base::StringPiece> tokens = base::SplitStringPiece( |
393 base::SplitString(shortcut, ':', &tokens); | 393 shortcut, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
394 CHECK(tokens.size() >= 2); | 394 CHECK(tokens.size() >= 2); |
395 shortcut = tokens[1]; | |
396 | 395 |
397 return Command(command_name, base::string16(), shortcut, global); | 396 return Command(command_name, base::string16(), tokens[1].as_string(), |
| 397 global); |
398 } | 398 } |
399 | 399 |
400 return Command(); | 400 return Command(); |
401 } | 401 } |
402 | 402 |
403 bool CommandService::GetSuggestedExtensionCommand( | 403 bool CommandService::GetSuggestedExtensionCommand( |
404 const std::string& extension_id, | 404 const std::string& extension_id, |
405 const ui::Accelerator& accelerator, | 405 const ui::Accelerator& accelerator, |
406 Command* command, | 406 Command* command, |
407 ExtensionCommandType* command_type) const { | 407 ExtensionCommandType* command_type) const { |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 return true; | 909 return true; |
910 } | 910 } |
911 | 911 |
912 template <> | 912 template <> |
913 void | 913 void |
914 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 914 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
915 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 915 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
916 } | 916 } |
917 | 917 |
918 } // namespace extensions | 918 } // namespace extensions |
OLD | NEW |