Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: chromeos/ime/extension_ime_util.cc

Issue 309623005: Remove the flag g_use_wrapped_extension_keyboard_layouts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/ime/extension_ime_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/ime/extension_ime_util.cc
diff --git a/chromeos/ime/extension_ime_util.cc b/chromeos/ime/extension_ime_util.cc
index 9a1ee887642d76049eb90809c0335eafc0bcb826..474622df28773e9271c9baf3501457eceb6b5ca1 100644
--- a/chromeos/ime/extension_ime_util.cc
+++ b/chromeos/ime/extension_ime_util.cc
@@ -7,26 +7,22 @@
#include "base/strings/string_util.h"
namespace chromeos {
+
namespace {
+
const char kExtensionIMEPrefix[] = "_ext_ime_";
const int kExtensionIMEPrefixLength =
sizeof(kExtensionIMEPrefix) / sizeof(kExtensionIMEPrefix[0]) - 1;
const char kComponentExtensionIMEPrefix[] = "_comp_ime_";
-const char kPublicExtensionXkbIdPrefix[] =
- "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkao";
-const char kInternalExtensionXkbIdPrefix[] =
- "_comp_ime_jkghodnilhceideoidjikpgommlajknk";
-
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 {
+
std::string GetInputMethodID(const std::string& extension_id,
const std::string& engine_id) {
DCHECK(!extension_id.empty());
@@ -58,25 +54,36 @@ std::string GetExtensionIDFromInputMethodID(
return "";
}
-std::string GetInputMethodIDByKeyboardLayout(
- const std::string& keyboard_layout_id) {
- const char* kExtensionXkbIdPrefix =
-#if defined(OFFICIAL_BUILD)
- kInternalExtensionXkbIdPrefix;
-#else
- kPublicExtensionXkbIdPrefix;
-#endif
- bool migrate = UseWrappedExtensionKeyboardLayouts();
- if (IsKeyboardLayoutExtension(keyboard_layout_id)) {
- std::string id = keyboard_layout_id.substr(
- arraysize(kPublicExtensionXkbIdPrefix) - 1);
- if (migrate)
- return kExtensionXkbIdPrefix + id;
- return id;
+std::string GetInputMethodIDByEngineID(const std::string& engine_id) {
+ if (StartsWithASCII(engine_id, kComponentExtensionIMEPrefix, true) ||
+ StartsWithASCII(engine_id, kExtensionIMEPrefix, true)) {
+ return engine_id;
+ }
+ if (StartsWithASCII(engine_id, "xkb:", true))
+ return GetComponentInputMethodID(kXkbExtensionId, engine_id);
+ if (StartsWithASCII(engine_id, "vkd_", true))
+ return GetComponentInputMethodID(kM17nExtensionId, engine_id);
+ if (StartsWithASCII(engine_id, "nacl_mozc_", true))
+ return GetComponentInputMethodID(kMozcExtensionId, engine_id);
+ if (StartsWithASCII(engine_id, "hangul_", true))
+ return GetComponentInputMethodID(kHangulExtensionId, engine_id);
+
+ if (StartsWithASCII(engine_id, "zh-", true) &&
+ engine_id.find("pinyin") != std::string::npos) {
+ return GetComponentInputMethodID(kChinesePinyinExtensionId, engine_id);
+ }
+ if (StartsWithASCII(engine_id, "zh-", true) &&
+ engine_id.find("zhuyin") != std::string::npos) {
+ return GetComponentInputMethodID(kChineseZhuyinExtensionId, engine_id);
+ }
+ if (StartsWithASCII(engine_id, "zh-", true) &&
+ engine_id.find("cangjie") != std::string::npos) {
+ return GetComponentInputMethodID(kChineseCangjieExtensionId, engine_id);
}
- if (migrate && StartsWithASCII(keyboard_layout_id, "xkb:", true))
- return kExtensionXkbIdPrefix + keyboard_layout_id;
- return keyboard_layout_id;
+ if (engine_id.find("-t-i0-") != std::string::npos)
+ return GetComponentInputMethodID(kT13nExtensionId, engine_id);
+
+ return engine_id;
}
bool IsExtensionIME(const std::string& input_method_id) {
@@ -99,12 +106,8 @@ bool IsMemberOfExtension(const std::string& input_method_id,
}
bool IsKeyboardLayoutExtension(const std::string& input_method_id) {
- return StartsWithASCII(input_method_id, kPublicExtensionXkbIdPrefix, true) ||
- StartsWithASCII(input_method_id, kInternalExtensionXkbIdPrefix, true);
-}
-
-bool UseWrappedExtensionKeyboardLayouts() {
- return g_use_wrapped_extension_keyboard_layouts;
+ std::string prefix = kComponentExtensionIMEPrefix;
+ return StartsWithASCII(input_method_id, prefix + kXkbExtensionId, true);
}
std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
@@ -116,14 +119,5 @@ std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
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
« no previous file with comments | « chromeos/ime/extension_ime_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698