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" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 | 13 |
14 InputMethodBase::InputMethodBase() | 14 InputMethodBase::InputMethodBase() |
15 : delegate_(NULL), | 15 : delegate_(NULL), |
16 text_input_client_(NULL), | 16 text_input_client_(NULL), |
17 system_toplevel_window_focused_(false) { | 17 system_toplevel_window_focused_(false), |
| 18 is_candidate_popup_open_(false) { |
18 } | 19 } |
19 | 20 |
20 InputMethodBase::~InputMethodBase() { | 21 InputMethodBase::~InputMethodBase() { |
21 FOR_EACH_OBSERVER(InputMethodObserver, | 22 FOR_EACH_OBSERVER(InputMethodObserver, |
22 observer_list_, | 23 observer_list_, |
23 OnInputMethodDestroyed(this)); | 24 OnInputMethodDestroyed(this)); |
24 } | 25 } |
25 | 26 |
26 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { | 27 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { |
27 delegate_ = delegate; | 28 delegate_ = delegate; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 (type, key_code, flags) : false; | 126 (type, key_code, flags) : false; |
126 } | 127 } |
127 | 128 |
128 void InputMethodBase::NotifyTextInputStateChanged( | 129 void InputMethodBase::NotifyTextInputStateChanged( |
129 const TextInputClient* client) { | 130 const TextInputClient* client) { |
130 FOR_EACH_OBSERVER(InputMethodObserver, | 131 FOR_EACH_OBSERVER(InputMethodObserver, |
131 observer_list_, | 132 observer_list_, |
132 OnTextInputStateChanged(client)); | 133 OnTextInputStateChanged(client)); |
133 } | 134 } |
134 | 135 |
| 136 void InputMethodBase::NotifyCandidateWindowStateChanged() { |
| 137 bool new_state = IsCandidatePopupOpen(); |
| 138 if (!is_candidate_popup_open_ && new_state) { |
| 139 text_input_client_->OnCandidateWindowShow(); |
| 140 } else if (is_candidate_popup_open_ && new_state) { |
| 141 text_input_client_->OnCandidateWindowUpdate(); |
| 142 } else if (is_candidate_popup_open_ && !new_state) { |
| 143 text_input_client_->OnCandidateWindowHide(); |
| 144 } |
| 145 is_candidate_popup_open_ = new_state; |
| 146 } |
| 147 |
135 void InputMethodBase::SetFocusedTextInputClientInternal( | 148 void InputMethodBase::SetFocusedTextInputClientInternal( |
136 TextInputClient* client) { | 149 TextInputClient* client) { |
137 TextInputClient* old = text_input_client_; | 150 TextInputClient* old = text_input_client_; |
138 if (old == client) | 151 if (old == client) |
139 return; | 152 return; |
140 OnWillChangeFocusedClient(old, client); | 153 OnWillChangeFocusedClient(old, client); |
141 text_input_client_ = client; // NULL allowed. | 154 text_input_client_ = client; // NULL allowed. |
142 OnDidChangeFocusedClient(old, client); | 155 OnDidChangeFocusedClient(old, client); |
143 NotifyTextInputStateChanged(text_input_client_); | 156 NotifyTextInputStateChanged(text_input_client_); |
144 } | 157 } |
145 | 158 |
146 } // namespace ui | 159 } // namespace ui |
OLD | NEW |