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

Side by Side Diff: ui/base/ime/win/imm32_manager.cc

Issue 1234193002: Simplify InputMethodWin initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/ime/win/imm32_manager.h" 5 #include "ui/base/ime/win/imm32_manager.h"
6 6
7 #include <msctf.h>
8
9 #include "base/basictypes.h" 7 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
12 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
14 #include "base/win/scoped_comptr.h" 12 #include "base/win/scoped_comptr.h"
15 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/base/ime/composition_text.h" 14 #include "ui/base/ime/composition_text.h"
17 15
18 // "imm32.lib" is required by IMM32 APIs used in this file. 16 // "imm32.lib" is required by IMM32 APIs used in this file.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return false; 109 return false;
112 } 110 }
113 } 111 }
114 112
115 } // namespace 113 } // namespace
116 114
117 namespace ui { 115 namespace ui {
118 116
119 IMM32Manager::IMM32Manager() 117 IMM32Manager::IMM32Manager()
120 : is_composing_(false), 118 : is_composing_(false),
121 ime_status_(false),
122 input_language_id_(LANG_USER_DEFAULT), 119 input_language_id_(LANG_USER_DEFAULT),
123 system_caret_(false), 120 system_caret_(false),
124 caret_rect_(-1, -1, 0, 0), 121 caret_rect_(-1, -1, 0, 0),
125 use_composition_window_(false) { 122 use_composition_window_(false) {
126 } 123 }
127 124
128 IMM32Manager::~IMM32Manager() { 125 IMM32Manager::~IMM32Manager() {
129 } 126 }
130 127
131 bool IMM32Manager::SetInputLanguage() { 128 void IMM32Manager::SetInputLanguage() {
132 // Retrieve the current keyboard layout from Windows and determine whether 129 // Retrieve the current keyboard layout from Windows and determine whether
133 // or not the current input context has IMEs. 130 // or not the current input context has IMEs.
134 // Also save its input language for language-specific operations required 131 // Also save its input language for language-specific operations required
135 // while composing a text. 132 // while composing a text.
136 HKL keyboard_layout = ::GetKeyboardLayout(0); 133 HKL keyboard_layout = ::GetKeyboardLayout(0);
137 input_language_id_ = 134 input_language_id_ =
138 static_cast<LANGID>(reinterpret_cast<uintptr_t>(keyboard_layout)); 135 static_cast<LANGID>(reinterpret_cast<uintptr_t>(keyboard_layout));
139
140 // Check TSF Input Processor first.
141 // If the active profile is TSF INPUTPROCESSOR, this is IME.
142 base::win::ScopedComPtr<ITfInputProcessorProfileMgr> prof_mgr;
143 TF_INPUTPROCESSORPROFILE prof;
144 if (SUCCEEDED(prof_mgr.CreateInstance(CLSID_TF_InputProcessorProfiles)) &&
145 SUCCEEDED(prof_mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof)) &&
146 prof.hkl == NULL &&
147 prof.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR) {
148 ime_status_ = true;
149 } else {
150 // If the curent language is not using TSF, check IMM32 based IMEs.
151 // As ImmIsIME always returns non-0 value on Vista+, use ImmGetIMEFileName
152 // instead to check if this HKL has any associated IME file.
153 ime_status_ = (ImmGetIMEFileName(keyboard_layout, NULL, 0) != 0);
154 }
155
156 return ime_status_;
157 } 136 }
158 137
159 void IMM32Manager::CreateImeWindow(HWND window_handle) { 138 void IMM32Manager::CreateImeWindow(HWND window_handle) {
160 // When a user disables TSF (Text Service Framework) and CUAS (Cicero 139 // When a user disables TSF (Text Service Framework) and CUAS (Cicero
161 // Unaware Application Support), Chinese IMEs somehow ignore function calls 140 // Unaware Application Support), Chinese IMEs somehow ignore function calls
162 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate 141 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
163 // window to the position given as its parameters, and use the position 142 // window to the position given as its parameters, and use the position
164 // of the current system caret instead, i.e. it uses ::GetCaretPos() to 143 // of the current system caret instead, i.e. it uses ::GetCaretPos() to
165 // retrieve the position of their IME candidate window. 144 // retrieve the position of their IME candidate window.
166 // Therefore, we create a temporary system caret for Chinese IMEs and use 145 // Therefore, we create a temporary system caret for Chinese IMEs and use
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 | IME_CMODE_KATAKANA 616 | IME_CMODE_KATAKANA
638 | IME_CMODE_FULLSHAPE); 617 | IME_CMODE_FULLSHAPE);
639 break; 618 break;
640 default: 619 default:
641 *open = FALSE; 620 *open = FALSE;
642 break; 621 break;
643 } 622 }
644 } 623 }
645 624
646 } // namespace ui 625 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698