Chromium Code Reviews| 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 return kExtensionXkbIdPrefix + keyboard_layout_id; | |
|
Yuki
2014/02/27 02:40:33
I think it would be safer to DCHECK(keyboard_layou
Shu Chen
2014/02/27 03:12:12
The passed in keyboard_layout_id could be a new ex
| |
| 60 } | |
| 61 | |
| 55 bool IsExtensionIME(const std::string& input_method_id) { | 62 bool IsExtensionIME(const std::string& input_method_id) { |
| 56 return StartsWithASCII(input_method_id, | 63 return StartsWithASCII(input_method_id, |
| 57 kExtensionIMEPrefix, | 64 kExtensionIMEPrefix, |
| 58 true); // Case sensitive. | 65 true); // Case sensitive. |
| 59 } | 66 } |
| 60 | 67 |
| 61 bool IsComponentExtensionIME(const std::string& input_method_id) { | 68 bool IsComponentExtensionIME(const std::string& input_method_id) { |
| 62 return StartsWithASCII(input_method_id, | 69 return StartsWithASCII(input_method_id, |
| 63 kComponentExtensionIMEPrefix, | 70 kComponentExtensionIMEPrefix, |
| 64 true); // Case sensitive. | 71 true); // Case sensitive. |
| 65 } | 72 } |
| 66 | 73 |
| 67 bool IsMemberOfExtension(const std::string& input_method_id, | 74 bool IsMemberOfExtension(const std::string& input_method_id, |
| 68 const std::string& extension_id) { | 75 const std::string& extension_id) { |
| 69 return StartsWithASCII(input_method_id, | 76 return StartsWithASCII(input_method_id, |
| 70 kExtensionIMEPrefix + extension_id, | 77 kExtensionIMEPrefix + extension_id, |
| 71 true); // Case sensitive. | 78 true); // Case sensitive. |
| 72 } | 79 } |
| 73 | 80 |
| 74 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { | 81 bool IsKeyboardLayoutExtension(const std::string& input_method_id) { |
| 75 return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true); | 82 return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true); |
| 76 } | 83 } |
| 77 | 84 |
| 78 } // namespace extension_ime_util | 85 } // namespace extension_ime_util |
| 79 } // namespace chromeos | 86 } // namespace chromeos |
| OLD | NEW |