summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshuchen <shuchen@chromium.org>2014-09-29 20:50:03 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-30 03:50:41 +0000
commitbc91aaa2ed163990f30a36b5999e722ed548977c (patch)
tree66928084a02eeae985f3f6cbb9168648a0a33e9e
parentaebcdf88e420f281c950d741106e25dcdf0625e3 (diff)
downloadchromium_src-bc91aaa2ed163990f30a36b5999e722ed548977c.zip
chromium_src-bc91aaa2ed163990f30a36b5999e722ed548977c.tar.gz
chromium_src-bc91aaa2ed163990f30a36b5999e722ed548977c.tar.bz2
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}
-rw-r--r--chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc2
-rw-r--r--chrome/browser/chromeos/input_method/input_method_util.cc139
-rw-r--r--chrome/browser/chromeos/input_method/input_method_util.h1
-rw-r--r--chrome/browser/chromeos/input_method/input_method_util_unittest.cc5
-rw-r--r--chrome/browser/resources/chromeos/braille_ime/manifest.json1
-rw-r--r--chrome/browser/resources/chromeos/input_method/cangjie_manifest.json1
-rw-r--r--chrome/browser/resources/chromeos/input_method/google_input_tools_manifest.json10
-rw-r--r--chrome/browser/resources/chromeos/input_method/google_xkb_manifest.json12
-rw-r--r--chrome/browser/resources/chromeos/input_method/hangul_manifest.json6
-rw-r--r--chrome/browser/resources/chromeos/input_method/mozc_manifest.json2
-rw-r--r--chrome/browser/resources/chromeos/input_method/pinyin_manifest.json1
-rw-r--r--chrome/browser/resources/chromeos/input_method/xkb_manifest.json12
-rw-r--r--chrome/browser/resources/chromeos/input_method/zhuyin_manifest.json1
-rw-r--r--chromeos/ime/component_extension_ime_manager.cc2
-rw-r--r--chromeos/ime/component_extension_ime_manager.h1
-rw-r--r--chromeos/ime/extension_ime_util.cc6
-rw-r--r--chromeos/ime/input_method_descriptor.cc14
-rw-r--r--chromeos/ime/input_method_descriptor.h3
-rw-r--r--extensions/common/manifest_constants.cc1
-rw-r--r--extensions/common/manifest_constants.h1
20 files changed, 79 insertions, 142 deletions
diff --git a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
index 0e16247..1aa41a6 100644
--- a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
@@ -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) {
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc
index 69db27c..df5d978 100644
--- a/chrome/browser/chromeos/input_method/input_method_util.cc
+++ b/chrome/browser/chromeos/input_method/input_method_util.cc
@@ -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(
diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h
index 36ba5ab..7d31abf4bb 100644
--- a/chrome/browser/chromeos/input_method/input_method_util.h
+++ b/chrome/browser/chromeos/input_method/input_method_util.h
@@ -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_;
diff --git a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc
index ac3201f..0f117a8 100644
--- a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc
+++ b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc
@@ -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));
}
diff --git a/chrome/browser/resources/chromeos/braille_ime/manifest.json b/chrome/browser/resources/chromeos/braille_ime/manifest.json
index 8c4c327..3f0f9e1 100644
--- a/chrome/browser/resources/chromeos/braille_ime/manifest.json
+++ b/chrome/browser/resources/chromeos/braille_ime/manifest.json
@@ -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"
}
diff --git a/chrome/browser/resources/chromeos/input_method/cangjie_manifest.json b/chrome/browser/resources/chromeos/input_method/cangjie_manifest.json
index 4d2665e..89b5476 100644
--- a/chrome/browser/resources/chromeos/input_method/cangjie_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/cangjie_manifest.json
@@ -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"]
diff --git a/chrome/browser/resources/chromeos/input_method/google_input_tools_manifest.json b/chrome/browser/resources/chromeos/input_method/google_input_tools_manifest.json
index e46dc51..1c033b4 100644
--- a/chrome/browser/resources/chromeos/input_method/google_input_tools_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/google_input_tools_manifest.json
@@ -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"],
diff --git a/chrome/browser/resources/chromeos/input_method/google_xkb_manifest.json b/chrome/browser/resources/chromeos/input_method/google_xkb_manifest.json
index 9a2b5d0..517b728 100644
--- a/chrome/browser/resources/chromeos/input_method/google_xkb_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/google_xkb_manifest.json
@@ -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)"],
diff --git a/chrome/browser/resources/chromeos/input_method/hangul_manifest.json b/chrome/browser/resources/chromeos/input_method/hangul_manifest.json
index e66f7bd..b76e76c 100644
--- a/chrome/browser/resources/chromeos/input_method/hangul_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/hangul_manifest.json
@@ -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"],
diff --git a/chrome/browser/resources/chromeos/input_method/mozc_manifest.json b/chrome/browser/resources/chromeos/input_method/mozc_manifest.json
index 3539f10..6bce93f 100644
--- a/chrome/browser/resources/chromeos/input_method/mozc_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/mozc_manifest.json
@@ -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"]
diff --git a/chrome/browser/resources/chromeos/input_method/pinyin_manifest.json b/chrome/browser/resources/chromeos/input_method/pinyin_manifest.json
index 82adbba..0030aef 100644
--- a/chrome/browser/resources/chromeos/input_method/pinyin_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/pinyin_manifest.json
@@ -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"]
diff --git a/chrome/browser/resources/chromeos/input_method/xkb_manifest.json b/chrome/browser/resources/chromeos/input_method/xkb_manifest.json
index f9a9206..71187ba 100644
--- a/chrome/browser/resources/chromeos/input_method/xkb_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/xkb_manifest.json
@@ -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)"],
diff --git a/chrome/browser/resources/chromeos/input_method/zhuyin_manifest.json b/chrome/browser/resources/chromeos/input_method/zhuyin_manifest.json
index 0c3a5e5..c574bb2 100644
--- a/chrome/browser/resources/chromeos/input_method/zhuyin_manifest.json
+++ b/chrome/browser/resources/chromeos/input_method/zhuyin_manifest.json
@@ -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"]
diff --git a/chromeos/ime/component_extension_ime_manager.cc b/chromeos/ime/component_extension_ime_manager.cc
index feb0347..5454a94 100644
--- a/chromeos/ime/component_extension_ime_manager.cc
+++ b/chromeos/ime/component_extension_ime_manager.cc
@@ -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.
diff --git a/chromeos/ime/component_extension_ime_manager.h b/chromeos/ime/component_extension_ime_manager.h
index 98e0bbc..0fcaded 100644
--- a/chromeos/ime/component_extension_ime_manager.h
+++ b/chromeos/ime/component_extension_ime_manager.h
@@ -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.
diff --git a/chromeos/ime/extension_ime_util.cc b/chromeos/ime/extension_ime_util.cc
index ee37cae..bc0d078 100644
--- a/chromeos/ime/extension_ime_util.cc
+++ b/chromeos/ime/extension_ime_util.cc
@@ -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) {
diff --git a/chromeos/ime/input_method_descriptor.cc b/chromeos/ime/input_method_descriptor.cc
index 49b0360..6b9f42b 100644
--- a/chromeos/ime/input_method_descriptor.cc
+++ b/chromeos/ime/input_method_descriptor.cc
@@ -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() {
}
diff --git a/chromeos/ime/input_method_descriptor.h b/chromeos/ime/input_method_descriptor.h
index ab7cfb4..e11b0eb 100644
--- a/chromeos/ime/input_method_descriptor.h
+++ b/chromeos/ime/input_method_descriptor.h
@@ -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").
diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc
index acb9a9e..7ae2c48 100644
--- a/extensions/common/manifest_constants.cc
+++ b/extensions/common/manifest_constants.cc
@@ -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";
diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h
index 507beb5..497d008 100644
--- a/extensions/common/manifest_constants.h
+++ b/extensions/common/manifest_constants.h
@@ -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[];