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

Unified Diff: chrome/browser/chromeos/input_method/input_method_util.cc

Issue 608183002: Move all white-listed input method indicator text from InputMethodUtil to manifests of IME extensio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit. Created 6 years, 3 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
Index: chrome/browser/chromeos/input_method/input_method_util.cc
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc
index 69db27c379af9add29ca24f66092b06f90a51f17..5b49c6287789ec8092a73d4526382cc2fd95c0b6 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,8 @@ 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.
Peter Lundblad 2014/09/29 12:20:47 Does 'this method' refer to the one being called o
Shu Chen 2014/09/29 14:48:08 Done.
+ return base::UTF8ToUTF16(input_method.GetIndicator());
}
base::string16 InputMethodUtil::GetInputMethodMediumName(

Powered by Google App Engine
This is Rietveld 408576698