| 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 "content/browser/renderer_host/render_widget_host_view_mus.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mus.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "components/mus/public/cpp/property_type_converters.h" | 10 #include "components/mus/public/cpp/property_type_converters.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/aura/client/screen_position_client.h" | 21 #include "ui/aura/client/screen_position_client.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| 26 struct WebScreenInfo; | 26 struct WebScreenInfo; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 namespace { |
| 32 |
| 33 void OnEventAck(bool handled) {} |
| 34 |
| 35 } // namespace |
| 36 |
| 31 RenderWidgetHostViewMus::RenderWidgetHostViewMus(mus::Window* parent_window, | 37 RenderWidgetHostViewMus::RenderWidgetHostViewMus(mus::Window* parent_window, |
| 32 RenderWidgetHostImpl* host) | 38 RenderWidgetHostImpl* host) |
| 33 : host_(host), aura_window_(nullptr) { | 39 : host_(host), aura_window_(nullptr), weak_factory_(this) { |
| 34 DCHECK(parent_window); | 40 DCHECK(parent_window); |
| 35 mus::Window* window = parent_window->window_tree()->NewWindow(); | 41 mus::Window* window = parent_window->window_tree()->NewWindow(); |
| 36 window->SetVisible(true); | 42 window->SetVisible(true); |
| 37 window->SetBounds(gfx::Rect(300, 300)); | 43 window->SetBounds(gfx::Rect(300, 300)); |
| 38 window->set_input_event_handler(this); | 44 window->set_input_event_handler(this); |
| 39 parent_window->AddChild(window); | 45 parent_window->AddChild(window); |
| 40 mus_window_.reset(new mus::ScopedWindowPtr(window)); | 46 mus_window_.reset(new mus::ScopedWindowPtr(window)); |
| 41 host_->SetView(this); | 47 host_->SetView(this); |
| 42 | 48 |
| 43 // Connect to the renderer, pass it a WindowTreeClient interface request | 49 // Connect to the renderer, pass it a WindowTreeClient interface request |
| 44 // and embed that client inside our mus window. | 50 // and embed that client inside our mus window. |
| 45 mojom::RenderWidgetWindowTreeClientFactoryPtr factory; | 51 mojom::RenderWidgetWindowTreeClientFactoryPtr factory; |
| 46 host_->GetProcess()->GetChildConnection()->GetInterface(&factory); | 52 host_->GetProcess()->GetChildConnection()->GetInterface(&factory); |
| 47 | 53 |
| 48 mus::mojom::WindowTreeClientPtr window_tree_client; | 54 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 49 factory->CreateWindowTreeClientForRenderWidget( | 55 factory->CreateWindowTreeClientForRenderWidget( |
| 50 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client)); | 56 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client)); |
| 51 mus_window_->window()->Embed(std::move(window_tree_client), | 57 mus_window_->window()->Embed(std::move(window_tree_client), |
| 52 mus::mojom::kEmbedFlagEmbedderInterceptsEvents); | 58 base::Bind(&RenderWidgetHostViewMus::OnEmbed, |
| 59 weak_factory_.GetWeakPtr()), |
| 60 mus::mojom::kEmbedFlagEmbedderInterceptsEvents); |
| 53 } | 61 } |
| 54 | 62 |
| 55 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} | 63 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} |
| 56 | 64 |
| 57 void RenderWidgetHostViewMus::InternalSetBounds(const gfx::Rect& rect) { | 65 void RenderWidgetHostViewMus::InternalSetBounds(const gfx::Rect& rect) { |
| 58 aura_window_->SetBounds(rect); | 66 aura_window_->SetBounds(rect); |
| 59 gfx::Rect bounds = aura_window_->GetBoundsInRootWindow(); | 67 gfx::Rect bounds = aura_window_->GetBoundsInRootWindow(); |
| 60 mus_window_->window()->SetBounds(bounds); | 68 mus_window_->window()->SetBounds(bounds); |
| 61 host_->WasResized(); | 69 host_->WasResized(); |
| 62 } | 70 } |
| 63 | 71 |
| 72 void X() { |
| 73 } |
| 74 |
| 75 void RenderWidgetHostViewMus::OnEmbed( |
| 76 bool success, |
| 77 mus::mojom::InputEventHandlerPtr handler) { |
| 78 DCHECK(success); |
| 79 LOG(ERROR) << "Binding"; |
| 80 event_handler_ = std::move(handler); |
| 81 event_handler_.set_connection_error_handler(base::Bind(&X)); |
| 82 } |
| 83 |
| 64 void RenderWidgetHostViewMus::Show() { | 84 void RenderWidgetHostViewMus::Show() { |
| 65 // TODO(fsamuel): Update visibility in Mus. | 85 // TODO(fsamuel): Update visibility in Mus. |
| 66 // There is some interstitial complexity that we'll need to figure out here. | 86 // There is some interstitial complexity that we'll need to figure out here. |
| 67 host_->WasShown(ui::LatencyInfo()); | 87 host_->WasShown(ui::LatencyInfo()); |
| 68 } | 88 } |
| 69 | 89 |
| 70 void RenderWidgetHostViewMus::Hide() { | 90 void RenderWidgetHostViewMus::Hide() { |
| 71 host_->WasHidden(); | 91 host_->WasHidden(); |
| 72 } | 92 } |
| 73 | 93 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 void RenderWidgetHostViewMus::UnlockCompositingSurface() { | 328 void RenderWidgetHostViewMus::UnlockCompositingSurface() { |
| 309 NOTIMPLEMENTED(); | 329 NOTIMPLEMENTED(); |
| 310 } | 330 } |
| 311 | 331 |
| 312 void RenderWidgetHostViewMus::OnWindowInputEvent( | 332 void RenderWidgetHostViewMus::OnWindowInputEvent( |
| 313 mus::Window* window, | 333 mus::Window* window, |
| 314 const ui::Event& event, | 334 const ui::Event& event, |
| 315 std::unique_ptr<base::Callback<void(mus::mojom::EventResult)>>* | 335 std::unique_ptr<base::Callback<void(mus::mojom::EventResult)>>* |
| 316 ack_callback) { | 336 ack_callback) { |
| 317 // TODO(sad): Dispatch |event| to the RenderWidgetHost. | 337 // TODO(sad): Dispatch |event| to the RenderWidgetHost. |
| 338 std::unique_ptr<ui::Event> send; |
| 339 if (event.IsMouseEvent()) { |
| 340 send = ui::Event::Clone( |
| 341 ui::PointerEvent(static_cast<const ui::MouseEvent&>(event))); |
| 342 } else { |
| 343 send = ui::Event::Clone(event); |
| 344 } |
| 345 LOG(ERROR) << "X: " << window->server_id() << " vs. " |
| 346 << mus_window_->window()->server_id(); |
| 347 event_handler_->OnInputEvent(mus_window_->window()->server_id(), |
| 348 std::move(send), |
| 349 base::Bind(&OnEventAck)); |
| 350 (*ack_callback)->Run(mus::mojom::EventResult::HANDLED); |
| 351 ack_callback->reset(); |
| 318 } | 352 } |
| 319 | 353 |
| 320 } // namespace content | 354 } // namespace content |
| OLD | NEW |