| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "ui/base/ime/input_method_delegate.h" | 10 #include "ui/base/ime/input_method_delegate.h" |
| 11 #include "ui/base/ime/input_method_observer.h" | 11 #include "ui/base/ime/input_method_observer.h" |
| 12 #include "ui/base/ime/text_input_client.h" | 12 #include "ui/base/ime/text_input_client.h" |
| 13 #include "ui/base/ime/text_input_focus_manager.h" |
| 14 #include "ui/base/ui_base_switches_util.h" |
| 13 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 14 | 16 |
| 15 namespace ui { | 17 namespace ui { |
| 16 | 18 |
| 17 InputMethodBase::InputMethodBase() | 19 InputMethodBase::InputMethodBase() |
| 18 : delegate_(NULL), | 20 : delegate_(NULL), |
| 19 text_input_client_(NULL), | 21 text_input_client_(NULL), |
| 20 system_toplevel_window_focused_(false) { | 22 system_toplevel_window_focused_(false) { |
| 21 } | 23 } |
| 22 | 24 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 SetFocusedTextInputClientInternal(client); | 51 SetFocusedTextInputClientInternal(client); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { | 54 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { |
| 53 if (text_input_client_ != client) | 55 if (text_input_client_ != client) |
| 54 return; | 56 return; |
| 55 SetFocusedTextInputClientInternal(NULL); | 57 SetFocusedTextInputClientInternal(NULL); |
| 56 } | 58 } |
| 57 | 59 |
| 58 TextInputClient* InputMethodBase::GetTextInputClient() const { | 60 TextInputClient* InputMethodBase::GetTextInputClient() const { |
| 61 if (switches::IsTextInputFocusManagerEnabled()) |
| 62 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient(); |
| 63 |
| 59 return system_toplevel_window_focused_ ? text_input_client_ : NULL; | 64 return system_toplevel_window_focused_ ? text_input_client_ : NULL; |
| 60 } | 65 } |
| 61 | 66 |
| 62 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 67 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
| 63 if (!IsTextInputClientFocused(client)) | 68 if (!IsTextInputClientFocused(client)) |
| 64 return; | 69 return; |
| 65 NotifyTextInputStateChanged(client); | 70 NotifyTextInputStateChanged(client); |
| 66 } | 71 } |
| 67 | 72 |
| 68 TextInputType InputMethodBase::GetTextInputType() const { | 73 TextInputType InputMethodBase::GetTextInputType() const { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 121 |
| 117 void InputMethodBase::NotifyTextInputStateChanged( | 122 void InputMethodBase::NotifyTextInputStateChanged( |
| 118 const TextInputClient* client) { | 123 const TextInputClient* client) { |
| 119 FOR_EACH_OBSERVER(InputMethodObserver, | 124 FOR_EACH_OBSERVER(InputMethodObserver, |
| 120 observer_list_, | 125 observer_list_, |
| 121 OnTextInputStateChanged(client)); | 126 OnTextInputStateChanged(client)); |
| 122 } | 127 } |
| 123 | 128 |
| 124 void InputMethodBase::SetFocusedTextInputClientInternal( | 129 void InputMethodBase::SetFocusedTextInputClientInternal( |
| 125 TextInputClient* client) { | 130 TextInputClient* client) { |
| 131 if (switches::IsTextInputFocusManagerEnabled()) |
| 132 return; |
| 133 |
| 126 TextInputClient* old = text_input_client_; | 134 TextInputClient* old = text_input_client_; |
| 127 if (old == client) | 135 if (old == client) |
| 128 return; | 136 return; |
| 129 OnWillChangeFocusedClient(old, client); | 137 OnWillChangeFocusedClient(old, client); |
| 130 text_input_client_ = client; // NULL allowed. | 138 text_input_client_ = client; // NULL allowed. |
| 131 OnDidChangeFocusedClient(old, client); | 139 OnDidChangeFocusedClient(old, client); |
| 132 NotifyTextInputStateChanged(text_input_client_); | 140 NotifyTextInputStateChanged(text_input_client_); |
| 133 } | 141 } |
| 134 | 142 |
| 135 void InputMethodBase::OnCandidateWindowShown() { | 143 void InputMethodBase::OnCandidateWindowShown() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 if (text_input_client_) | 168 if (text_input_client_) |
| 161 text_input_client_->OnCandidateWindowUpdated(); | 169 text_input_client_->OnCandidateWindowUpdated(); |
| 162 } | 170 } |
| 163 | 171 |
| 164 void InputMethodBase::CandidateWindowHiddenCallback() { | 172 void InputMethodBase::CandidateWindowHiddenCallback() { |
| 165 if (text_input_client_) | 173 if (text_input_client_) |
| 166 text_input_client_->OnCandidateWindowHidden(); | 174 text_input_client_->OnCandidateWindowHidden(); |
| 167 } | 175 } |
| 168 | 176 |
| 169 } // namespace ui | 177 } // namespace ui |
| OLD | NEW |