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

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: fixed test failures on Android. 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
« no previous file with comments | « ui/base/ime/win/imm32_manager.h ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 7 #include <msctf.h>
yukawa 2015/07/17 07:50:36 nit: Can we remove this line?
Shu Chen 2015/07/17 08:22:00 Done.
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
15 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/base/ime/composition_text.h" 16 #include "ui/base/ime/composition_text.h"
17 17
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return false; 111 return false;
112 } 112 }
113 } 113 }
114 114
115 } // namespace 115 } // namespace
116 116
117 namespace ui { 117 namespace ui {
118 118
119 IMM32Manager::IMM32Manager() 119 IMM32Manager::IMM32Manager()
120 : is_composing_(false), 120 : is_composing_(false),
121 ime_status_(false),
122 input_language_id_(LANG_USER_DEFAULT), 121 input_language_id_(LANG_USER_DEFAULT),
123 system_caret_(false), 122 system_caret_(false),
124 caret_rect_(-1, -1, 0, 0), 123 caret_rect_(-1, -1, 0, 0),
125 use_composition_window_(false) { 124 use_composition_window_(false) {
126 } 125 }
127 126
128 IMM32Manager::~IMM32Manager() { 127 IMM32Manager::~IMM32Manager() {
129 } 128 }
130 129
131 bool IMM32Manager::SetInputLanguage() { 130 void IMM32Manager::SetInputLanguage() {
132 // Retrieve the current keyboard layout from Windows and determine whether 131 // Retrieve the current keyboard layout from Windows and determine whether
133 // or not the current input context has IMEs. 132 // or not the current input context has IMEs.
134 // Also save its input language for language-specific operations required 133 // Also save its input language for language-specific operations required
135 // while composing a text. 134 // while composing a text.
136 HKL keyboard_layout = ::GetKeyboardLayout(0); 135 HKL keyboard_layout = ::GetKeyboardLayout(0);
137 input_language_id_ = 136 input_language_id_ =
138 static_cast<LANGID>(reinterpret_cast<uintptr_t>(keyboard_layout)); 137 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 } 138 }
158 139
159 void IMM32Manager::CreateImeWindow(HWND window_handle) { 140 void IMM32Manager::CreateImeWindow(HWND window_handle) {
160 // When a user disables TSF (Text Service Framework) and CUAS (Cicero 141 // When a user disables TSF (Text Service Framework) and CUAS (Cicero
161 // Unaware Application Support), Chinese IMEs somehow ignore function calls 142 // Unaware Application Support), Chinese IMEs somehow ignore function calls
162 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate 143 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
163 // window to the position given as its parameters, and use the position 144 // 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 145 // of the current system caret instead, i.e. it uses ::GetCaretPos() to
165 // retrieve the position of their IME candidate window. 146 // retrieve the position of their IME candidate window.
166 // Therefore, we create a temporary system caret for Chinese IMEs and use 147 // 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 618 | IME_CMODE_KATAKANA
638 | IME_CMODE_FULLSHAPE); 619 | IME_CMODE_FULLSHAPE);
639 break; 620 break;
640 default: 621 default:
641 *open = FALSE; 622 *open = FALSE;
642 break; 623 break;
643 } 624 }
644 } 625 }
645 626
646 } // namespace ui 627 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/win/imm32_manager.h ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698