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

Side by Side Diff: blimp/engine/session/blimp_engine_session.cc

Issue 1779673003: Added network components for blimp text input feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added proto coverters for TextInputType Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 "blimp/engine/session/blimp_engine_session.h" 5 #include "blimp/engine/session/blimp_engine_session.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 14 matching lines...) Expand all
25 #include "blimp/net/engine_connection_manager.h" 25 #include "blimp/net/engine_connection_manager.h"
26 #include "blimp/net/null_blimp_message_processor.h" 26 #include "blimp/net/null_blimp_message_processor.h"
27 #include "blimp/net/tcp_engine_transport.h" 27 #include "blimp/net/tcp_engine_transport.h"
28 #include "blimp/net/thread_pipe_manager.h" 28 #include "blimp/net/thread_pipe_manager.h"
29 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
32 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/render_widget_host.h" 34 #include "content/public/browser/render_widget_host.h"
35 #include "content/public/browser/render_widget_host_view.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "net/base/ip_address.h" 37 #include "net/base/ip_address.h"
37 #include "net/base/net_errors.h" 38 #include "net/base/net_errors.h"
38 #include "ui/aura/client/default_capture_client.h" 39 #include "ui/aura/client/default_capture_client.h"
39 #include "ui/aura/env.h" 40 #include "ui/aura/env.h"
40 #include "ui/aura/window.h" 41 #include "ui/aura/window.h"
41 #include "ui/aura/window_tree_host.h" 42 #include "ui/aura/window_tree_host.h"
43 #include "ui/base/ime/input_method.h"
44 #include "ui/base/ime/text_input_client.h"
42 #include "ui/gfx/geometry/size.h" 45 #include "ui/gfx/geometry/size.h"
43 #include "ui/wm/core/base_focus_rules.h" 46 #include "ui/wm/core/base_focus_rules.h"
44 #include "ui/wm/core/default_activation_client.h" 47 #include "ui/wm/core/default_activation_client.h"
45 #include "ui/wm/core/focus_controller.h" 48 #include "ui/wm/core/focus_controller.h"
46 49
47 50
48 namespace blimp { 51 namespace blimp {
49 namespace engine { 52 namespace engine {
50 namespace { 53 namespace {
51 54
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 DCHECK(engine_config_); 189 DCHECK(engine_config_);
187 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor, 190 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor,
188 gfx::Size(kDefaultDisplayWidth, 191 gfx::Size(kDefaultDisplayWidth,
189 kDefaultDisplayHeight)); 192 kDefaultDisplayHeight));
190 render_widget_feature_.SetDelegate(kDummyTabId, this); 193 render_widget_feature_.SetDelegate(kDummyTabId, this);
191 } 194 }
192 195
193 BlimpEngineSession::~BlimpEngineSession() { 196 BlimpEngineSession::~BlimpEngineSession() {
194 render_widget_feature_.RemoveDelegate(kDummyTabId); 197 render_widget_feature_.RemoveDelegate(kDummyTabId);
195 198
199 window_tree_host_->GetInputMethod()->RemoveObserver(this);
200
196 // Ensure that all WebContents are torn down first, since teardown will 201 // Ensure that all WebContents are torn down first, since teardown will
197 // trigger RenderViewDeleted callbacks to their observers. 202 // trigger RenderViewDeleted callbacks to their observers.
198 web_contents_.reset(); 203 web_contents_.reset();
199 204
200 // Safely delete network components on the IO thread. 205 // Safely delete network components on the IO thread.
201 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, 206 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
202 net_components_.release()); 207 net_components_.release());
203 } 208 }
204 209
205 void BlimpEngineSession::Initialize() { 210 void BlimpEngineSession::Initialize() {
206 DCHECK(!gfx::Screen::GetScreen()); 211 DCHECK(!gfx::Screen::GetScreen());
207 gfx::Screen::SetScreenInstance(screen_.get()); 212 gfx::Screen::SetScreenInstance(screen_.get());
208 213
209 context_factory_.reset(new BlimpUiContextFactory()); 214 context_factory_.reset(new BlimpUiContextFactory());
210 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); 215 aura::Env::GetInstance()->set_context_factory(context_factory_.get());
211 window_tree_host_.reset(new BlimpWindowTreeHost()); 216 window_tree_host_.reset(new BlimpWindowTreeHost());
212 217
213 screen_->set_window_tree_host(window_tree_host_.get()); 218 screen_->set_window_tree_host(window_tree_host_.get());
214 window_tree_host_->InitHost(); 219 window_tree_host_->InitHost();
215 window_tree_host_->window()->SetLayoutManager( 220 window_tree_host_->window()->SetLayoutManager(
216 new BlimpLayoutManager(window_tree_host_->window())); 221 new BlimpLayoutManager(window_tree_host_->window()));
217 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); 222 focus_client_.reset(new wm::FocusController(new FocusRulesImpl));
218 aura::client::SetFocusClient(window_tree_host_->window(), 223 aura::client::SetFocusClient(window_tree_host_->window(),
219 focus_client_.get()); 224 focus_client_.get());
220 aura::client::SetActivationClient(window_tree_host_->window(), 225 aura::client::SetActivationClient(window_tree_host_->window(),
221 focus_client_.get()); 226 focus_client_.get());
222 capture_client_.reset( 227 capture_client_.reset(
223 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 228 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
224 229
230 window_tree_host_->GetInputMethod()->AddObserver(this);
231
225 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size())); 232 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size()));
226 233
227 RegisterFeatures(); 234 RegisterFeatures();
228 235
229 // Initialize must only be posted after the RegisterFeature calls have 236 // Initialize must only be posted after the RegisterFeature calls have
230 // completed. 237 // completed.
231 content::BrowserThread::PostTask( 238 content::BrowserThread::PostTask(
232 content::BrowserThread::IO, FROM_HERE, 239 content::BrowserThread::IO, FROM_HERE,
233 base::Bind(&EngineNetworkComponents::Initialize, 240 base::Bind(&EngineNetworkComponents::Initialize,
234 base::Unretained(net_components_.get()), 241 base::Unretained(net_components_.get()),
(...skipping 15 matching lines...) Expand all
250 thread_pipe_manager_->RegisterFeature(BlimpMessage::NAVIGATION, this); 257 thread_pipe_manager_->RegisterFeature(BlimpMessage::NAVIGATION, this);
251 render_widget_feature_.set_render_widget_message_sender( 258 render_widget_feature_.set_render_widget_message_sender(
252 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET, 259 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET,
253 &render_widget_feature_)); 260 &render_widget_feature_));
254 render_widget_feature_.set_input_message_sender( 261 render_widget_feature_.set_input_message_sender(
255 thread_pipe_manager_->RegisterFeature(BlimpMessage::INPUT, 262 thread_pipe_manager_->RegisterFeature(BlimpMessage::INPUT,
256 &render_widget_feature_)); 263 &render_widget_feature_));
257 render_widget_feature_.set_compositor_message_sender( 264 render_widget_feature_.set_compositor_message_sender(
258 thread_pipe_manager_->RegisterFeature(BlimpMessage::COMPOSITOR, 265 thread_pipe_manager_->RegisterFeature(BlimpMessage::COMPOSITOR,
259 &render_widget_feature_)); 266 &render_widget_feature_));
267 render_widget_feature_.set_ime_message_sender(
268 thread_pipe_manager_->RegisterFeature(BlimpMessage::IME,
269 &render_widget_feature_));
260 } 270 }
261 271
262 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) { 272 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) {
263 DVLOG(1) << "Create tab " << target_tab_id; 273 DVLOG(1) << "Create tab " << target_tab_id;
264 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). 274 // TODO(haibinlu): Support more than one active WebContents (crbug/547231).
265 if (web_contents_) { 275 if (web_contents_) {
266 DLOG(WARNING) << "Tab " << target_tab_id << " already existed"; 276 DLOG(WARNING) << "Tab " << target_tab_id << " already existed";
267 return false; 277 return false;
268 } 278 }
269 279
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 render_widget_host->ForwardGestureEvent(*event); 344 render_widget_host->ForwardGestureEvent(*event);
335 } 345 }
336 346
337 void BlimpEngineSession::OnCompositorMessageReceived( 347 void BlimpEngineSession::OnCompositorMessageReceived(
338 content::RenderWidgetHost* render_widget_host, 348 content::RenderWidgetHost* render_widget_host,
339 const std::vector<uint8_t>& message) { 349 const std::vector<uint8_t>& message) {
340 350
341 render_widget_host->HandleCompositorProto(message); 351 render_widget_host->HandleCompositorProto(message);
342 } 352 }
343 353
354 void BlimpEngineSession::OnTextInputTypeChanged(
355 const ui::TextInputClient* client) {}
356
357 void BlimpEngineSession::OnFocus() {}
358
359 void BlimpEngineSession::OnBlur() {}
360
361 void BlimpEngineSession::OnCaretBoundsChanged(
362 const ui::TextInputClient* client) {}
363
364 // Called when either:
365 // - the TextInputClient is changed (e.g. by a change of focus)
366 // - the TextInputType of the TextInputClient changes
David Trainor- moved to gerrit 2016/03/17 21:53:29 Add a todo to propagate the new type to the client
367 void BlimpEngineSession::OnTextInputStateChanged(
368 const ui::TextInputClient* client) {
369 ui::TextInputType type =
370 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
371
372 // Hide IME if text input is out of focus
David Trainor- moved to gerrit 2016/03/17 21:53:29 . at the end.
373 if (type == ui::TEXT_INPUT_TYPE_NONE)
haibinlu 2016/03/17 18:59:46 does ui::TEXT_INPUT_TYPE_NONE mean text input is o
shaktisahu 2016/03/18 19:08:06 Yes, text input type changes to ui::TEXT_INPUT_TYP
haibinlu 2016/03/18 19:53:49 can you add this to the comment?
374 render_widget_feature_.SendHideImeRequest(
375 kDummyTabId,
376 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(),
Khushal 2016/03/17 10:02:45 RenderWidgetHostView can be null. Check that befor
377 client);
Khushal 2016/03/17 10:02:45 Do you need to pass the client in this method? Loo
378 }
haibinlu 2016/03/17 18:59:46 what happens to other types? shall you just show t
shaktisahu 2016/03/18 19:08:06 For other text input types, I would receive a call
haibinlu 2016/03/18 19:53:49 Does OnShowImeIFNeeded cover more cases for showin
shaktisahu 2016/03/22 19:44:18 I would think so, although the api description for
379
380 void BlimpEngineSession::OnInputMethodDestroyed(
381 const ui::InputMethod* input_method) {}
382
383 // Called when a user input should trigger showing the IME.
384 void BlimpEngineSession::OnShowImeIfNeeded() {
385 render_widget_feature_.SendShowImeRequest(
386 kDummyTabId,
387 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(),
388 window_tree_host_->GetInputMethod()->GetTextInputClient());
Khushal 2016/03/17 10:02:45 The text input client can also be null. If the exp
389 }
390
344 void BlimpEngineSession::ProcessMessage( 391 void BlimpEngineSession::ProcessMessage(
345 scoped_ptr<BlimpMessage> message, 392 scoped_ptr<BlimpMessage> message,
346 const net::CompletionCallback& callback) { 393 const net::CompletionCallback& callback) {
347 DCHECK(!callback.is_null()); 394 DCHECK(!callback.is_null());
348 DCHECK(message->type() == BlimpMessage::TAB_CONTROL || 395 DCHECK(message->type() == BlimpMessage::TAB_CONTROL ||
349 message->type() == BlimpMessage::NAVIGATION); 396 message->type() == BlimpMessage::NAVIGATION);
350 397
351 net::Error result = net::OK; 398 net::Error result = net::OK;
352 if (message->type() == BlimpMessage::TAB_CONTROL) { 399 if (message->type() == BlimpMessage::TAB_CONTROL) {
353 switch (message->tab_control().type()) { 400 switch (message->tab_control().type()) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 557
511 aura::Window* parent = window_tree_host_->window(); 558 aura::Window* parent = window_tree_host_->window();
512 aura::Window* content = web_contents_->GetNativeView(); 559 aura::Window* content = web_contents_->GetNativeView();
513 if (!parent->Contains(content)) 560 if (!parent->Contains(content))
514 parent->AddChild(content); 561 parent->AddChild(content);
515 content->Show(); 562 content->Show();
516 } 563 }
517 564
518 } // namespace engine 565 } // namespace engine
519 } // namespace blimp 566 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698