| 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 namespace { | 10 namespace { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 if (IsComponentExtensionIME(input_method_id) && | 46 if (IsComponentExtensionIME(input_method_id) && |
| 47 input_method_id.size() >= kComponentExtensionIMEPrefixLength + | 47 input_method_id.size() >= kComponentExtensionIMEPrefixLength + |
| 48 kExtensionIdLength) { | 48 kExtensionIdLength) { |
| 49 return input_method_id.substr(kComponentExtensionIMEPrefixLength, | 49 return input_method_id.substr(kComponentExtensionIMEPrefixLength, |
| 50 kExtensionIdLength); | 50 kExtensionIdLength); |
| 51 } | 51 } |
| 52 return ""; | 52 return ""; |
| 53 } | 53 } |
| 54 | 54 |
| 55 std::string GetInputMethodIDByKeyboardLayout( |
| 56 const std::string& keyboard_layout_id) { |
| 57 if (IsKeyboardLayoutExtension(keyboard_layout_id)) |
| 58 return keyboard_layout_id; |
| 59 DCHECK(StartsWithASCII(keyboard_layout_id, "xkb:", true)); |
| 60 return kExtensionXkbIdPrefix + keyboard_layout_id; |
| 61 } |
| 62 |
| 55 bool IsExtensionIME(const std::string& input_method_id) { | 63 bool IsExtensionIME(const std::string& input_method_id) { |
| 56 return StartsWithASCII(input_method_id, | 64 return StartsWithASCII(input_method_id, |
| 57 kExtensionIMEPrefix, | 65 kExtensionIMEPrefix, |
| 58 true); // Case sensitive. | 66 true); // Case sensitive. |
| 59 } | 67 } |
| 60 | 68 |
| 61 bool IsComponentExtensionIME(const std::string& input_method_id) { | 69 bool IsComponentExtensionIME(const std::string& input_method_id) { |
| 62 return StartsWithASCII(input_method_id, | 70 return StartsWithASCII(input_method_id, |
| 63 kComponentExtensionIMEPrefix, | 71 kComponentExtensionIMEPrefix, |
| 64 true); // Case sensitive. | 72 true); // Case sensitive. |
| 65 } | 73 } |
| 66 | 74 |
| 67 bool IsMemberOfExtension(const std::string& input_method_id, | 75 bool IsMemberOfExtension(const std::string& input_method_id, |
| 68 const std::string& extension_id) { | 76 const std::string& extension_id) { |
| 69 return StartsWithASCII(input_method_id, | 77 return StartsWithASCII(input_method_id, |
| 70 kExtensionIMEPrefix + extension_id, | 78 kExtensionIMEPrefix + extension_id, |
| 71 true); // Case sensitive. | 79 true); // Case sensitive. |
| 72 } | 80 } |
| 73 | 81 |
| 74 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { | 82 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { |
| 75 return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true); | 83 return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true); |
| 76 } | 84 } |
| 77 | 85 |
| 78 } // namespace extension_ime_util | 86 } // namespace extension_ime_util |
| 79 } // namespace chromeos | 87 } // namespace chromeos |
| OLD | NEW |