Chromium Code Reviews| Index: mandoline/ui/aura/input_method_mandoline.cc |
| diff --git a/mandoline/ui/aura/input_method_mandoline.cc b/mandoline/ui/aura/input_method_mandoline.cc |
| index 5857466112d1f512612d6e9f6673fde83a6f42e8..a32d64669d61a5144ce6356f1e1b5981e4f76b6a 100644 |
| --- a/mandoline/ui/aura/input_method_mandoline.cc |
| +++ b/mandoline/ui/aura/input_method_mandoline.cc |
| @@ -4,8 +4,12 @@ |
| #include "mandoline/ui/aura/input_method_mandoline.h" |
| +#include "base/logging.h" |
| +#include "components/view_manager/public/cpp/view.h" |
| +#include "mojo/converters/ime/ime_type_converters.h" |
| #include "ui/base/ime/text_input_client.h" |
| #include "ui/events/event.h" |
| +#include "ui/mojo/ime/text_input_state.mojom.h" |
| namespace mandoline { |
| @@ -13,7 +17,9 @@ namespace mandoline { |
| // InputMethodMandoline, public: |
| InputMethodMandoline::InputMethodMandoline( |
| - ui::internal::InputMethodDelegate* delegate) { |
| + ui::internal::InputMethodDelegate* delegate, |
| + mojo::View* view) |
| + : view_(view) { |
| SetDelegate(delegate); |
| } |
| @@ -22,6 +28,16 @@ InputMethodMandoline::~InputMethodMandoline() {} |
| //////////////////////////////////////////////////////////////////////////////// |
| // InputMethodMandoline, ui::InputMethod implementation: |
| +void InputMethodMandoline::OnFocus() { |
| + InputMethodBase::OnFocus(); |
| + UpdateTextInputType(); |
| +} |
| + |
| +void InputMethodMandoline::OnBlur() { |
| + InputMethodBase::OnBlur(); |
| + UpdateTextInputType(); |
| +} |
| + |
| bool InputMethodMandoline::OnUntranslatedIMEMessage( |
| const base::NativeEvent& event, |
| NativeEventResult* result) { |
| @@ -51,6 +67,13 @@ void InputMethodMandoline::DispatchKeyEvent(ui::KeyEvent* event) { |
| ignore_result(DispatchKeyEventPostIME(event)); |
| } |
| +void InputMethodMandoline::OnTextInputTypeChanged( |
| + const ui::TextInputClient* client) { |
| + if (IsTextInputClientFocused(client)) |
| + UpdateTextInputType(); |
| + InputMethodBase::OnTextInputTypeChanged(client); |
| +} |
| + |
| void InputMethodMandoline::OnCaretBoundsChanged( |
| const ui::TextInputClient* client) { |
| } |
| @@ -70,4 +93,27 @@ bool InputMethodMandoline::IsCandidatePopupOpen() const { |
| return false; |
| } |
| +void InputMethodMandoline::OnWillChangeFocusedClient( |
|
sky
2015/08/14 19:59:23
nit: remove this as it's the same as that of the b
Peng
2015/08/17 13:26:49
Done.
|
| + ui::TextInputClient* focused_before, |
| + ui::TextInputClient* focused) { |
| + InputMethodBase::OnWillChangeFocusedClient(focused_before, focused); |
| +} |
| + |
| +void InputMethodMandoline::OnDidChangeFocusedClient( |
| + ui::TextInputClient* focused_before, |
| + ui::TextInputClient* focused) { |
| + InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); |
| + UpdateTextInputType(); |
| +} |
| + |
| +void InputMethodMandoline::UpdateTextInputType() { |
| + ui::TextInputType type = GetTextInputType(); |
| + mojo::TextInputStatePtr state = mojo::TextInputState::New(); |
| + state->type = mojo::ConvertTo<mojo::TextInputType>(type); |
| + if (type != ui::TEXT_INPUT_TYPE_NONE) |
| + view_->SetImeVisibility(true, state.Pass()); |
| + else |
| + view_->SetTextInputState(state.Pass()); |
| +} |
| + |
| } // namespace mandoline |