OLD | NEW |
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/views/ime/input_method_bridge.h" | 5 #include "ui/views/ime/input_method_bridge.h" |
6 | 6 |
7 #include "ui/base/events/event.h" | 7 #include "ui/base/events/event.h" |
8 #include "ui/base/ime/input_method.h" | 8 #include "ui/base/ime/input_method.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 SetDelegate(delegate); | 22 SetDelegate(delegate); |
23 } | 23 } |
24 | 24 |
25 InputMethodBridge::~InputMethodBridge() { | 25 InputMethodBridge::~InputMethodBridge() { |
26 // By the time we get here it's very likely |widget_|'s NativeWidget has been | 26 // By the time we get here it's very likely |widget_|'s NativeWidget has been |
27 // destroyed. This means any calls to |widget_| that go to the NativeWidget, | 27 // destroyed. This means any calls to |widget_| that go to the NativeWidget, |
28 // such as IsActive(), will crash. SetFocusedTextInputClient() may callback to | 28 // such as IsActive(), will crash. SetFocusedTextInputClient() may callback to |
29 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use | 29 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use |
30 // it. | 30 // it. |
31 DetachFromWidget(); | 31 DetachFromWidget(); |
32 if (host_->GetTextInputClient() == this) | 32 host_->DetachTextInputClient(this); |
33 host_->SetFocusedTextInputClient(NULL); | |
34 } | 33 } |
35 | 34 |
36 void InputMethodBridge::OnFocus() { | 35 void InputMethodBridge::OnFocus() { |
37 // Direct the shared IME to send TextInputClient messages to |this| object. | 36 // Direct the shared IME to send TextInputClient messages to |this| object. |
38 if (shared_input_method_ || !host_->GetTextInputClient()) | 37 if (shared_input_method_ || !host_->GetTextInputClient()) |
39 host_->SetFocusedTextInputClient(this); | 38 host_->SetFocusedTextInputClient(this); |
40 | 39 |
41 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move | 40 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move |
42 // text input type tracker code to ui::InputMethodBase. | 41 // text input type tracker code to ui::InputMethodBase. |
43 if (GetFocusedView()) | 42 if (GetFocusedView()) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 OnTextInputTypeChanged(focused); | 248 OnTextInputTypeChanged(focused); |
250 OnCaretBoundsChanged(focused); | 249 OnCaretBoundsChanged(focused); |
251 } | 250 } |
252 | 251 |
253 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { | 252 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { |
254 return host_; | 253 return host_; |
255 } | 254 } |
256 | 255 |
257 | 256 |
258 } // namespace views | 257 } // namespace views |
OLD | NEW |