| Index: ui/base/ime/win/imm32_manager.cc
|
| diff --git a/ui/base/ime/win/imm32_manager.cc b/ui/base/ime/win/imm32_manager.cc
|
| index bd50e933942e35e6680f788286d74b7df19bdbf0..b0420fdaa65fbd429f1cf668f9aa4e38f782607e 100644
|
| --- a/ui/base/ime/win/imm32_manager.cc
|
| +++ b/ui/base/ime/win/imm32_manager.cc
|
| @@ -124,13 +124,19 @@ IMM32Manager::~IMM32Manager() {
|
| }
|
|
|
| void IMM32Manager::SetInputLanguage() {
|
| - // Retrieve the current keyboard layout from Windows and determine whether
|
| - // or not the current input context has IMEs.
|
| - // Also save its input language for language-specific operations required
|
| - // while composing a text.
|
| - HKL keyboard_layout = ::GetKeyboardLayout(0);
|
| - input_language_id_ =
|
| - static_cast<LANGID>(reinterpret_cast<uintptr_t>(keyboard_layout));
|
| + // Retrieve the current input language from the system's keyboard layout.
|
| + // Using GetKeyboardLayoutName instead of GetKeyboardLayout, because
|
| + // the language from GetKeyboardLayout is the language under where the
|
| + // keyboard layout is installed. And the language from GetKeyboardLayoutName
|
| + // indicates the language of the keyboard layout itself.
|
| + // See crbug.com/344834.
|
| + WCHAR keyboard_layout[KL_NAMELENGTH];
|
| + if (::GetKeyboardLayoutNameW(keyboard_layout)) {
|
| + input_language_id_ =
|
| + static_cast<LANGID>(_wtoi(&keyboard_layout[KL_NAMELENGTH >> 1]));
|
| + } else {
|
| + input_language_id_ = 0x0409; // Fallback to en-US.
|
| + }
|
| }
|
|
|
| void IMM32Manager::CreateImeWindow(HWND window_handle) {
|
| @@ -457,31 +463,10 @@ void IMM32Manager::SetUseCompositionWindow(bool use_composition_window) {
|
| use_composition_window_ = use_composition_window;
|
| }
|
|
|
| -std::string IMM32Manager::GetInputLanguageName() const {
|
| - const LCID locale_id = MAKELCID(input_language_id_, SORT_DEFAULT);
|
| - // max size for LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME is 9.
|
| - wchar_t buffer[9];
|
| -
|
| - // Get language id.
|
| - int length = ::GetLocaleInfo(locale_id, LOCALE_SISO639LANGNAME, &buffer[0],
|
| - arraysize(buffer));
|
| - if (length <= 1)
|
| - return std::string();
|
| -
|
| - std::string language;
|
| - base::WideToUTF8(buffer, length - 1, &language);
|
| - if (SUBLANGID(input_language_id_) == SUBLANG_NEUTRAL)
|
| - return language;
|
| -
|
| - // Get region id.
|
| - length = ::GetLocaleInfo(locale_id, LOCALE_SISO3166CTRYNAME, &buffer[0],
|
| - arraysize(buffer));
|
| - if (length <= 1)
|
| - return language;
|
| -
|
| - std::string region;
|
| - base::WideToUTF8(buffer, length - 1, ®ion);
|
| - return language.append(1, '-').append(region);
|
| +bool IMM32Manager::IsInputLanguageCJK() const {
|
| + LANGID lang = PRIMARYLANGID(input_language_id_);
|
| + return lang == LANG_CHINESE || lang == LANG_JAPANESE ||
|
| + lang == LANG_KOREAN;
|
| }
|
|
|
| void IMM32Manager::SetTextInputMode(HWND window_handle,
|
|
|