Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "blimp/net/blimp_stats.h" | 33 #include "blimp/net/blimp_stats.h" |
| 34 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" | 34 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" |
| 35 #include "blimp/net/blob_channel/helium_blob_sender_delegate.h" | 35 #include "blimp/net/blob_channel/helium_blob_sender_delegate.h" |
| 36 #include "blimp/net/browser_connection_handler.h" | 36 #include "blimp/net/browser_connection_handler.h" |
| 37 #include "blimp/net/common.h" | 37 #include "blimp/net/common.h" |
| 38 #include "blimp/net/engine_authentication_handler.h" | 38 #include "blimp/net/engine_authentication_handler.h" |
| 39 #include "blimp/net/engine_connection_manager.h" | 39 #include "blimp/net/engine_connection_manager.h" |
| 40 #include "blimp/net/null_blimp_message_processor.h" | 40 #include "blimp/net/null_blimp_message_processor.h" |
| 41 #include "blimp/net/tcp_engine_transport.h" | 41 #include "blimp/net/tcp_engine_transport.h" |
| 42 #include "blimp/net/thread_pipe_manager.h" | 42 #include "blimp/net/thread_pipe_manager.h" |
| 43 #include "content/browser/web_contents/web_contents_impl.h" | |
| 43 #include "content/public/browser/browser_context.h" | 44 #include "content/public/browser/browser_context.h" |
| 44 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 45 #include "content/public/browser/navigation_controller.h" | 46 #include "content/public/browser/navigation_controller.h" |
| 46 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
| 47 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
| 48 #include "content/public/browser/render_widget_host.h" | 49 #include "content/public/browser/render_widget_host.h" |
| 49 #include "content/public/browser/render_widget_host_view.h" | 50 #include "content/public/browser/render_widget_host_view.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "device/geolocation/geolocation_delegate.h" | 52 #include "device/geolocation/geolocation_delegate.h" |
| 52 #include "device/geolocation/geolocation_provider.h" | 53 #include "device/geolocation/geolocation_provider.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 base::MakeUnique<InMemoryBlobCache>(), std::move(helium_blob_delegate)); | 244 base::MakeUnique<InMemoryBlobCache>(), std::move(helium_blob_delegate)); |
| 244 blob_channel_sender_weak_factory_ = | 245 blob_channel_sender_weak_factory_ = |
| 245 base::MakeUnique<base::WeakPtrFactory<BlobChannelSenderImpl>>( | 246 base::MakeUnique<base::WeakPtrFactory<BlobChannelSenderImpl>>( |
| 246 blob_channel_sender_.get()); | 247 blob_channel_sender_.get()); |
| 247 | 248 |
| 248 device::GeolocationProvider::SetGeolocationDelegate( | 249 device::GeolocationProvider::SetGeolocationDelegate( |
| 249 geolocation_feature_.CreateGeolocationDelegate()); | 250 geolocation_feature_.CreateGeolocationDelegate()); |
| 250 } | 251 } |
| 251 | 252 |
| 252 BlimpEngineSession::~BlimpEngineSession() { | 253 BlimpEngineSession::~BlimpEngineSession() { |
| 253 window_tree_host_->GetInputMethod()->RemoveObserver(this); | |
| 254 | |
| 255 // Ensure that all tabs are torn down first, since teardown will | 254 // Ensure that all tabs are torn down first, since teardown will |
| 256 // trigger RenderViewDeleted callbacks to their observers, which will in turn | 255 // trigger RenderViewDeleted callbacks to their observers, which will in turn |
| 257 // send messages to net_components_, which is already deleted due to the line | 256 // send messages to net_components_, which is already deleted due to the line |
| 258 // below. | 257 // below. |
| 259 tab_.reset(); | 258 tab_.reset(); |
| 260 | 259 |
| 261 // Safely delete network components on the IO thread. | 260 // Safely delete network components on the IO thread. |
| 262 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, | 261 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, |
| 263 net_components_.release()); | 262 net_components_.release()); |
| 264 } | 263 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 277 aura::client::SetFocusClient(window_tree_host_->window(), | 276 aura::client::SetFocusClient(window_tree_host_->window(), |
| 278 focus_client_.get()); | 277 focus_client_.get()); |
| 279 aura::client::SetActivationClient(window_tree_host_->window(), | 278 aura::client::SetActivationClient(window_tree_host_->window(), |
| 280 focus_client_.get()); | 279 focus_client_.get()); |
| 281 capture_client_.reset( | 280 capture_client_.reset( |
| 282 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 281 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
| 283 | 282 |
| 284 window_tree_client_.reset( | 283 window_tree_client_.reset( |
| 285 new BlimpWindowTreeClient(window_tree_host_->window())); | 284 new BlimpWindowTreeClient(window_tree_host_->window())); |
| 286 | 285 |
| 287 window_tree_host_->GetInputMethod()->AddObserver(this); | |
| 288 | |
| 289 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size())); | 286 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size())); |
| 290 | 287 |
| 291 RegisterFeatures(); | 288 RegisterFeatures(); |
| 292 | 289 |
| 293 // Initialize must only be posted after the RegisterFeature calls have | 290 // Initialize must only be posted after the RegisterFeature calls have |
| 294 // completed. | 291 // completed. |
| 295 content::BrowserThread::PostTask( | 292 content::BrowserThread::PostTask( |
| 296 content::BrowserThread::IO, FROM_HERE, | 293 content::BrowserThread::IO, FROM_HERE, |
| 297 base::Bind(&EngineNetworkComponents::Initialize, | 294 base::Bind(&EngineNetworkComponents::Initialize, |
| 298 base::Unretained(net_components_.get()), | 295 base::Unretained(net_components_.get()), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 const gfx::Size& size) { | 371 const gfx::Size& size) { |
| 375 DVLOG(1) << "Resize to " << size.ToString() << ", " << device_pixel_ratio; | 372 DVLOG(1) << "Resize to " << size.ToString() << ", " << device_pixel_ratio; |
| 376 screen_->UpdateDisplayScaleAndSize(device_pixel_ratio, size); | 373 screen_->UpdateDisplayScaleAndSize(device_pixel_ratio, size); |
| 377 window_tree_host_->SetBounds(gfx::Rect(size)); | 374 window_tree_host_->SetBounds(gfx::Rect(size)); |
| 378 if (tab_) { | 375 if (tab_) { |
| 379 tab_->Resize(device_pixel_ratio, | 376 tab_->Resize(device_pixel_ratio, |
| 380 screen_->GetPrimaryDisplay().bounds().size()); | 377 screen_->GetPrimaryDisplay().bounds().size()); |
| 381 } | 378 } |
| 382 } | 379 } |
| 383 | 380 |
| 384 void BlimpEngineSession::OnTextInputTypeChanged( | 381 void BlimpEngineSession::OnUpdateTextInputStateCalled( |
|
EhsanK
2016/09/28 16:14:11
I guess I see why you had to observe TextInputMana
shaktisahu
2016/09/28 20:17:23
I think I pipe this call to RenderWidgetHostDelega
EhsanK
2016/10/03 14:53:10
I too think going through the delegates is better.
| |
| 385 const ui::TextInputClient* client) {} | 382 content::TextInputManager* text_input_manager, |
| 383 content::RenderWidgetHostViewBase* updated_view, | |
| 384 bool did_update_state) { | |
| 385 const content::TextInputState* state = | |
| 386 text_input_manager->GetTextInputState(); | |
| 386 | 387 |
| 387 void BlimpEngineSession::OnFocus() {} | 388 if (!state) |
| 388 | |
| 389 void BlimpEngineSession::OnBlur() {} | |
| 390 | |
| 391 void BlimpEngineSession::OnCaretBoundsChanged( | |
| 392 const ui::TextInputClient* client) {} | |
| 393 | |
| 394 // Called when either: | |
| 395 // - the TextInputClient is changed (e.g. by a change of focus) | |
| 396 // - the TextInputType of the TextInputClient changes | |
| 397 void BlimpEngineSession::OnTextInputStateChanged( | |
| 398 const ui::TextInputClient* client) { | |
| 399 if (!tab_ || !tab_->web_contents()->GetRenderWidgetHostView()) | |
| 400 return; | 389 return; |
| 401 | 390 |
| 402 ui::TextInputType type = | 391 if (state->show_ime_if_needed) { |
| 403 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 392 render_widget_feature_.SendShowImeRequest( |
| 393 tab_->tab_id(), updated_view->GetRenderWidgetHost(), state); | |
|
EhsanK
2016/09/28 16:14:11
RWHV::GetRenderWidgetHost() may return nullptr. I
shaktisahu
2016/09/28 20:17:23
Ya, this is checked. The function will return 0 fo
EhsanK
2016/10/03 14:53:10
Acknowledged.
| |
| 394 } | |
| 404 | 395 |
| 405 // TODO(shaktisahu): Propagate the new type to the client. | 396 if (state->type == ui::TEXT_INPUT_TYPE_NONE) { |
| 406 // Hide IME, when text input is out of focus, i.e. if the text input type | |
| 407 // changes to ui::TEXT_INPUT_TYPE_NONE. For other text input types, | |
| 408 // OnShowImeIfNeeded is used instead to send show IME request to client. | |
| 409 if (type == ui::TEXT_INPUT_TYPE_NONE) | |
| 410 render_widget_feature_.SendHideImeRequest( | 397 render_widget_feature_.SendHideImeRequest( |
| 411 tab_->tab_id(), | 398 tab_->tab_id(), updated_view->GetRenderWidgetHost()); |
| 412 tab_->web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost()); | 399 } |
| 413 } | |
| 414 | |
| 415 void BlimpEngineSession::OnInputMethodDestroyed( | |
| 416 const ui::InputMethod* input_method) {} | |
| 417 | |
| 418 // Called when a user input should trigger showing the IME. | |
| 419 void BlimpEngineSession::OnShowImeIfNeeded() { | |
| 420 TRACE_EVENT0("blimp", "BlimpEngineSession::OnShowImeIfNeeded"); | |
| 421 if (!tab_ || !tab_->web_contents()->GetRenderWidgetHostView() || | |
| 422 !window_tree_host_->GetInputMethod()->GetTextInputClient()) | |
| 423 return; | |
| 424 | |
| 425 render_widget_feature_.SendShowImeRequest( | |
| 426 tab_->tab_id(), | |
| 427 tab_->web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost(), | |
| 428 window_tree_host_->GetInputMethod()->GetTextInputClient()); | |
| 429 } | 400 } |
| 430 | 401 |
| 431 void BlimpEngineSession::ProcessMessage( | 402 void BlimpEngineSession::ProcessMessage( |
| 432 std::unique_ptr<BlimpMessage> message, | 403 std::unique_ptr<BlimpMessage> message, |
| 433 const net::CompletionCallback& callback) { | 404 const net::CompletionCallback& callback) { |
| 434 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId", | 405 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId", |
| 435 message->target_tab_id()); | 406 message->target_tab_id()); |
| 436 DCHECK(!callback.is_null()); | 407 DCHECK(!callback.is_null()); |
| 437 DCHECK(BlimpMessage::kTabControl == message->feature_case() || | 408 DCHECK(BlimpMessage::kTabControl == message->feature_case() || |
| 438 BlimpMessage::kNavigation == message->feature_case()); | 409 BlimpMessage::kNavigation == message->feature_case()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 } | 492 } |
| 522 | 493 |
| 523 void BlimpEngineSession::RequestToLockMouse(content::WebContents* web_contents, | 494 void BlimpEngineSession::RequestToLockMouse(content::WebContents* web_contents, |
| 524 bool user_gesture, | 495 bool user_gesture, |
| 525 bool last_unlocked_by_target) { | 496 bool last_unlocked_by_target) { |
| 526 web_contents->GotResponseToLockMouseRequest(true); | 497 web_contents->GotResponseToLockMouseRequest(true); |
| 527 } | 498 } |
| 528 | 499 |
| 529 void BlimpEngineSession::CloseContents(content::WebContents* source) { | 500 void BlimpEngineSession::CloseContents(content::WebContents* source) { |
| 530 if (source == tab_->web_contents()) { | 501 if (source == tab_->web_contents()) { |
| 502 static_cast<content::WebContentsImpl*>(source) | |
| 503 ->GetTextInputManager() | |
| 504 ->RemoveObserver(this); | |
| 531 tab_.reset(); | 505 tab_.reset(); |
| 532 } | 506 } |
| 533 } | 507 } |
| 534 | 508 |
| 535 void BlimpEngineSession::ActivateContents(content::WebContents* contents) { | 509 void BlimpEngineSession::ActivateContents(content::WebContents* contents) { |
| 536 contents->GetRenderViewHost()->GetWidget()->Focus(); | 510 contents->GetRenderViewHost()->GetWidget()->Focus(); |
| 537 } | 511 } |
| 538 | 512 |
| 539 void BlimpEngineSession::ForwardCompositorProto( | 513 void BlimpEngineSession::ForwardCompositorProto( |
| 540 content::RenderWidgetHost* render_widget_host, | 514 content::RenderWidgetHost* render_widget_host, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 559 std::unique_ptr<content::WebContents> new_contents, | 533 std::unique_ptr<content::WebContents> new_contents, |
| 560 const int target_tab_id) { | 534 const int target_tab_id) { |
| 561 new_contents->SetDelegate(this); | 535 new_contents->SetDelegate(this); |
| 562 | 536 |
| 563 aura::Window* parent = window_tree_host_->window(); | 537 aura::Window* parent = window_tree_host_->window(); |
| 564 aura::Window* content = new_contents->GetNativeView(); | 538 aura::Window* content = new_contents->GetNativeView(); |
| 565 if (!parent->Contains(content)) | 539 if (!parent->Contains(content)) |
| 566 parent->AddChild(content); | 540 parent->AddChild(content); |
| 567 content->Show(); | 541 content->Show(); |
| 568 | 542 |
| 543 static_cast<content::WebContentsImpl*>(new_contents.get()) | |
| 544 ->GetTextInputManager() | |
| 545 ->AddObserver(this); | |
| 546 | |
| 569 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, | 547 tab_ = base::MakeUnique<Tab>(std::move(new_contents), target_tab_id, |
| 570 &render_widget_feature_, | 548 &render_widget_feature_, |
| 571 navigation_message_sender_.get()); | 549 navigation_message_sender_.get()); |
| 572 } | 550 } |
| 573 | 551 |
| 574 } // namespace engine | 552 } // namespace engine |
| 575 } // namespace blimp | 553 } // namespace blimp |
| OLD | NEW |