| 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 base::StartsWithASCII(key, Command::CommandPlatform() + ":", true); | 72 return base::StartsWith(key, Command::CommandPlatform() + ":", |
| 73 base::CompareCase::SENSITIVE); |
| 73 } | 74 } |
| 74 | 75 |
| 75 std::string StripCurrentPlatform(const std::string& key) { | 76 std::string StripCurrentPlatform(const std::string& key) { |
| 76 DCHECK(IsForCurrentPlatform(key)); | 77 DCHECK(IsForCurrentPlatform(key)); |
| 77 std::string result = key; | 78 std::string result = key; |
| 78 base::ReplaceFirstSubstringAfterOffset( | 79 base::ReplaceFirstSubstringAfterOffset( |
| 79 &result, 0, Command::CommandPlatform() + ":", base::StringPiece()); | 80 &result, 0, Command::CommandPlatform() + ":", base::StringPiece()); |
| 80 return result; | 81 return result; |
| 81 } | 82 } |
| 82 | 83 |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 return true; | 909 return true; |
| 909 } | 910 } |
| 910 | 911 |
| 911 template <> | 912 template <> |
| 912 void | 913 void |
| 913 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 914 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 914 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 915 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 915 } | 916 } |
| 916 | 917 |
| 917 } // namespace extensions | 918 } // namespace extensions |
| OLD | NEW |