Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: ui/aura/mus/input_method_mus.cc

Issue 2626983003: IME for Mus: Send TextInputClient information to IMEDriver. (Closed)
Patch Set: Addressed feedback. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/aura/mus/input_method_mus.h" 5 #include "ui/aura/mus/input_method_mus.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "services/ui/public/interfaces/constants.mojom.h" 10 #include "services/ui/public/interfaces/constants.mojom.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void InputMethodMus::DispatchKeyEvent(ui::KeyEvent* event) { 86 void InputMethodMus::DispatchKeyEvent(ui::KeyEvent* event) {
87 DispatchKeyEvent(event, nullptr); 87 DispatchKeyEvent(event, nullptr);
88 } 88 }
89 89
90 void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) { 90 void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) {
91 if (IsTextInputClientFocused(client)) 91 if (IsTextInputClientFocused(client))
92 UpdateTextInputType(); 92 UpdateTextInputType();
93 InputMethodBase::OnTextInputTypeChanged(client); 93 InputMethodBase::OnTextInputTypeChanged(client);
94 94
95 if (input_method_) { 95 if (input_method_)
96 input_method_->OnTextInputTypeChanged(client->GetTextInputType()); 96 input_method_->OnTextInputTypeChanged(client->GetTextInputType());
97 }
98 } 97 }
99 98
100 void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) { 99 void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) {
101 if (input_method_) 100 if (input_method_)
102 input_method_->OnCaretBoundsChanged(client->GetCaretBounds()); 101 input_method_->OnCaretBoundsChanged(client->GetCaretBounds());
103 } 102 }
104 103
105 void InputMethodMus::CancelComposition(const ui::TextInputClient* client) { 104 void InputMethodMus::CancelComposition(const ui::TextInputClient* client) {
106 if (input_method_) 105 if (input_method_)
107 input_method_->CancelComposition(); 106 input_method_->CancelComposition();
(...skipping 11 matching lines...) Expand all
119 } 118 }
120 119
121 void InputMethodMus::OnDidChangeFocusedClient( 120 void InputMethodMus::OnDidChangeFocusedClient(
122 ui::TextInputClient* focused_before, 121 ui::TextInputClient* focused_before,
123 ui::TextInputClient* focused) { 122 ui::TextInputClient* focused) {
124 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); 123 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
125 UpdateTextInputType(); 124 UpdateTextInputType();
126 125
127 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); 126 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused);
128 if (ime_server_) { 127 if (ime_server_) {
129 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), 128 ui::mojom::StartSessionDetailsPtr details =
130 MakeRequest(&input_method_)); 129 ui::mojom::StartSessionDetails::New();
130 details->client = text_input_client_->CreateInterfacePtrAndBind();
131 details->input_method_request = MakeRequest(&input_method_);
132 details->text_input_type = focused->GetTextInputType();
133 details->text_input_mode = focused->GetTextInputMode();
134 details->text_direction = focused->GetTextDirection();
135 details->text_input_flags = focused->GetTextInputFlags();
136 details->caret_bounds = focused->GetCaretBounds();
137 ime_server_->StartSession(std::move(details));
131 } 138 }
132 } 139 }
133 140
134 void InputMethodMus::UpdateTextInputType() { 141 void InputMethodMus::UpdateTextInputType() {
135 ui::TextInputType type = GetTextInputType(); 142 ui::TextInputType type = GetTextInputType();
136 mojo::TextInputStatePtr state = mojo::TextInputState::New(); 143 mojo::TextInputStatePtr state = mojo::TextInputState::New();
137 state->type = mojo::ConvertTo<mojo::TextInputType>(type); 144 state->type = mojo::ConvertTo<mojo::TextInputType>(type);
138 if (window_) { 145 if (window_) {
139 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); 146 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_);
140 if (type != ui::TEXT_INPUT_TYPE_NONE) 147 if (type != ui::TEXT_INPUT_TYPE_NONE)
(...skipping 20 matching lines...) Expand all
161 event_result = EventResult::HANDLED; 168 event_result = EventResult::HANDLED;
162 } 169 }
163 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is 170 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is
164 // called instead of the version which provides a callback. In mus+ash we 171 // called instead of the version which provides a callback. In mus+ash we
165 // use the version with callback, but some unittests use the standard form. 172 // use the version with callback, but some unittests use the standard form.
166 if (ack_callback) 173 if (ack_callback)
167 ack_callback->Run(event_result); 174 ack_callback->Run(event_result);
168 } 175 }
169 176
170 } // namespace aura 177 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698