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/base/ime/input_method_base.h" | 5 #include "ui/base/ime/input_method_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/ime/input_method_delegate.h" | 8 #include "ui/base/ime/input_method_delegate.h" |
9 #include "ui/base/ime/input_method_observer.h" | 9 #include "ui/base/ime/input_method_observer.h" |
10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) { | 45 void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) { |
46 TextInputClient* old = text_input_client_; | 46 TextInputClient* old = text_input_client_; |
47 OnWillChangeFocusedClient(old, client); | 47 OnWillChangeFocusedClient(old, client); |
48 text_input_client_ = client; // NULL allowed. | 48 text_input_client_ = client; // NULL allowed. |
49 OnDidChangeFocusedClient(old, client); | 49 OnDidChangeFocusedClient(old, client); |
50 | 50 |
51 if (old != text_input_client_) | 51 if (old != text_input_client_) |
52 NotifyTextInputStateChanged(text_input_client_); | 52 NotifyTextInputStateChanged(text_input_client_); |
53 } | 53 } |
54 | 54 |
| 55 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { |
| 56 if (text_input_client_ == client) { |
| 57 OnWillChangeFocusedClient(client, NULL); |
| 58 text_input_client_ = NULL; |
| 59 OnDidChangeFocusedClient(client, NULL); |
| 60 NotifyTextInputStateChanged(text_input_client_); |
| 61 } |
| 62 } |
| 63 |
55 TextInputClient* InputMethodBase::GetTextInputClient() const { | 64 TextInputClient* InputMethodBase::GetTextInputClient() const { |
56 return system_toplevel_window_focused_ ? text_input_client_ : NULL; | 65 return system_toplevel_window_focused_ ? text_input_client_ : NULL; |
57 } | 66 } |
58 | 67 |
59 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 68 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
60 if (!IsTextInputClientFocused(client)) | 69 if (!IsTextInputClientFocused(client)) |
61 return; | 70 return; |
62 NotifyTextInputStateChanged(client); | 71 NotifyTextInputStateChanged(client); |
63 } | 72 } |
64 | 73 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 121 } |
113 | 122 |
114 void InputMethodBase::NotifyTextInputStateChanged( | 123 void InputMethodBase::NotifyTextInputStateChanged( |
115 const TextInputClient* client) { | 124 const TextInputClient* client) { |
116 FOR_EACH_OBSERVER(InputMethodObserver, | 125 FOR_EACH_OBSERVER(InputMethodObserver, |
117 observer_list_, | 126 observer_list_, |
118 OnTextInputStateChanged(client)); | 127 OnTextInputStateChanged(client)); |
119 } | 128 } |
120 | 129 |
121 } // namespace ui | 130 } // namespace ui |
OLD | NEW |