Chromium Code Reviews| Index: ui/base/win/ime_input.cc |
| diff --git a/ui/base/win/ime_input.cc b/ui/base/win/ime_input.cc |
| index 3bad0acbf3b2c3c1220d0149fc86367fd21ed5a1..f3b1a0a8aa6a49b694466a49c6c9ea0956f89546 100644 |
| --- a/ui/base/win/ime_input.cc |
| +++ b/ui/base/win/ime_input.cc |
| @@ -4,6 +4,10 @@ |
| #include "ui/base/win/ime_input.h" |
| +#include <atlbase.h> |
| +#include <atlcom.h> |
| +#include <msctf.h> |
| + |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/string16.h" |
| @@ -130,7 +134,23 @@ bool ImeInput::SetInputLanguage() { |
| // while composing a text. |
| HKL keyboard_layout = ::GetKeyboardLayout(0); |
| input_language_id_ = reinterpret_cast<LANGID>(keyboard_layout); |
| - ime_status_ = (::ImmIsIME(keyboard_layout) == TRUE); |
| + |
| + // Check TSF Input Processor first. |
| + // If the active profile is TSF INPUTPROCESSOR, this is IME. |
| + CComPtr<ITfInputProcessorProfileMgr> prof_mgr; |
|
Yohei Yukawa
2013/05/16 08:55:02
We prefer to use our own scoped pointer to maingai
kochi
2013/05/16 10:29:31
Done.
|
| + TF_INPUTPROCESSORPROFILE prof; |
| + if (SUCCEEDED(prof_mgr.CoCreateInstance(CLSID_TF_InputProcessorProfiles)) && |
| + SUCCEEDED(prof_mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof)) && |
| + prof.hkl == NULL && |
| + prof.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR) { |
| + ime_status_ = true; |
| + } else { |
| + // If the curent language is not using TSF, check IMM32 based IMEs. |
| + // As ImmIsIME always returns non-0 value on Vista+, use ImmGetIMEFileName |
| + // instead to check if this HKL has any associated IME file. |
| + ime_status_ = (ImmGetIMEFileName(keyboard_layout, NULL, 0) != 0); |
| + } |
| + |
| return ime_status_; |
| } |