OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chromeos/ime/extension_ime_util.h" | 5 #include "chromeos/ime/extension_ime_util.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 | 8 |
9 namespace chromeos { | 9 namespace chromeos { |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return StartsWithASCII(input_method_id, | 103 return StartsWithASCII(input_method_id, |
104 kExtensionIMEPrefix + extension_id, | 104 kExtensionIMEPrefix + extension_id, |
105 true); // Case sensitive. | 105 true); // Case sensitive. |
106 } | 106 } |
107 | 107 |
108 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { | 108 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { |
109 std::string prefix = kComponentExtensionIMEPrefix; | 109 std::string prefix = kComponentExtensionIMEPrefix; |
110 return StartsWithASCII(input_method_id, prefix + kXkbExtensionId, true); | 110 return StartsWithASCII(input_method_id, prefix + kXkbExtensionId, true); |
111 } | 111 } |
112 | 112 |
| 113 std::string GetEngineIDByInputMethodID(const std::string& input_method_id) { |
| 114 if (!IsComponentExtensionIME(input_method_id)) |
| 115 return input_method_id; |
| 116 return input_method_id.substr(kComponentExtensionIMEPrefixLength + |
| 117 kExtensionIdLength); |
| 118 } |
| 119 |
113 std::string MaybeGetLegacyXkbId(const std::string& input_method_id) { | 120 std::string MaybeGetLegacyXkbId(const std::string& input_method_id) { |
114 if (IsKeyboardLayoutExtension(input_method_id)) { | 121 if (IsKeyboardLayoutExtension(input_method_id)) |
115 size_t pos = input_method_id.find("xkb:"); | 122 return GetEngineIDByInputMethodID(input_method_id); |
116 if (pos != std::string::npos) | |
117 return input_method_id.substr(pos); | |
118 } | |
119 return input_method_id; | 123 return input_method_id; |
120 } | 124 } |
121 | 125 |
122 } // namespace extension_ime_util | 126 } // namespace extension_ime_util |
123 } // namespace chromeos | 127 } // namespace chromeos |
OLD | NEW |