| 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" | |
| 15 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 16 | 14 |
| 17 namespace ui { | 15 namespace ui { |
| 18 | 16 |
| 19 InputMethodBase::InputMethodBase() | 17 InputMethodBase::InputMethodBase() |
| 20 : delegate_(NULL), | 18 : delegate_(NULL), |
| 21 text_input_client_(NULL), | 19 text_input_client_(NULL), |
| 22 system_toplevel_window_focused_(false) { | 20 system_toplevel_window_focused_(false) { |
| 23 } | 21 } |
| 24 | 22 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 44 SetFocusedTextInputClientInternal(client); | 42 SetFocusedTextInputClientInternal(client); |
| 45 } | 43 } |
| 46 | 44 |
| 47 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { | 45 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { |
| 48 if (text_input_client_ != client) | 46 if (text_input_client_ != client) |
| 49 return; | 47 return; |
| 50 SetFocusedTextInputClientInternal(NULL); | 48 SetFocusedTextInputClientInternal(NULL); |
| 51 } | 49 } |
| 52 | 50 |
| 53 TextInputClient* InputMethodBase::GetTextInputClient() const { | 51 TextInputClient* InputMethodBase::GetTextInputClient() const { |
| 54 if (switches::IsTextInputFocusManagerEnabled()) | |
| 55 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient(); | |
| 56 | |
| 57 return system_toplevel_window_focused_ ? text_input_client_ : NULL; | 52 return system_toplevel_window_focused_ ? text_input_client_ : NULL; |
| 58 } | 53 } |
| 59 | 54 |
| 60 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 55 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
| 61 if (!IsTextInputClientFocused(client)) | 56 if (!IsTextInputClientFocused(client)) |
| 62 return; | 57 return; |
| 63 NotifyTextInputStateChanged(client); | 58 NotifyTextInputStateChanged(client); |
| 64 } | 59 } |
| 65 | 60 |
| 66 TextInputType InputMethodBase::GetTextInputType() const { | 61 TextInputType InputMethodBase::GetTextInputType() const { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 120 } |
| 126 | 121 |
| 127 void InputMethodBase::NotifyTextInputCaretBoundsChanged( | 122 void InputMethodBase::NotifyTextInputCaretBoundsChanged( |
| 128 const TextInputClient* client) { | 123 const TextInputClient* client) { |
| 129 FOR_EACH_OBSERVER( | 124 FOR_EACH_OBSERVER( |
| 130 InputMethodObserver, observer_list_, OnCaretBoundsChanged(client)); | 125 InputMethodObserver, observer_list_, OnCaretBoundsChanged(client)); |
| 131 } | 126 } |
| 132 | 127 |
| 133 void InputMethodBase::SetFocusedTextInputClientInternal( | 128 void InputMethodBase::SetFocusedTextInputClientInternal( |
| 134 TextInputClient* client) { | 129 TextInputClient* client) { |
| 135 if (switches::IsTextInputFocusManagerEnabled()) | |
| 136 return; | |
| 137 | |
| 138 TextInputClient* old = text_input_client_; | 130 TextInputClient* old = text_input_client_; |
| 139 if (old == client) | 131 if (old == client) |
| 140 return; | 132 return; |
| 141 OnWillChangeFocusedClient(old, client); | 133 OnWillChangeFocusedClient(old, client); |
| 142 text_input_client_ = client; // NULL allowed. | 134 text_input_client_ = client; // NULL allowed. |
| 143 OnDidChangeFocusedClient(old, client); | 135 OnDidChangeFocusedClient(old, client); |
| 144 NotifyTextInputStateChanged(text_input_client_); | 136 NotifyTextInputStateChanged(text_input_client_); |
| 145 } | 137 } |
| 146 | 138 |
| 147 } // namespace ui | 139 } // namespace ui |
| OLD | NEW |