| 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..8712451ee4b4d6ba32a59b2f6265a3d7b07be3d7 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 g_use_wrapped_extension_keyboard_layouts = true;
|
| } // 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,27 @@ bool IsKeyboardLayoutExtension(const std::string& input_method_id) {
|
| return StartsWithASCII(input_method_id, kExtensionXkbIdPrefix, true);
|
| }
|
|
|
| +bool UseWrappedExtensionKeyboardLayouts() {
|
| + return g_use_wrapped_extension_keyboard_layouts;
|
| +}
|
| +
|
| +std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
|
| + if (IsKeyboardLayoutExtension(input_method_id)) {
|
| + size_t pos = input_method_id.find("xkb:");
|
| + if (pos != std::string::npos)
|
| + return input_method_id.substr(pos);
|
| + }
|
| + return input_method_id;
|
| +}
|
| +
|
| +ScopedUseExtensionKeyboardFlagForTesting::
|
| + ScopedUseExtensionKeyboardFlagForTesting(bool new_flag)
|
| + : auto_reset_(&g_use_wrapped_extension_keyboard_layouts, new_flag) {
|
| +}
|
| +
|
| +ScopedUseExtensionKeyboardFlagForTesting::
|
| + ~ScopedUseExtensionKeyboardFlagForTesting() {
|
| +}
|
| +
|
| } // namespace extension_ime_util
|
| } // namespace chromeos
|
|
|