| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // shortcut (1-to-1 relationship). That means two or more extensions can | 62 // shortcut (1-to-1 relationship). That means two or more extensions can |
| 63 // register for the same media key so the extension ID needs to be added to | 63 // register for the same media key so the extension ID needs to be added to |
| 64 // the key to make sure the key is unique. | 64 // the key to make sure the key is unique. |
| 65 if (Command::IsMediaKey(accelerator)) | 65 if (Command::IsMediaKey(accelerator)) |
| 66 key += ":" + extension_id; | 66 key += ":" + extension_id; |
| 67 | 67 |
| 68 return key; | 68 return key; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool IsForCurrentPlatform(const std::string& key) { | 71 bool IsForCurrentPlatform(const std::string& key) { |
| 72 return StartsWithASCII(key, Command::CommandPlatform() + ":", true); | 72 return base::StartsWithASCII(key, Command::CommandPlatform() + ":", true); |
| 73 } | 73 } |
| 74 | 74 |
| 75 std::string StripCurrentPlatform(const std::string& key) { | 75 std::string StripCurrentPlatform(const std::string& key) { |
| 76 DCHECK(IsForCurrentPlatform(key)); | 76 DCHECK(IsForCurrentPlatform(key)); |
| 77 std::string result = key; | 77 std::string result = key; |
| 78 ReplaceFirstSubstringAfterOffset(&result, 0, Command::CommandPlatform() + ":", | 78 ReplaceFirstSubstringAfterOffset(&result, 0, Command::CommandPlatform() + ":", |
| 79 ""); | 79 ""); |
| 80 return result; | 80 return result; |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 return true; | 908 return true; |
| 909 } | 909 } |
| 910 | 910 |
| 911 template <> | 911 template <> |
| 912 void | 912 void |
| 913 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 913 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 914 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 914 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 915 } | 915 } |
| 916 | 916 |
| 917 } // namespace extensions | 917 } // namespace extensions |
| OLD | NEW |