Commit bc91aaa2 authored by shuchen's avatar shuchen Committed by Commit bot

Move all white-listed input method indicator text from InputMethodUtil to...

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}
parent aebcdf88
...@@ -345,6 +345,8 @@ bool ComponentExtensionIMEManagerImpl::ReadEngineComponent( ...@@ -345,6 +345,8 @@ bool ComponentExtensionIMEManagerImpl::ReadEngineComponent(
return false; return false;
if (!dict.GetString(extensions::manifest_keys::kName, &out->display_name)) if (!dict.GetString(extensions::manifest_keys::kName, &out->display_name))
return false; return false;
if (!dict.GetString(extensions::manifest_keys::kIndicator, &out->indicator))
out->indicator = "";
// Localizes the input method name. // Localizes the input method name.
if (out->display_name.find("__MSG_") == 0) { if (out->display_name.find("__MSG_") == 0) {
......
...@@ -27,41 +27,6 @@ ...@@ -27,41 +27,6 @@
namespace { 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 // A mapping from an input method id to a resource id for a
// medium length language indicator. // medium length language indicator.
// For those languages that want to display a slightly longer text in the // For those languages that want to display a slightly longer text in the
...@@ -106,61 +71,6 @@ const struct { ...@@ -106,61 +71,6 @@ const struct {
{ "vi", "us", "vkd_vi_tcvn" }, { "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. // The extension ID map for migration.
const char* const kExtensionIdMigrationMap[][2] = { const char* const kExtensionIdMigrationMap[][2] = {
// Official Japanese IME extension ID. // Official Japanese IME extension ID.
...@@ -299,11 +209,6 @@ InputMethodUtil::InputMethodUtil(InputMethodDelegate* delegate) ...@@ -299,11 +209,6 @@ InputMethodUtil::InputMethodUtil(InputMethodDelegate* delegate)
DCHECK(result) << "Duplicated string is found: " DCHECK(result) << "Duplicated string is found: "
<< map_entry.english_string_from_ibus; << 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() { InputMethodUtil::~InputMethodUtil() {
...@@ -375,47 +280,9 @@ std::string InputMethodUtil::GetInputMethodDisplayNameFromId( ...@@ -375,47 +280,9 @@ std::string InputMethodUtil::GetInputMethodDisplayNameFromId(
base::string16 InputMethodUtil::GetInputMethodShortName( base::string16 InputMethodUtil::GetInputMethodShortName(
const InputMethodDescriptor& input_method) const { const InputMethodDescriptor& input_method) const {
// For the status area, we use two-letter, upper-case language code like // TODO(shuchen): remove this method, as the client can directly use
// "US" and "JP". // input_method.GetIndicator().
return base::UTF8ToUTF16(input_method.GetIndicator());
// 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;
} }
base::string16 InputMethodUtil::GetInputMethodMediumName( base::string16 InputMethodUtil::GetInputMethodMediumName(
......
...@@ -182,7 +182,6 @@ class InputMethodUtil { ...@@ -182,7 +182,6 @@ class InputMethodUtil {
LanguageCodeToIdsMap language_code_to_ids_; LanguageCodeToIdsMap language_code_to_ids_;
InputMethodIdToDescriptorMap id_to_descriptor_; InputMethodIdToDescriptorMap id_to_descriptor_;
std::map<std::string, std::string> xkb_layout_to_indicator_;
typedef base::hash_map<std::string, int> HashType; typedef base::hash_map<std::string, int> HashType;
HashType english_to_resource_id_; HashType english_to_resource_id_;
......
...@@ -159,12 +159,13 @@ TEST_F(InputMethodUtilTest, GetInputMethodShortNameTest) { ...@@ -159,12 +159,13 @@ TEST_F(InputMethodUtilTest, GetInputMethodShortNameTest) {
} }
{ {
InputMethodDescriptor desc = 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"), EXPECT_EQ(base::UTF8ToUTF16("\xe6\x8b\xbc"),
util_.GetInputMethodShortName(desc)); 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"), EXPECT_EQ(base::UTF8ToUTF16("\xE6\xB3\xA8"),
util_.GetInputMethodShortName(desc)); util_.GetInputMethodShortName(desc));
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"name": "Braille Keyboard", "name": "Braille Keyboard",
"type": "ime", "type": "ime",
"id": "braille", "id": "braille",
"indicator": "\u2803\u2817\u2807", // Unicode of 'brl' in English (and many other) braille codes.
"language": ["None"], "language": ["None"],
"description": "Braille hardware keyboard" "description": "Braille hardware keyboard"
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"name": "__MSG_inputmethod_cangjie__", "name": "__MSG_inputmethod_cangjie__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-cangjie-1987", "id": "zh-hant-t-i0-cangjie-1987",
"indicator": "\u5009",
"description": "Cangjie", "description": "Cangjie",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"] "layouts": ["us"]
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"name": "__MSG_inputmethod_pinyin__", "name": "__MSG_inputmethod_pinyin__",
"type": "ime", "type": "ime",
"id": "zh-t-i0-pinyin", "id": "zh-t-i0-pinyin",
"indicator": "\u62FC",
"description": "Pinyin", "description": "Pinyin",
"language": ["zh-CN", "zh"], "language": ["zh-CN", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
"name": "__MSG_inputmethod_traditional_pinyin__", "name": "__MSG_inputmethod_traditional_pinyin__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-pinyin", "id": "zh-hant-t-i0-pinyin",
"indicator": "\u62FC",
"description": "Pinyin for Tranditional Chinese", "description": "Pinyin for Tranditional Chinese",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -44,6 +46,7 @@ ...@@ -44,6 +46,7 @@
"name": "__MSG_inputmethod_cangjie__", "name": "__MSG_inputmethod_cangjie__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-cangjie-1987", "id": "zh-hant-t-i0-cangjie-1987",
"indicator": "\u5009",
"description": "Cangjie", "description": "Cangjie",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -53,6 +56,7 @@ ...@@ -53,6 +56,7 @@
"name": "__MSG_inputmethod_quick__", "name": "__MSG_inputmethod_quick__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-cangjie-1987-x-m0-simplified", "id": "zh-hant-t-i0-cangjie-1987-x-m0-simplified",
"indicator": "\u901F",
"description": "Quick", "description": "Quick",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -62,6 +66,7 @@ ...@@ -62,6 +66,7 @@
"name": "__MSG_inputmethod_wubi__", "name": "__MSG_inputmethod_wubi__",
"type": "ime", "type": "ime",
"id": "zh-t-i0-wubi-1986", "id": "zh-t-i0-wubi-1986",
"indicator": "\u4E94",
"description": "Wubi", "description": "Wubi",
"language": ["zh-CN", "zh"], "language": ["zh-CN", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -71,6 +76,7 @@ ...@@ -71,6 +76,7 @@
"name": "__MSG_inputmethod_array__", "name": "__MSG_inputmethod_array__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-array-1992", "id": "zh-hant-t-i0-array-1992",
"indicator": "\u884C\u5217",
"description": "Array", "description": "Array",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -80,6 +86,7 @@ ...@@ -80,6 +86,7 @@
"name": "__MSG_inputmethod_dayi__", "name": "__MSG_inputmethod_dayi__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-dayi-1988", "id": "zh-hant-t-i0-dayi-1988",
"indicator": "\u5927\u6613",
"description": "Dayi", "description": "Dayi",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -89,6 +96,7 @@ ...@@ -89,6 +96,7 @@
"name": "__MSG_inputmethod_zhuyin__", "name": "__MSG_inputmethod_zhuyin__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-und", "id": "zh-hant-t-i0-und",
"indicator": "\u9177",
"description": "Zhuyin", "description": "Zhuyin",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"], "layouts": ["us"],
...@@ -279,6 +287,7 @@ ...@@ -279,6 +287,7 @@
"name": "__MSG_inputmethod_mozc_us__", "name": "__MSG_inputmethod_mozc_us__",
"type": "ime", "type": "ime",
"id": "nacl_mozc_us", "id": "nacl_mozc_us",
"indicator": "\u3042",
"description": "Japanese input method.", "description": "Japanese input method.",
"language": "ja", "language": "ja",
"layouts": ["us"], "layouts": ["us"],
...@@ -289,6 +298,7 @@ ...@@ -289,6 +298,7 @@
"name": "__MSG_inputmethod_mozc_jp__", "name": "__MSG_inputmethod_mozc_jp__",
"type": "ime", "type": "ime",
"id": "nacl_mozc_jp", "id": "nacl_mozc_jp",
"indicator": "\u3042",
"description": "Japanese input method.", "description": "Japanese input method.",
"language": "ja", "language": "ja",
"layouts": ["jp"], "layouts": ["jp"],
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:eng", "id": "xkb:us:intl:eng",
"indicator": "INTL",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -76,6 +77,7 @@ ...@@ -76,6 +77,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:nld", "id": "xkb:us:intl:nld",
"indicator": "INTL",
"description": "", "description": "",
"language": ["nl"], "language": ["nl"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -86,6 +88,7 @@ ...@@ -86,6 +88,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:por", "id": "xkb:us:intl:por",
"indicator": "INTL",
"description": "", "description": "",
"language": ["pt-BR"], "language": ["pt-BR"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -96,6 +99,7 @@ ...@@ -96,6 +99,7 @@
"name": "__MSG_keyboard_us_extended__", "name": "__MSG_keyboard_us_extended__",
"type": "ime", "type": "ime",
"id": "xkb:us:altgr-intl:eng", "id": "xkb:us:altgr-intl:eng",
"indicator": "EXTD",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(altgr-intl)"], "layouts": ["us(altgr-intl)"],
...@@ -106,6 +110,7 @@ ...@@ -106,6 +110,7 @@
"name": "__MSG_keyboard_us_dvorak__", "name": "__MSG_keyboard_us_dvorak__",
"type": "ime", "type": "ime",
"id": "xkb:us:dvorak:eng", "id": "xkb:us:dvorak:eng",
"indicator": "DV",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(dvorak)"], "layouts": ["us(dvorak)"],
...@@ -116,6 +121,7 @@ ...@@ -116,6 +121,7 @@
"name": "__MSG_keyboard_us_colemak__", "name": "__MSG_keyboard_us_colemak__",
"type": "ime", "type": "ime",
"id": "xkb:us:colemak:eng", "id": "xkb:us:colemak:eng",
"indicator": "CO",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(colemak)"], "layouts": ["us(colemak)"],
...@@ -196,6 +202,7 @@ ...@@ -196,6 +202,7 @@
"name": "__MSG_keyboard_german_neo_2__", "name": "__MSG_keyboard_german_neo_2__",
"type": "ime", "type": "ime",
"id": "xkb:de:neo:ger", "id": "xkb:de:neo:ger",
"indicator": "NEO",
"description": "", "description": "",
"language": ["de", "de-DE"], "language": ["de", "de-DE"],
"layouts": ["de(neo)"], "layouts": ["de(neo)"],
...@@ -226,6 +233,7 @@ ...@@ -226,6 +233,7 @@
"name": "__MSG_keyboard_japanese__", "name": "__MSG_keyboard_japanese__",
"type": "ime", "type": "ime",
"id": "xkb:jp::jpn", "id": "xkb:jp::jpn",
"indicator": "JA",
"description": "", "description": "",
"language": ["ja"], "language": ["ja"],
"layouts": ["jp"], "layouts": ["jp"],
...@@ -306,6 +314,7 @@ ...@@ -306,6 +314,7 @@
"name": "__MSG_keyboard_czech_qwerty__", "name": "__MSG_keyboard_czech_qwerty__",
"type": "ime", "type": "ime",
"id": "xkb:cz:qwerty:cze", "id": "xkb:cz:qwerty:cze",
"indicator": "CS",
"description": "", "description": "",
"language": ["cs"], "language": ["cs"],
"layouts": ["cz(qwerty)"], "layouts": ["cz(qwerty)"],
...@@ -336,6 +345,7 @@ ...@@ -336,6 +345,7 @@
"name": "__MSG_keyboard_catalan__", "name": "__MSG_keyboard_catalan__",
"type": "ime", "type": "ime",
"id": "xkb:es:cat:cat", "id": "xkb:es:cat:cat",
"indicator": "CAS",
"description": "", "description": "",
"language": ["ca"], "language": ["ca"],
"layouts": ["es(cat)"], "layouts": ["es(cat)"],
...@@ -376,6 +386,7 @@ ...@@ -376,6 +386,7 @@
"name": "__MSG_keyboard_latin_american__", "name": "__MSG_keyboard_latin_american__",
"type": "ime", "type": "ime",
"id": "xkb:latam::spa", "id": "xkb:latam::spa",
"indicator": "LA",
"description": "", "description": "",
"language": ["es", "es-419"], "language": ["es", "es-419"],
"layouts": ["latam"], "layouts": ["latam"],
...@@ -426,6 +437,7 @@ ...@@ -426,6 +437,7 @@
"name": "__MSG_keyboard_uk_dvorak__", "name": "__MSG_keyboard_uk_dvorak__",
"type": "ime", "type": "ime",
"id": "xkb:gb:dvorak:eng", "id": "xkb:gb:dvorak:eng",
"indicator": "DV",
"description": "", "description": "",
"language": ["en", "en-GB"], "language": ["en", "en-GB"],
"layouts": ["gb(dvorak)"], "layouts": ["gb(dvorak)"],
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"name": "__MSG_inputmethod_Hangul_2_Set__", "name": "__MSG_inputmethod_Hangul_2_Set__",
"type": "ime", "type": "ime",
"id": "hangul_2set", "id": "hangul_2set",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
"name": "__MSG_inputmethod_Hangul_3_Set_390__", "name": "__MSG_inputmethod_Hangul_3_Set_390__",
"type": "ime", "type": "ime",
"id": "hangul_3set390", "id": "hangul_3set390",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
"name": "__MSG_inputmethod_Hangul_3_Set_Final__", "name": "__MSG_inputmethod_Hangul_3_Set_Final__",
"type": "ime", "type": "ime",
"id": "hangul_3setfinal", "id": "hangul_3setfinal",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
...@@ -42,6 +45,7 @@ ...@@ -42,6 +45,7 @@
"name": "__MSG_inputmethod_Hangul_3_Set_No_Shift__", "name": "__MSG_inputmethod_Hangul_3_Set_No_Shift__",
"type": "ime", "type": "ime",
"id": "hangul_3setnoshift", "id": "hangul_3setnoshift",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
...@@ -50,6 +54,7 @@ ...@@ -50,6 +54,7 @@
"name": "__MSG_inputmethod_Hangul_Romaja__", "name": "__MSG_inputmethod_Hangul_Romaja__",
"type": "ime", "type": "ime",
"id": "hangul_romaja", "id": "hangul_romaja",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
...@@ -58,6 +63,7 @@ ...@@ -58,6 +63,7 @@
"name": "__MSG_inputmethod_Hangul_Ahnmatae__", "name": "__MSG_inputmethod_Hangul_Ahnmatae__",
"type": "ime", "type": "ime",
"id": "hangul_ahnmatae", "id": "hangul_ahnmatae",
"indicator": "\uD55C",
"description": "", "description": "",
"language": "ko", "language": "ko",
"layouts": ["us"], "layouts": ["us"],
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"name": "__MSG_inputmethod_mozc_us__", "name": "__MSG_inputmethod_mozc_us__",
"type": "ime", "type": "ime",
"id": "nacl_mozc_us", "id": "nacl_mozc_us",
"indicator": "\u3042",
"description": "Japanese input method.", "description": "Japanese input method.",
"language": "ja", "language": "ja",
"layouts": ["us"] "layouts": ["us"]
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
"name": "__MSG_inputmethod_mozc_jp__", "name": "__MSG_inputmethod_mozc_jp__",
"type": "ime", "type": "ime",
"id": "nacl_mozc_jp", "id": "nacl_mozc_jp",
"indicator": "\u3042",
"description": "Japanese input method.", "description": "Japanese input method.",
"language": "ja", "language": "ja",
"layouts": ["jp"] "layouts": ["jp"]
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"name": "__MSG_inputmethod_pinyin__", "name": "__MSG_inputmethod_pinyin__",
"type": "ime", "type": "ime",
"id": "zh-t-i0-pinyin", "id": "zh-t-i0-pinyin",
"indicator": "\u62FC",
"description": "Pinyin", "description": "Pinyin",
"language": ["zh-CN", "zh"], "language": ["zh-CN", "zh"],
"layouts": ["us"] "layouts": ["us"]
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:eng", "id": "xkb:us:intl:eng",
"indicator": "INTL",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:nld", "id": "xkb:us:intl:nld",
"indicator": "INTL",
"description": "", "description": "",
"language": ["nl"], "language": ["nl"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -74,6 +76,7 @@ ...@@ -74,6 +76,7 @@
"name": "__MSG_keyboard_us_international__", "name": "__MSG_keyboard_us_international__",
"type": "ime", "type": "ime",
"id": "xkb:us:intl:por", "id": "xkb:us:intl:por",
"indicator": "INTL",
"description": "", "description": "",
"language": ["pt-BR"], "language": ["pt-BR"],
"layouts": ["us(intl)"], "layouts": ["us(intl)"],
...@@ -83,6 +86,7 @@ ...@@ -83,6 +86,7 @@
"name": "__MSG_keyboard_us_extended__", "name": "__MSG_keyboard_us_extended__",
"type": "ime", "type": "ime",
"id": "xkb:us:altgr-intl:eng", "id": "xkb:us:altgr-intl:eng",
"indicator": "EXTD",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(altgr-intl)"], "layouts": ["us(altgr-intl)"],
...@@ -92,6 +96,7 @@ ...@@ -92,6 +96,7 @@
"name": "__MSG_keyboard_us_dvorak__", "name": "__MSG_keyboard_us_dvorak__",
"type": "ime", "type": "ime",
"id": "xkb:us:dvorak:eng", "id": "xkb:us:dvorak:eng",
"indicator": "DV",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(dvorak)"], "layouts": ["us(dvorak)"],
...@@ -101,6 +106,7 @@ ...@@ -101,6 +106,7 @@
"name": "__MSG_keyboard_us_colemak__", "name": "__MSG_keyboard_us_colemak__",
"type": "ime", "type": "ime",
"id": "xkb:us:colemak:eng", "id": "xkb:us:colemak:eng",
"indicator": "CO",
"description": "", "description": "",
"language": ["en", "en-US"], "language": ["en", "en-US"],
"layouts": ["us(colemak)"], "layouts": ["us(colemak)"],
...@@ -173,6 +179,7 @@ ...@@ -173,6 +179,7 @@
"name": "__MSG_keyboard_german_neo_2__", "name": "__MSG_keyboard_german_neo_2__",
"type": "ime", "type": "ime",
"id": "xkb:de:neo:ger", "id": "xkb:de:neo:ger",
"indicator": "NEO",
"description": "", "description": "",
"language": ["de", "de-DE"], "language": ["de", "de-DE"],
"layouts": ["de(neo)"], "layouts": ["de(neo)"],
...@@ -200,6 +207,7 @@ ...@@ -200,6 +207,7 @@
"name": "__MSG_keyboard_japanese__", "name": "__MSG_keyboard_japanese__",
"type": "ime", "type": "ime",
"id": "xkb:jp::jpn", "id": "xkb:jp::jpn",
"indicator": "JA",
"description": "", "description": "",
"language": ["ja"], "language": ["ja"],
"layouts": ["jp"], "layouts": ["jp"],
...@@ -272,6 +280,7 @@ ...@@ -272,6 +280,7 @@
"name": "__MSG_keyboard_czech_qwerty__", "name": "__MSG_keyboard_czech_qwerty__",
"type": "ime", "type": "ime",
"id": "xkb:cz:qwerty:cze", "id": "xkb:cz:qwerty:cze",
"indicator": "CS",
"description": "", "description": "",
"language": ["cs"], "language": ["cs"],
"layouts": ["cz(qwerty)"], "layouts": ["cz(qwerty)"],
...@@ -299,6 +308,7 @@ ...@@ -299,6 +308,7 @@
"name": "__MSG_keyboard_catalan__", "name": "__MSG_keyboard_catalan__",
"type": "ime", "type": "ime",
"id": "xkb:es:cat:cat", "id": "xkb:es:cat:cat",
"indicator": "CAS",
"description": "", "description": "",
"language": ["ca"], "language": ["ca"],
"layouts": ["es(cat)"], "layouts": ["es(cat)"],
...@@ -335,6 +345,7 @@ ...@@ -335,6 +345,7 @@
"name": "__MSG_keyboard_latin_american__", "name": "__MSG_keyboard_latin_american__",
"type": "ime", "type": "ime",
"id": "xkb:latam::spa", "id": "xkb:latam::spa",
"indicator": "LA",
"description": "", "description": "",
"language": ["es", "es-419"], "language": ["es", "es-419"],
"layouts": ["latam"], "layouts": ["latam"],
...@@ -380,6 +391,7 @@ ...@@ -380,6 +391,7 @@
"name": "__MSG_keyboard_uk_dvorak__", "name": "__MSG_keyboard_uk_dvorak__",
"type": "ime", "type": "ime",
"id": "xkb:gb:dvorak:eng", "id": "xkb:gb:dvorak:eng",
"indicator": "DV",
"description": "", "description": "",
"language": ["en", "en-GB"], "language": ["en", "en-GB"],
"layouts": ["gb(dvorak)"], "layouts": ["gb(dvorak)"],
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"name": "__MSG_inputmethod_zhuyin__", "name": "__MSG_inputmethod_zhuyin__",
"type": "ime", "type": "ime",
"id": "zh-hant-t-i0-und", "id": "zh-hant-t-i0-und",
"indicator": "\u9177",
"description": "Zhuyin", "description": "Zhuyin",
"language": ["zh-TW", "zh"], "language": ["zh-TW", "zh"],
"layouts": ["us"] "layouts": ["us"]
......
...@@ -154,7 +154,7 @@ input_method::InputMethodDescriptors ...@@ -154,7 +154,7 @@ input_method::InputMethodDescriptors
input_method::InputMethodDescriptor( input_method::InputMethodDescriptor(
input_method_id, input_method_id,
ime.display_name, ime.display_name,
std::string(), // TODO(uekawa): Set short name. ime.indicator,
layouts, layouts,
ime.language_codes, ime.language_codes,
// Enables extension based xkb keyboards on login screen. // Enables extension based xkb keyboards on login screen.
......
...@@ -24,6 +24,7 @@ struct CHROMEOS_EXPORT ComponentExtensionEngine { ...@@ -24,6 +24,7 @@ struct CHROMEOS_EXPORT ComponentExtensionEngine {
~ComponentExtensionEngine(); ~ComponentExtensionEngine();
std::string engine_id; // The engine id. std::string engine_id; // The engine id.
std::string display_name; // The display name. 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::vector<std::string> language_codes; // The engine's language(ex. "en").
std::string description; // The engine description. std::string description; // The engine description.
std::vector<std::string> layouts; // The list of keyboard layout of engine. std::vector<std::string> layouts; // The list of keyboard layout of engine.
......
...@@ -116,8 +116,10 @@ bool IsMemberOfExtension(const std::string& input_method_id, ...@@ -116,8 +116,10 @@ bool IsMemberOfExtension(const std::string& input_method_id,
} }
bool IsKeyboardLayoutExtension(const std::string& input_method_id) { bool IsKeyboardLayoutExtension(const std::string& input_method_id) {
std::string prefix = kComponentExtensionIMEPrefix; if (IsComponentExtensionIME(input_method_id))
return StartsWithASCII(input_method_id, prefix + kXkbExtensionId, true); return StartsWithASCII(GetComponentIDByInputMethodID(input_method_id),
"xkb:", true);
return false;
} }
std::string MaybeGetLegacyXkbId(const std::string& input_method_id) { std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "chromeos/ime/extension_ime_util.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace chromeos { namespace chromeos {
...@@ -38,6 +40,18 @@ std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const { ...@@ -38,6 +40,18 @@ std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const {
return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0]; 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() { InputMethodDescriptor::InputMethodDescriptor() {
} }
......
...@@ -47,6 +47,9 @@ class CHROMEOS_EXPORT InputMethodDescriptor { ...@@ -47,6 +47,9 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
// Returns preferred keyboard layout. // Returns preferred keyboard layout.
std::string GetPreferredKeyboardLayout() const; std::string GetPreferredKeyboardLayout() const;
// Returns the indicator text of this input method.
std::string GetIndicator() const;
private: private:
// An ID that identifies an input method engine (e.g., "t:latn-post", // An ID that identifies an input method engine (e.g., "t:latn-post",
// "pinyin", "hangul"). // "pinyin", "hangul").
......
...@@ -56,6 +56,7 @@ const char kImeOptionsPage[] = "options_page"; ...@@ -56,6 +56,7 @@ const char kImeOptionsPage[] = "options_page";
const char kImport[] = "import"; const char kImport[] = "import";
const char kIncognito[] = "incognito"; const char kIncognito[] = "incognito";
const char kIncludeGlobs[] = "include_globs"; const char kIncludeGlobs[] = "include_globs";
const char kIndicator[] = "indicator";
const char kInputComponents[] = "input_components"; const char kInputComponents[] = "input_components";
const char kInputView[] = "input_view"; const char kInputView[] = "input_view";
const char kIsolation[] = "app.isolation"; const char kIsolation[] = "app.isolation";
......
...@@ -59,6 +59,7 @@ extern const char kImeOptionsPage[]; ...@@ -59,6 +59,7 @@ extern const char kImeOptionsPage[];
extern const char kImport[]; extern const char kImport[];
extern const char kIncognito[]; extern const char kIncognito[];
extern const char kIncludeGlobs[]; extern const char kIncludeGlobs[];
extern const char kIndicator[];
extern const char kInputComponents[]; extern const char kInputComponents[];
extern const char kInputView[]; extern const char kInputView[];
extern const char kIntentDisposition[]; extern const char kIntentDisposition[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment