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

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

Issue 2545543002: Makes InputMethodMus deal with no connection (Closed)
Patch Set: moar Created 4 years 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
« no previous file with comments | « ui/aura/mus/input_method_mus.h ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/public/interfaces/constants.mojom.h" 9 #include "services/ui/public/interfaces/constants.mojom.h"
10 #include "services/ui/public/interfaces/ime.mojom.h" 10 #include "services/ui/public/interfaces/ime.mojom.h"
(...skipping 15 matching lines...) Expand all
26 26
27 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate, 27 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate,
28 Window* window) 28 Window* window)
29 : window_(window) { 29 : window_(window) {
30 SetDelegate(delegate); 30 SetDelegate(delegate);
31 } 31 }
32 32
33 InputMethodMus::~InputMethodMus() {} 33 InputMethodMus::~InputMethodMus() {}
34 34
35 void InputMethodMus::Init(service_manager::Connector* connector) { 35 void InputMethodMus::Init(service_manager::Connector* connector) {
36 connector->ConnectToInterface(ui::mojom::kServiceName, &ime_server_); 36 if (connector)
37 connector->ConnectToInterface(ui::mojom::kServiceName, &ime_server_);
37 } 38 }
38 39
39 void InputMethodMus::DispatchKeyEvent( 40 void InputMethodMus::DispatchKeyEvent(
40 ui::KeyEvent* event, 41 ui::KeyEvent* event,
41 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback) { 42 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback) {
42 DCHECK(event->type() == ui::ET_KEY_PRESSED || 43 DCHECK(event->type() == ui::ET_KEY_PRESSED ||
43 event->type() == ui::ET_KEY_RELEASED); 44 event->type() == ui::ET_KEY_RELEASED);
44 45
45 // If no text input client, do nothing. 46 // If no text input client, do nothing.
46 if (!GetTextInputClient()) { 47 if (!GetTextInputClient()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return false; 118 return false;
118 } 119 }
119 120
120 void InputMethodMus::OnDidChangeFocusedClient( 121 void InputMethodMus::OnDidChangeFocusedClient(
121 ui::TextInputClient* focused_before, 122 ui::TextInputClient* focused_before,
122 ui::TextInputClient* focused) { 123 ui::TextInputClient* focused) {
123 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); 124 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
124 UpdateTextInputType(); 125 UpdateTextInputType();
125 126
126 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); 127 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused);
127 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), 128 if (ime_server_) {
128 GetProxy(&input_method_)); 129 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(),
130 GetProxy(&input_method_));
131 }
129 } 132 }
130 133
131 void InputMethodMus::UpdateTextInputType() { 134 void InputMethodMus::UpdateTextInputType() {
132 ui::TextInputType type = GetTextInputType(); 135 ui::TextInputType type = GetTextInputType();
133 mojo::TextInputStatePtr state = mojo::TextInputState::New(); 136 mojo::TextInputStatePtr state = mojo::TextInputState::New();
134 state->type = mojo::ConvertTo<mojo::TextInputType>(type); 137 state->type = mojo::ConvertTo<mojo::TextInputType>(type);
135 if (window_) { 138 if (window_) {
136 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); 139 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_);
137 if (type != ui::TEXT_INPUT_TYPE_NONE) 140 if (type != ui::TEXT_INPUT_TYPE_NONE)
138 window_impl_mus->SetImeVisibility(true, std::move(state)); 141 window_impl_mus->SetImeVisibility(true, std::move(state));
(...skipping 19 matching lines...) Expand all
158 event_result = EventResult::HANDLED; 161 event_result = EventResult::HANDLED;
159 } 162 }
160 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is 163 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is
161 // called instead of the version which provides a callback. In mus+ash we 164 // called instead of the version which provides a callback. In mus+ash we
162 // use the version with callback, but some unittests use the standard form. 165 // use the version with callback, but some unittests use the standard form.
163 if (ack_callback) 166 if (ack_callback)
164 ack_callback->Run(event_result); 167 ack_callback->Run(event_result);
165 } 168 }
166 169
167 } // namespace aura 170 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/input_method_mus.h ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698