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

Side by Side Diff: ui/base/ime/input_method_win.cc

Issue 1037103004: Fix a crash seen in Desktop Chrome Windows while displaying a bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delay creation of the IME Created 5 years, 9 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/input_method_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/input_method_win.h" 5 #include "ui/base/ime/input_method_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/profiler/scoped_tracker.h" 8 #include "base/profiler/scoped_tracker.h"
9 #include "ui/base/ime/text_input_client.h" 9 #include "ui/base/ime/text_input_client.h"
10 #include "ui/base/ime/win/tsf_input_scope.h" 10 #include "ui/base/ime/win/tsf_input_scope.h"
(...skipping 14 matching lines...) Expand all
25 } // namespace 25 } // namespace
26 26
27 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, 27 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate,
28 HWND toplevel_window_handle) 28 HWND toplevel_window_handle)
29 : toplevel_window_handle_(toplevel_window_handle), 29 : toplevel_window_handle_(toplevel_window_handle),
30 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION), 30 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION),
31 accept_carriage_return_(false), 31 accept_carriage_return_(false),
32 active_(false), 32 active_(false),
33 enabled_(false), 33 enabled_(false),
34 is_candidate_popup_open_(false), 34 is_candidate_popup_open_(false),
35 composing_window_handle_(NULL) { 35 composing_window_handle_(NULL),
36 default_input_language_initialized_(false) {
36 SetDelegate(delegate); 37 SetDelegate(delegate);
37 // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur() 38 // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur()
38 // are not implemented yet. To work around this limitation, here we use 39 // are not implemented yet. To work around this limitation, here we use
39 // "always focused" model. 40 // "always focused" model.
40 // TODO(ime): Fix the caller of OnFocus() and OnBlur() so that appropriate 41 // TODO(ime): Fix the caller of OnFocus() and OnBlur() so that appropriate
41 // focus event will be passed. 42 // focus event will be passed.
42 InputMethodBase::OnFocus(); 43 InputMethodBase::OnFocus();
43 } 44 }
44 45
45 void InputMethodWin::Init(bool focused) { 46 void InputMethodWin::Init(bool focused) {
46 // Gets the initial input locale.
47 OnInputLocaleChanged();
48
49 InputMethodBase::Init(focused); 47 InputMethodBase::Init(focused);
50 } 48 }
51 49
52 void InputMethodWin::OnFocus() { 50 void InputMethodWin::OnFocus() {
53 // Ignore OnFocus event for "always focused" model. See the comment in the 51 // Ignore OnFocus event for "always focused" model. See the comment in the
54 // constructor. 52 // constructor.
55 // TODO(ime): Implement OnFocus once the callers are fixed. 53 // TODO(ime): Implement OnFocus once the callers are fixed.
56 } 54 }
57 55
58 void InputMethodWin::OnBlur() { 56 void InputMethodWin::OnBlur() {
59 // Ignore OnBlur event for "always focused" model. See the comment in the 57 // Ignore OnBlur event for "always focused" model. See the comment in the
60 // constructor. 58 // constructor.
61 // TODO(ime): Implement OnFocus once the callers are fixed. 59 // TODO(ime): Implement OnFocus once the callers are fixed.
62 } 60 }
63 61
64 bool InputMethodWin::OnUntranslatedIMEMessage( 62 bool InputMethodWin::OnUntranslatedIMEMessage(
65 const base::NativeEvent& event, 63 const base::NativeEvent& event,
66 InputMethod::NativeEventResult* result) { 64 InputMethod::NativeEventResult* result) {
67 LRESULT original_result = 0; 65 LRESULT original_result = 0;
68 BOOL handled = FALSE; 66 BOOL handled = FALSE;
67
68 if (!default_input_language_initialized_) {
69 default_input_language_initialized_ = true;
msw 2015/03/27 19:05:23 Nix this, it's set in OnInputLocaleChanged().
ananta 2015/03/27 19:08:38 Done.
70 // Gets the initial input locale.
msw 2015/03/27 19:05:23 Optionally nix comment and curlies, or outdent thi
ananta 2015/03/27 19:08:38 Done.
71 OnInputLocaleChanged();
72 }
73
69 switch (event.message) { 74 switch (event.message) {
70 case WM_IME_SETCONTEXT: 75 case WM_IME_SETCONTEXT:
71 original_result = OnImeSetContext( 76 original_result = OnImeSetContext(
72 event.hwnd, event.message, event.wParam, event.lParam, &handled); 77 event.hwnd, event.message, event.wParam, event.lParam, &handled);
73 break; 78 break;
74 case WM_IME_STARTCOMPOSITION: 79 case WM_IME_STARTCOMPOSITION:
75 original_result = OnImeStartComposition( 80 original_result = OnImeStartComposition(
76 event.hwnd, event.message, event.wParam, event.lParam, &handled); 81 event.hwnd, event.message, event.wParam, event.lParam, &handled);
77 break; 82 break;
78 case WM_IME_COMPOSITION: 83 case WM_IME_COMPOSITION:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 screen_bounds.size()); 177 screen_bounds.size());
173 imm32_manager_.UpdateCaretRect(attached_window, caret_rect); 178 imm32_manager_.UpdateCaretRect(attached_window, caret_rect);
174 } 179 }
175 180
176 void InputMethodWin::CancelComposition(const TextInputClient* client) { 181 void InputMethodWin::CancelComposition(const TextInputClient* client) {
177 if (enabled_ && IsTextInputClientFocused(client)) 182 if (enabled_ && IsTextInputClientFocused(client))
178 imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); 183 imm32_manager_.CancelIME(GetAttachedWindowHandle(client));
179 } 184 }
180 185
181 void InputMethodWin::OnInputLocaleChanged() { 186 void InputMethodWin::OnInputLocaleChanged() {
187 default_input_language_initialized_ = true;
182 active_ = imm32_manager_.SetInputLanguage(); 188 active_ = imm32_manager_.SetInputLanguage();
183 locale_ = imm32_manager_.GetInputLanguageName(); 189 locale_ = imm32_manager_.GetInputLanguageName();
184 OnInputMethodChanged(); 190 OnInputMethodChanged();
185 } 191 }
186 192
187 std::string InputMethodWin::GetInputLocale() { 193 std::string InputMethodWin::GetInputLocale() {
188 return locale_; 194 return locale_;
189 } 195 }
190 196
191 bool InputMethodWin::IsActive() { 197 bool InputMethodWin::IsActive() {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 enabled_ = true; 647 enabled_ = true;
642 break; 648 break;
643 } 649 }
644 650
645 imm32_manager_.SetTextInputMode(window_handle, text_input_mode); 651 imm32_manager_.SetTextInputMode(window_handle, text_input_mode);
646 tsf_inputscope::SetInputScopeForTsfUnawareWindow( 652 tsf_inputscope::SetInputScopeForTsfUnawareWindow(
647 window_handle, text_input_type, text_input_mode); 653 window_handle, text_input_type, text_input_mode);
648 } 654 }
649 655
650 } // namespace ui 656 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698