Move all white-listed input method indicator text from InputMethodUtil to manifests of IME extensions.
BUG=232260 TEST=Verified on linux_chromeos. Review URL: https://codereview.chromium.org/608183002 Cr-Commit-Position: refs/heads/master@{#297357}
This commit is contained in:
chrome/browser
chromeos
input_method
resources
chromeos/ime
component_extension_ime_manager.cccomponent_extension_ime_manager.hextension_ime_util.ccinput_method_descriptor.ccinput_method_descriptor.h
extensions/common
@ -345,6 +345,8 @@ bool ComponentExtensionIMEManagerImpl::ReadEngineComponent(
|
||||
return false;
|
||||
if (!dict.GetString(extensions::manifest_keys::kName, &out->display_name))
|
||||
return false;
|
||||
if (!dict.GetString(extensions::manifest_keys::kIndicator, &out->indicator))
|
||||
out->indicator = "";
|
||||
|
||||
// Localizes the input method name.
|
||||
if (out->display_name.find("__MSG_") == 0) {
|
||||
|
@ -27,41 +27,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// A mapping from an input method id to a string for the language indicator. The
|
||||
// mapping is necessary since some input methods belong to the same language.
|
||||
// For example, both "xkb:us::eng" and "xkb:us:dvorak:eng" are for US English.
|
||||
const struct {
|
||||
const char* engine_id;
|
||||
const char* indicator_text;
|
||||
} kMappingFromIdToIndicatorText[] = {
|
||||
// To distinguish from "xkb:jp::jpn"
|
||||
// TODO(nona): Make following variables configurable. http://crbug.com/232260.
|
||||
{ "nacl_mozc_us", "\xe3\x81\x82" },
|
||||
{ "nacl_mozc_jp", "\xe3\x81\x82" },
|
||||
// For simplified Chinese input methods
|
||||
{ "zh-t-i0-pinyin", "\xe6\x8b\xbc" }, // U+62FC
|
||||
{ "zh-t-i0-wubi-1986", "\xe4\xba\x94" }, // U+4E94
|
||||
// For traditional Chinese input methods
|
||||
{ "zh-hant-t-i0-pinyin", "\xe6\x8b\xbc" }, // U+62FC
|
||||
{ "zh-hant-t-i0-und", "\xE6\xB3\xA8" }, // U+9177
|
||||
{ "zh-hant-t-i0-cangjie-1987", "\xe5\x80\x89" }, // U+5009
|
||||
{ "zh-hant-t-i0-cangjie-1987-x-m0-simplified", "\xe9\x80\x9f" }, // U+901F
|
||||
// For Hangul input method.
|
||||
{ "hangul_ahnmatae", "\xed\x95\x9c" }, // U+D55C
|
||||
{ "hangul_2set", "\xed\x95\x9c" }, // U+D55C
|
||||
{ "hangul_3set390", "\xed\x95\x9c" }, // U+D55C
|
||||
{ "hangul_3setfinal", "\xed\x95\x9c" }, // U+D55C
|
||||
{ "hangul_3setnoshift", "\xed\x95\x9c" }, // U+D55C
|
||||
{ "hangul_romaja", "\xed\x95\x9c" }, // U+D55C
|
||||
{ extension_misc::kBrailleImeEngineId,
|
||||
// U+2803 U+2817 U+2807 (Unicode braille patterns for the letters 'brl' in
|
||||
// English (and many other) braille codes.
|
||||
"\xe2\xa0\x83\xe2\xa0\x97\xe2\xa0\x87" },
|
||||
};
|
||||
|
||||
const size_t kMappingFromIdToIndicatorTextLen =
|
||||
ARRAYSIZE_UNSAFE(kMappingFromIdToIndicatorText);
|
||||
|
||||
// A mapping from an input method id to a resource id for a
|
||||
// medium length language indicator.
|
||||
// For those languages that want to display a slightly longer text in the
|
||||
@ -106,61 +71,6 @@ const struct {
|
||||
{ "vi", "us", "vkd_vi_tcvn" },
|
||||
};
|
||||
|
||||
// The map from xkb layout to the indicator text.
|
||||
// Refer to crbug.com/349829.
|
||||
const char* const kXkbIndicators[][2] = {{"am", "AM"},
|
||||
{"be", "BE"},
|
||||
{"bg", "BG"},
|
||||
{"bg(phonetic)", "BG"},
|
||||
{"br", "BR"},
|
||||
{"by", "BY"},
|
||||
{"ca", "CA"},
|
||||
{"ca(eng)", "CA"},
|
||||
{"ca(multix)", "CA"},
|
||||
{"ch", "CH"},
|
||||
{"ch(fr)", "CH"},
|
||||
{"cz", "CZ"},
|
||||
{"cz(qwerty)", "CS"},
|
||||
{"de", "DE"},
|
||||
{"de(neo)", "NEO"},
|
||||
{"dk", "DK"},
|
||||
{"ee", "EE"},
|
||||
{"es", "ES"},
|
||||
{"es(cat)", "CAS"},
|
||||
{"fi", "FI"},
|
||||
{"fr", "FR"},
|
||||
{"gb(dvorak)", "DV"},
|
||||
{"gb(extd)", "GB"},
|
||||
{"ge", "GE"},
|
||||
{"gr", "GR"},
|
||||
{"hr", "HR"},
|
||||
{"hu", "HU"},
|
||||
{"il", "IL"},
|
||||
{"is", "IS"},
|
||||
{"it", "IT"},
|
||||
{"jp", "JA"},
|
||||
{"latam", "LA"},
|
||||
{"lt", "LT"},
|
||||
{"lv(apostrophe)", "LV"},
|
||||
{"mn", "MN"},
|
||||
{"no", "NO"},
|
||||
{"pl", "PL"},
|
||||
{"pt", "PT"},
|
||||
{"ro", "RO"},
|
||||
{"rs", "RS"},
|
||||
{"ru", "RU"},
|
||||
{"ru(phonetic)", "RU"},
|
||||
{"se", "SE"},
|
||||
{"si", "SI"},
|
||||
{"sk", "SK"},
|
||||
{"tr", "TR"},
|
||||
{"ua", "UA"},
|
||||
{"us", "US"},
|
||||
{"us(altgr-intl)", "EXTD"},
|
||||
{"us(colemak)", "CO"},
|
||||
{"us(dvorak)", "DV"},
|
||||
{"us(intl)", "INTL"}, };
|
||||
|
||||
// The extension ID map for migration.
|
||||
const char* const kExtensionIdMigrationMap[][2] = {
|
||||
// Official Japanese IME extension ID.
|
||||
@ -299,11 +209,6 @@ InputMethodUtil::InputMethodUtil(InputMethodDelegate* delegate)
|
||||
DCHECK(result) << "Duplicated string is found: "
|
||||
<< map_entry.english_string_from_ibus;
|
||||
}
|
||||
|
||||
// Initialize the map from xkb layout to indicator text.
|
||||
for (size_t i = 0; i < arraysize(kXkbIndicators); ++i) {
|
||||
xkb_layout_to_indicator_[kXkbIndicators[i][0]] = kXkbIndicators[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
InputMethodUtil::~InputMethodUtil() {
|
||||
@ -375,47 +280,9 @@ std::string InputMethodUtil::GetInputMethodDisplayNameFromId(
|
||||
|
||||
base::string16 InputMethodUtil::GetInputMethodShortName(
|
||||
const InputMethodDescriptor& input_method) const {
|
||||
// For the status area, we use two-letter, upper-case language code like
|
||||
// "US" and "JP".
|
||||
|
||||
// Use the indicator string if set.
|
||||
if (!input_method.indicator().empty()) {
|
||||
return base::UTF8ToUTF16(input_method.indicator());
|
||||
}
|
||||
|
||||
base::string16 text;
|
||||
// Check special cases first.
|
||||
for (size_t i = 0; i < kMappingFromIdToIndicatorTextLen; ++i) {
|
||||
if (extension_ime_util::GetInputMethodIDByEngineID(
|
||||
kMappingFromIdToIndicatorText[i].engine_id) == input_method.id()) {
|
||||
text = base::UTF8ToUTF16(kMappingFromIdToIndicatorText[i].indicator_text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Display the keyboard layout name when using a keyboard layout.
|
||||
if (text.empty() && IsKeyboardLayout(input_method.id())) {
|
||||
std::map<std::string, std::string>::const_iterator it =
|
||||
xkb_layout_to_indicator_.find(GetKeyboardLayoutName(input_method.id()));
|
||||
if (it != xkb_layout_to_indicator_.end())
|
||||
text = base::UTF8ToUTF16(it->second);
|
||||
}
|
||||
|
||||
// TODO(yusukes): Some languages have two or more input methods. For example,
|
||||
// Thai has 3, Vietnamese has 4. If these input methods could be activated at
|
||||
// the same time, we should do either of the following:
|
||||
// (1) Add mappings to |kMappingFromIdToIndicatorText|
|
||||
// (2) Add suffix (1, 2, ...) to |text| when ambiguous.
|
||||
|
||||
if (text.empty()) {
|
||||
const size_t kMaxLanguageNameLen = 2;
|
||||
DCHECK(!input_method.language_codes().empty());
|
||||
const std::string language_code = input_method.language_codes().at(0);
|
||||
text = StringToUpperASCII(base::UTF8ToUTF16(language_code)).substr(
|
||||
0, kMaxLanguageNameLen);
|
||||
}
|
||||
DCHECK(!text.empty()) << input_method.id();
|
||||
return text;
|
||||
// TODO(shuchen): remove this method, as the client can directly use
|
||||
// input_method.GetIndicator().
|
||||
return base::UTF8ToUTF16(input_method.GetIndicator());
|
||||
}
|
||||
|
||||
base::string16 InputMethodUtil::GetInputMethodMediumName(
|
||||
|
@ -182,7 +182,6 @@ class InputMethodUtil {
|
||||
|
||||
LanguageCodeToIdsMap language_code_to_ids_;
|
||||
InputMethodIdToDescriptorMap id_to_descriptor_;
|
||||
std::map<std::string, std::string> xkb_layout_to_indicator_;
|
||||
|
||||
typedef base::hash_map<std::string, int> HashType;
|
||||
HashType english_to_resource_id_;
|
||||
|
@ -159,12 +159,13 @@ TEST_F(InputMethodUtilTest, GetInputMethodShortNameTest) {
|
||||
}
|
||||
{
|
||||
InputMethodDescriptor desc =
|
||||
GetDesc(pinyin_ime_id, "us", "zh-CN", "");
|
||||
GetDesc(pinyin_ime_id, "us", "zh-CN", "\xe6\x8b\xbc");
|
||||
EXPECT_EQ(base::UTF8ToUTF16("\xe6\x8b\xbc"),
|
||||
util_.GetInputMethodShortName(desc));
|
||||
}
|
||||
{
|
||||
InputMethodDescriptor desc = GetDesc(zhuyin_ime_id, "us", "zh-TW", "");
|
||||
InputMethodDescriptor desc =
|
||||
GetDesc(zhuyin_ime_id, "us", "zh-TW", "\xE6\xB3\xA8");
|
||||
EXPECT_EQ(base::UTF8ToUTF16("\xE6\xB3\xA8"),
|
||||
util_.GetInputMethodShortName(desc));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
"name": "Braille Keyboard",
|
||||
"type": "ime",
|
||||
"id": "braille",
|
||||
"indicator": "\u2803\u2817\u2807", // Unicode of 'brl' in English (and many other) braille codes.
|
||||
"language": ["None"],
|
||||
"description": "Braille hardware keyboard"
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
"name": "__MSG_inputmethod_cangjie__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-cangjie-1987",
|
||||
"indicator": "\u5009",
|
||||
"description": "Cangjie",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"]
|
||||
|
@ -24,6 +24,7 @@
|
||||
"name": "__MSG_inputmethod_pinyin__",
|
||||
"type": "ime",
|
||||
"id": "zh-t-i0-pinyin",
|
||||
"indicator": "\u62FC",
|
||||
"description": "Pinyin",
|
||||
"language": ["zh-CN", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -34,6 +35,7 @@
|
||||
"name": "__MSG_inputmethod_traditional_pinyin__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-pinyin",
|
||||
"indicator": "\u62FC",
|
||||
"description": "Pinyin for Tranditional Chinese",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -44,6 +46,7 @@
|
||||
"name": "__MSG_inputmethod_cangjie__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-cangjie-1987",
|
||||
"indicator": "\u5009",
|
||||
"description": "Cangjie",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -53,6 +56,7 @@
|
||||
"name": "__MSG_inputmethod_quick__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-cangjie-1987-x-m0-simplified",
|
||||
"indicator": "\u901F",
|
||||
"description": "Quick",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -62,6 +66,7 @@
|
||||
"name": "__MSG_inputmethod_wubi__",
|
||||
"type": "ime",
|
||||
"id": "zh-t-i0-wubi-1986",
|
||||
"indicator": "\u4E94",
|
||||
"description": "Wubi",
|
||||
"language": ["zh-CN", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -71,6 +76,7 @@
|
||||
"name": "__MSG_inputmethod_array__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-array-1992",
|
||||
"indicator": "\u884C\u5217",
|
||||
"description": "Array",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -80,6 +86,7 @@
|
||||
"name": "__MSG_inputmethod_dayi__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-dayi-1988",
|
||||
"indicator": "\u5927\u6613",
|
||||
"description": "Dayi",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -89,6 +96,7 @@
|
||||
"name": "__MSG_inputmethod_zhuyin__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-und",
|
||||
"indicator": "\u9177",
|
||||
"description": "Zhuyin",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"],
|
||||
@ -279,6 +287,7 @@
|
||||
"name": "__MSG_inputmethod_mozc_us__",
|
||||
"type": "ime",
|
||||
"id": "nacl_mozc_us",
|
||||
"indicator": "\u3042",
|
||||
"description": "Japanese input method.",
|
||||
"language": "ja",
|
||||
"layouts": ["us"],
|
||||
@ -289,6 +298,7 @@
|
||||
"name": "__MSG_inputmethod_mozc_jp__",
|
||||
"type": "ime",
|
||||
"id": "nacl_mozc_jp",
|
||||
"indicator": "\u3042",
|
||||
"description": "Japanese input method.",
|
||||
"language": "ja",
|
||||
"layouts": ["jp"],
|
||||
|
@ -66,6 +66,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:eng",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -76,6 +77,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:nld",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["nl"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -86,6 +88,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:por",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["pt-BR"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -96,6 +99,7 @@
|
||||
"name": "__MSG_keyboard_us_extended__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:altgr-intl:eng",
|
||||
"indicator": "EXTD",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(altgr-intl)"],
|
||||
@ -106,6 +110,7 @@
|
||||
"name": "__MSG_keyboard_us_dvorak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:dvorak:eng",
|
||||
"indicator": "DV",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(dvorak)"],
|
||||
@ -116,6 +121,7 @@
|
||||
"name": "__MSG_keyboard_us_colemak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:colemak:eng",
|
||||
"indicator": "CO",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(colemak)"],
|
||||
@ -196,6 +202,7 @@
|
||||
"name": "__MSG_keyboard_german_neo_2__",
|
||||
"type": "ime",
|
||||
"id": "xkb:de:neo:ger",
|
||||
"indicator": "NEO",
|
||||
"description": "",
|
||||
"language": ["de", "de-DE"],
|
||||
"layouts": ["de(neo)"],
|
||||
@ -226,6 +233,7 @@
|
||||
"name": "__MSG_keyboard_japanese__",
|
||||
"type": "ime",
|
||||
"id": "xkb:jp::jpn",
|
||||
"indicator": "JA",
|
||||
"description": "",
|
||||
"language": ["ja"],
|
||||
"layouts": ["jp"],
|
||||
@ -306,6 +314,7 @@
|
||||
"name": "__MSG_keyboard_czech_qwerty__",
|
||||
"type": "ime",
|
||||
"id": "xkb:cz:qwerty:cze",
|
||||
"indicator": "CS",
|
||||
"description": "",
|
||||
"language": ["cs"],
|
||||
"layouts": ["cz(qwerty)"],
|
||||
@ -336,6 +345,7 @@
|
||||
"name": "__MSG_keyboard_catalan__",
|
||||
"type": "ime",
|
||||
"id": "xkb:es:cat:cat",
|
||||
"indicator": "CAS",
|
||||
"description": "",
|
||||
"language": ["ca"],
|
||||
"layouts": ["es(cat)"],
|
||||
@ -376,6 +386,7 @@
|
||||
"name": "__MSG_keyboard_latin_american__",
|
||||
"type": "ime",
|
||||
"id": "xkb:latam::spa",
|
||||
"indicator": "LA",
|
||||
"description": "",
|
||||
"language": ["es", "es-419"],
|
||||
"layouts": ["latam"],
|
||||
@ -426,6 +437,7 @@
|
||||
"name": "__MSG_keyboard_uk_dvorak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:gb:dvorak:eng",
|
||||
"indicator": "DV",
|
||||
"description": "",
|
||||
"language": ["en", "en-GB"],
|
||||
"layouts": ["gb(dvorak)"],
|
||||
|
@ -18,6 +18,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_2_Set__",
|
||||
"type": "ime",
|
||||
"id": "hangul_2set",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
@ -26,6 +27,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_3_Set_390__",
|
||||
"type": "ime",
|
||||
"id": "hangul_3set390",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
@ -34,6 +36,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_3_Set_Final__",
|
||||
"type": "ime",
|
||||
"id": "hangul_3setfinal",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
@ -42,6 +45,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_3_Set_No_Shift__",
|
||||
"type": "ime",
|
||||
"id": "hangul_3setnoshift",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
@ -50,6 +54,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_Romaja__",
|
||||
"type": "ime",
|
||||
"id": "hangul_romaja",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
@ -58,6 +63,7 @@
|
||||
"name": "__MSG_inputmethod_Hangul_Ahnmatae__",
|
||||
"type": "ime",
|
||||
"id": "hangul_ahnmatae",
|
||||
"indicator": "\uD55C",
|
||||
"description": "",
|
||||
"language": "ko",
|
||||
"layouts": ["us"],
|
||||
|
@ -18,6 +18,7 @@
|
||||
"name": "__MSG_inputmethod_mozc_us__",
|
||||
"type": "ime",
|
||||
"id": "nacl_mozc_us",
|
||||
"indicator": "\u3042",
|
||||
"description": "Japanese input method.",
|
||||
"language": "ja",
|
||||
"layouts": ["us"]
|
||||
@ -25,6 +26,7 @@
|
||||
"name": "__MSG_inputmethod_mozc_jp__",
|
||||
"type": "ime",
|
||||
"id": "nacl_mozc_jp",
|
||||
"indicator": "\u3042",
|
||||
"description": "Japanese input method.",
|
||||
"language": "ja",
|
||||
"layouts": ["jp"]
|
||||
|
@ -17,6 +17,7 @@
|
||||
"name": "__MSG_inputmethod_pinyin__",
|
||||
"type": "ime",
|
||||
"id": "zh-t-i0-pinyin",
|
||||
"indicator": "\u62FC",
|
||||
"description": "Pinyin",
|
||||
"language": ["zh-CN", "zh"],
|
||||
"layouts": ["us"]
|
||||
|
@ -56,6 +56,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:eng",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -65,6 +66,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:nld",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["nl"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -74,6 +76,7 @@
|
||||
"name": "__MSG_keyboard_us_international__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:intl:por",
|
||||
"indicator": "INTL",
|
||||
"description": "",
|
||||
"language": ["pt-BR"],
|
||||
"layouts": ["us(intl)"],
|
||||
@ -83,6 +86,7 @@
|
||||
"name": "__MSG_keyboard_us_extended__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:altgr-intl:eng",
|
||||
"indicator": "EXTD",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(altgr-intl)"],
|
||||
@ -92,6 +96,7 @@
|
||||
"name": "__MSG_keyboard_us_dvorak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:dvorak:eng",
|
||||
"indicator": "DV",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(dvorak)"],
|
||||
@ -101,6 +106,7 @@
|
||||
"name": "__MSG_keyboard_us_colemak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:us:colemak:eng",
|
||||
"indicator": "CO",
|
||||
"description": "",
|
||||
"language": ["en", "en-US"],
|
||||
"layouts": ["us(colemak)"],
|
||||
@ -173,6 +179,7 @@
|
||||
"name": "__MSG_keyboard_german_neo_2__",
|
||||
"type": "ime",
|
||||
"id": "xkb:de:neo:ger",
|
||||
"indicator": "NEO",
|
||||
"description": "",
|
||||
"language": ["de", "de-DE"],
|
||||
"layouts": ["de(neo)"],
|
||||
@ -200,6 +207,7 @@
|
||||
"name": "__MSG_keyboard_japanese__",
|
||||
"type": "ime",
|
||||
"id": "xkb:jp::jpn",
|
||||
"indicator": "JA",
|
||||
"description": "",
|
||||
"language": ["ja"],
|
||||
"layouts": ["jp"],
|
||||
@ -272,6 +280,7 @@
|
||||
"name": "__MSG_keyboard_czech_qwerty__",
|
||||
"type": "ime",
|
||||
"id": "xkb:cz:qwerty:cze",
|
||||
"indicator": "CS",
|
||||
"description": "",
|
||||
"language": ["cs"],
|
||||
"layouts": ["cz(qwerty)"],
|
||||
@ -299,6 +308,7 @@
|
||||
"name": "__MSG_keyboard_catalan__",
|
||||
"type": "ime",
|
||||
"id": "xkb:es:cat:cat",
|
||||
"indicator": "CAS",
|
||||
"description": "",
|
||||
"language": ["ca"],
|
||||
"layouts": ["es(cat)"],
|
||||
@ -335,6 +345,7 @@
|
||||
"name": "__MSG_keyboard_latin_american__",
|
||||
"type": "ime",
|
||||
"id": "xkb:latam::spa",
|
||||
"indicator": "LA",
|
||||
"description": "",
|
||||
"language": ["es", "es-419"],
|
||||
"layouts": ["latam"],
|
||||
@ -380,6 +391,7 @@
|
||||
"name": "__MSG_keyboard_uk_dvorak__",
|
||||
"type": "ime",
|
||||
"id": "xkb:gb:dvorak:eng",
|
||||
"indicator": "DV",
|
||||
"description": "",
|
||||
"language": ["en", "en-GB"],
|
||||
"layouts": ["gb(dvorak)"],
|
||||
|
@ -17,6 +17,7 @@
|
||||
"name": "__MSG_inputmethod_zhuyin__",
|
||||
"type": "ime",
|
||||
"id": "zh-hant-t-i0-und",
|
||||
"indicator": "\u9177",
|
||||
"description": "Zhuyin",
|
||||
"language": ["zh-TW", "zh"],
|
||||
"layouts": ["us"]
|
||||
|
@ -154,7 +154,7 @@ input_method::InputMethodDescriptors
|
||||
input_method::InputMethodDescriptor(
|
||||
input_method_id,
|
||||
ime.display_name,
|
||||
std::string(), // TODO(uekawa): Set short name.
|
||||
ime.indicator,
|
||||
layouts,
|
||||
ime.language_codes,
|
||||
// Enables extension based xkb keyboards on login screen.
|
||||
|
@ -24,6 +24,7 @@ struct CHROMEOS_EXPORT ComponentExtensionEngine {
|
||||
~ComponentExtensionEngine();
|
||||
std::string engine_id; // The engine id.
|
||||
std::string display_name; // The display name.
|
||||
std::string indicator; // The indicator text.
|
||||
std::vector<std::string> language_codes; // The engine's language(ex. "en").
|
||||
std::string description; // The engine description.
|
||||
std::vector<std::string> layouts; // The list of keyboard layout of engine.
|
||||
|
@ -116,8 +116,10 @@ bool IsMemberOfExtension(const std::string& input_method_id,
|
||||
}
|
||||
|
||||
bool IsKeyboardLayoutExtension(const std::string& input_method_id) {
|
||||
std::string prefix = kComponentExtensionIMEPrefix;
|
||||
return StartsWithASCII(input_method_id, prefix + kXkbExtensionId, true);
|
||||
if (IsComponentExtensionIME(input_method_id))
|
||||
return StartsWithASCII(GetComponentIDByInputMethodID(input_method_id),
|
||||
"xkb:", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "chromeos/ime/extension_ime_util.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace chromeos {
|
||||
@ -38,6 +40,18 @@ std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const {
|
||||
return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0];
|
||||
}
|
||||
|
||||
std::string InputMethodDescriptor::GetIndicator() const {
|
||||
// If indicator is empty, use the first two character in its preferred
|
||||
// keyboard layout or language code.
|
||||
if (indicator_.empty()) {
|
||||
if (extension_ime_util::IsKeyboardLayoutExtension(id_))
|
||||
return StringToUpperASCII(GetPreferredKeyboardLayout().substr(0, 2));
|
||||
DCHECK(language_codes_.size() > 0);
|
||||
return StringToUpperASCII(language_codes_[0].substr(0, 2));
|
||||
}
|
||||
return indicator_;
|
||||
}
|
||||
|
||||
InputMethodDescriptor::InputMethodDescriptor() {
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,9 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
|
||||
// Returns preferred keyboard layout.
|
||||
std::string GetPreferredKeyboardLayout() const;
|
||||
|
||||
// Returns the indicator text of this input method.
|
||||
std::string GetIndicator() const;
|
||||
|
||||
private:
|
||||
// An ID that identifies an input method engine (e.g., "t:latn-post",
|
||||
// "pinyin", "hangul").
|
||||
|
@ -56,6 +56,7 @@ const char kImeOptionsPage[] = "options_page";
|
||||
const char kImport[] = "import";
|
||||
const char kIncognito[] = "incognito";
|
||||
const char kIncludeGlobs[] = "include_globs";
|
||||
const char kIndicator[] = "indicator";
|
||||
const char kInputComponents[] = "input_components";
|
||||
const char kInputView[] = "input_view";
|
||||
const char kIsolation[] = "app.isolation";
|
||||
|
@ -59,6 +59,7 @@ extern const char kImeOptionsPage[];
|
||||
extern const char kImport[];
|
||||
extern const char kIncognito[];
|
||||
extern const char kIncludeGlobs[];
|
||||
extern const char kIndicator[];
|
||||
extern const char kInputComponents[];
|
||||
extern const char kInputView[];
|
||||
extern const char kIntentDisposition[];
|
||||
|
Reference in New Issue
Block a user