Chromium Code Reviews| Index: chromeos/ime/extension_ime_util.cc |
| diff --git a/chromeos/ime/extension_ime_util.cc b/chromeos/ime/extension_ime_util.cc |
| index 7955e52536caae6569ca3c4a917fb6f66e25ab55..55a290ba0d2e6408dfc0a3b4531181df6d650c9c 100644 |
| --- a/chromeos/ime/extension_ime_util.cc |
| +++ b/chromeos/ime/extension_ime_util.cc |
| @@ -18,6 +18,9 @@ const int kComponentExtensionIMEPrefixLength = |
| sizeof(kComponentExtensionIMEPrefix) / |
| sizeof(kComponentExtensionIMEPrefix[0]) - 1; |
| const int kExtensionIdLength = 32; |
| +// Hard coded to true. If the wrapped extension keyboards misbehaves, |
| +// we can easily change this to false to switch back to legacy xkb keyboards. |
| +bool use_wrapped_extension_keyboard_layouts = true; |
|
Yuki
2014/03/03 05:59:06
Could you rename this to g_use_wrapped_... because
Shu Chen
2014/03/03 08:24:37
Done.
|
| } // namespace |
| namespace extension_ime_util { |
| @@ -52,6 +55,19 @@ std::string GetExtensionIDFromInputMethodID( |
| return ""; |
| } |
| +std::string GetInputMethodIDByKeyboardLayout( |
| + const std::string& keyboard_layout_id) { |
| + bool migrate = UseWrappedExtensionKeyboardLayouts(); |
| + if (IsKeyboardLayoutExtension(keyboard_layout_id)) { |
| + if (migrate) |
| + return keyboard_layout_id; |
| + return keyboard_layout_id.substr(arraysize(kExtensionXkbIdPrefix) - 1); |
| + } |
| + if (migrate && StartsWithASCII(keyboard_layout_id, "xkb:", true)) |
| + return kExtensionXkbIdPrefix + keyboard_layout_id; |
| + return keyboard_layout_id; |
| +} |
| + |
| bool IsExtensionIME(const std::string& input_method_id) { |
| return StartsWithASCII(input_method_id, |
| kExtensionIMEPrefix, |
| @@ -75,5 +91,15 @@ bool IsKeyboardLayoutExtension(const std::string& input_method_id) { |
| return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true); |
| } |
| +bool UseWrappedExtensionKeyboardLayouts() { |
| + return use_wrapped_extension_keyboard_layouts; |
| +} |
| + |
| +bool SetUseWrappedExtensionKeyboardLayoutsFlagForTesting(bool enabled) { |
| + bool ret = use_wrapped_extension_keyboard_layouts; |
| + use_wrapped_extension_keyboard_layouts = enabled; |
| + return ret; |
| +} |
| + |
| } // namespace extension_ime_util |
| } // namespace chromeos |