| 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 "components/mus/public/cpp/window.h" |
| 8 #include "components/mus/public/cpp/window_tree_connection.h" |
| 9 #include "content/browser/mojo/mojo_shell_client_host.h" |
| 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" | 11 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 12 #include "content/common/render_widget_window_tree_client_factory.mojom.h" |
| 13 #include "content/public/common/mojo_shell_connection.h" |
| 14 #include "mojo/application/public/cpp/application_impl.h" |
| 8 | 15 |
| 9 namespace blink { | 16 namespace blink { |
| 10 struct WebScreenInfo; | 17 struct WebScreenInfo; |
| 11 } | 18 } |
| 12 | 19 |
| 13 namespace content { | 20 namespace content { |
| 14 | 21 |
| 15 RenderWidgetHostViewMus::RenderWidgetHostViewMus( | 22 RenderWidgetHostViewMus::RenderWidgetHostViewMus( |
| 23 mus::Window* parent_window, |
| 16 RenderWidgetHostImpl* host, | 24 RenderWidgetHostImpl* host, |
| 17 base::WeakPtr<RenderWidgetHostViewBase> platform_view) | 25 base::WeakPtr<RenderWidgetHostViewBase> platform_view) |
| 18 : host_(host), platform_view_(platform_view) { | 26 : host_(host), platform_view_(platform_view) { |
| 27 DCHECK(parent_window); |
| 28 mus::Window* window = parent_window->connection()->NewWindow(); |
| 29 window->SetVisible(true); |
| 30 window->SetBounds(gfx::Rect(300, 300)); |
| 31 parent_window->AddChild(window); |
| 32 window_.reset(new mus::ScopedWindowPtr(window)); |
| 19 host_->SetView(this); | 33 host_->SetView(this); |
| 34 |
| 35 // Connect to the renderer, pass it a WindowTreeClient interface request |
| 36 // and embed that client inside our mus window. |
| 37 std::string url = GetMojoApplicationInstanceURL(host_->GetProcess()); |
| 38 mojom::RenderWidgetWindowTreeClientFactoryPtr factory; |
| 39 MojoShellConnection::Get()->GetApplication()->ConnectToService(url, &factory); |
| 40 |
| 41 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 42 factory->CreateWindowTreeClientForRenderWidget( |
| 43 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client)); |
| 44 window_->window()->Embed(window_tree_client.Pass()); |
| 20 } | 45 } |
| 21 | 46 |
| 22 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} | 47 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} |
| 23 | 48 |
| 24 void RenderWidgetHostViewMus::Show() { | 49 void RenderWidgetHostViewMus::Show() { |
| 25 // TODO(fsamuel): Update visibility in Mus. | 50 // TODO(fsamuel): Update visibility in Mus. |
| 26 // There is some interstitial complexity that we'll need to figure out here. | 51 // There is some interstitial complexity that we'll need to figure out here. |
| 27 host_->WasShown(ui::LatencyInfo()); | 52 host_->WasShown(ui::LatencyInfo()); |
| 28 } | 53 } |
| 29 | 54 |
| 30 void RenderWidgetHostViewMus::Hide() { | 55 void RenderWidgetHostViewMus::Hide() { |
| 31 host_->WasHidden(); | 56 host_->WasHidden(); |
| 32 } | 57 } |
| 33 | 58 |
| 34 bool RenderWidgetHostViewMus::IsShowing() { | 59 bool RenderWidgetHostViewMus::IsShowing() { |
| 35 return !host_->is_hidden(); | 60 return !host_->is_hidden(); |
| 36 } | 61 } |
| 37 | 62 |
| 38 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { | 63 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { |
| 39 size_ = size; | 64 size_ = size; |
| 65 window_->window()->SetBounds(gfx::Rect(size)); |
| 40 host_->WasResized(); | 66 host_->WasResized(); |
| 41 } | 67 } |
| 42 | 68 |
| 43 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { | 69 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { |
| 44 SetSize(rect.size()); | 70 SetSize(rect.size()); |
| 45 } | 71 } |
| 46 | 72 |
| 47 void RenderWidgetHostViewMus::Focus() { | 73 void RenderWidgetHostViewMus::Focus() { |
| 48 // TODO(fsamuel): Request focus for the associated Mus::Window | 74 // TODO(fsamuel): Request focus for the associated Mus::Window |
| 49 // We need to be careful how we propagate focus as we navigate to and | 75 // We need to be careful how we propagate focus as we navigate to and |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( | 296 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( |
| 271 gfx::NativeViewAccessible accessible_parent) {} | 297 gfx::NativeViewAccessible accessible_parent) {} |
| 272 | 298 |
| 273 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() | 299 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() |
| 274 const { | 300 const { |
| 275 return gfx::NativeViewId(); | 301 return gfx::NativeViewId(); |
| 276 } | 302 } |
| 277 #endif | 303 #endif |
| 278 | 304 |
| 279 } // namespace content | 305 } // namespace content |
| OLD | NEW |