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 MaybeGetLegacyXkbId(const std::string& input_method_id) { | 113 std::string GetEngineIDByInputMethodID(const std::string& input_method_id) { |
114 if (IsKeyboardLayoutExtension(input_method_id)) { | 114 if (!IsComponentExtensionIME(input_method_id)) |
115 size_t pos = input_method_id.find("xkb:"); | 115 return input_method_id; |
116 if (pos != std::string::npos) | 116 |
Shu Chen
2014/07/02 02:29:04
just do:
return input_method_id.substr(kComponent
michaelpg
2014/07/10 00:46:01
Done.
| |
117 size_t pos = std::string::npos; | |
118 if (IsKeyboardLayoutExtension(input_method_id)) | |
119 pos = input_method_id.find("xkb:"); | |
120 else | |
121 pos = input_method_id.find(kComponentExtensionIMEPrefix); | |
122 | |
123 if (pos != std::string::npos) | |
117 return input_method_id.substr(pos); | 124 return input_method_id.substr(pos); |
118 } | |
119 return input_method_id; | 125 return input_method_id; |
120 } | 126 } |
121 | 127 |
128 std::string MaybeGetLegacyXkbId(const std::string& input_method_id) { | |
129 if (IsKeyboardLayoutExtension(input_method_id)) | |
130 return GetEngineIDByInputMethodID(input_method_id); | |
131 return input_method_id; | |
132 } | |
133 | |
122 } // namespace extension_ime_util | 134 } // namespace extension_ime_util |
123 } // namespace chromeos | 135 } // namespace chromeos |
OLD | NEW |