Commit 418c634e authored by shuchen's avatar shuchen Committed by Commit bot

Only strip 'keyboard' from the input method name for OOBE screen.

BUG=361855
TEST=Verified on linux_chromeos.

Review URL: https://codereview.chromium.org/606063002

Cr-Commit-Position: refs/heads/master@{#297378}
parent bdb453be
......@@ -301,8 +301,8 @@ base::string16 InputMethodUtil::GetInputMethodMediumName(
return GetInputMethodShortName(input_method);
}
base::string16 InputMethodUtil::GetInputMethodLongName(
const InputMethodDescriptor& input_method) const {
base::string16 InputMethodUtil::GetInputMethodLongNameInternal(
const InputMethodDescriptor& input_method, bool short_name) const {
if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) {
// If the descriptor has a name, use it.
return base::UTF8ToUTF16(input_method.name());
......@@ -310,25 +310,18 @@ base::string16 InputMethodUtil::GetInputMethodLongName(
// We don't show language here. Name of keyboard layout or input method
// usually imply (or explicitly include) its language.
// Special case for German, French and Dutch: these languages have multiple
// keyboard layouts and share the same layout of keyboard (Belgian). We need
// to show explicitly the language for the layout. For Arabic, Amharic, and
// Indic languages: they share "Standard Input Method".
const base::string16 standard_input_method_text =
delegate_->GetLocalizedString(
IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD);
// to show explicitly the language for the layout.
DCHECK(!input_method.language_codes().empty());
const std::string language_code = input_method.language_codes().at(0);
base::string16 text = TranslateString(input_method.id());
if (text == standard_input_method_text ||
language_code == "de" ||
language_code == "fr" ||
language_code == "nl") {
base::string16 text = (short_name || input_method.name().empty())
? TranslateString(input_method.id())
: base::UTF8ToUTF16(input_method.name());
if (language_code == "de" || language_code == "fr" || language_code == "nl") {
const base::string16 language_name = delegate_->GetDisplayLanguageName(
language_code);
text = language_name + base::UTF8ToUTF16(" - ") + text;
}
......@@ -336,6 +329,17 @@ base::string16 InputMethodUtil::GetInputMethodLongName(
return text;
}
base::string16 InputMethodUtil::GetInputMethodLongNameStripped(
const InputMethodDescriptor& input_method) const {
return GetInputMethodLongNameInternal(input_method, true /* short_name */);
}
base::string16 InputMethodUtil::GetInputMethodLongName(
const InputMethodDescriptor& input_method) const {
return GetInputMethodLongNameInternal(input_method, false /* short_name */);
}
const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId(
const std::string& input_method_id) const {
InputMethodIdToDescriptorMap::const_iterator iter =
......
......@@ -57,6 +57,8 @@ class InputMethodUtil {
const InputMethodDescriptor& input_method) const;
base::string16 GetInputMethodMediumName(
const InputMethodDescriptor& input_method) const;
base::string16 GetInputMethodLongNameStripped(
const InputMethodDescriptor& input_method) const;
base::string16 GetInputMethodLongName(
const InputMethodDescriptor& input_method) const;
......@@ -177,6 +179,12 @@ class InputMethodUtil {
bool TranslateStringInternal(const std::string& english_string,
base::string16 *out_string) const;
// Get long name of the given input method. |short_name| is to specify whether
// to get the long name for OOBE screen, because OOBE screen displays shorter
// name (e.g. 'US' instead of 'US keyboard').
base::string16 GetInputMethodLongNameInternal(
const InputMethodDescriptor& input_method, bool short_name) const;
// Map from language code to associated input method IDs, etc.
typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap;
......
......@@ -47,7 +47,8 @@ scoped_ptr<base::DictionaryValue> CreateInputMethodsEntry(
const std::string& ime_id = method.id();
scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue);
input_method->SetString("value", ime_id);
input_method->SetString("title", util->GetInputMethodLongName(method));
input_method->SetString(
"title", util->GetInputMethodLongNameStripped(method));
input_method->SetBoolean("selected", ime_id == selected);
return input_method.Pass();
}
......
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