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 "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_process_client.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 EmbedClient(); | |
| 20 } | 36 } |
| 21 | 37 |
| 22 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} | 38 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} |
| 23 | 39 |
| 24 void RenderWidgetHostViewMus::Show() { | 40 void RenderWidgetHostViewMus::Show() { |
| 25 // TODO(fsamuel): Update visibility in Mus. | 41 // TODO(fsamuel): Update visibility in Mus. |
| 26 // There is some interstitial complexity that we'll need to figure out here. | 42 // There is some interstitial complexity that we'll need to figure out here. |
| 27 host_->WasShown(ui::LatencyInfo()); | 43 host_->WasShown(ui::LatencyInfo()); |
| 28 } | 44 } |
| 29 | 45 |
| 30 void RenderWidgetHostViewMus::Hide() { | 46 void RenderWidgetHostViewMus::Hide() { |
| 31 host_->WasHidden(); | 47 host_->WasHidden(); |
| 32 } | 48 } |
| 33 | 49 |
| 34 bool RenderWidgetHostViewMus::IsShowing() { | 50 bool RenderWidgetHostViewMus::IsShowing() { |
| 35 return !host_->is_hidden(); | 51 return !host_->is_hidden(); |
| 36 } | 52 } |
| 37 | 53 |
| 38 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { | 54 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { |
| 39 size_ = size; | 55 size_ = size; |
| 56 window_->window()->SetBounds(gfx::Rect(size)); | |
| 40 host_->WasResized(); | 57 host_->WasResized(); |
| 41 } | 58 } |
| 42 | 59 |
| 43 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { | 60 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { |
| 44 SetSize(rect.size()); | 61 SetSize(rect.size()); |
| 45 } | 62 } |
| 46 | 63 |
| 47 void RenderWidgetHostViewMus::Focus() { | 64 void RenderWidgetHostViewMus::Focus() { |
| 48 // TODO(fsamuel): Request focus for the associated Mus::Window | 65 // TODO(fsamuel): Request focus for the associated Mus::Window |
| 49 // We need to be careful how we propagate focus as we navigate to and | 66 // We need to be careful how we propagate focus as we navigate to and |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 101 |
| 85 base::string16 RenderWidgetHostViewMus::GetSelectedText() const { | 102 base::string16 RenderWidgetHostViewMus::GetSelectedText() const { |
| 86 return platform_view_->GetSelectedText(); | 103 return platform_view_->GetSelectedText(); |
| 87 } | 104 } |
| 88 | 105 |
| 89 void RenderWidgetHostViewMus::SetTooltipText( | 106 void RenderWidgetHostViewMus::SetTooltipText( |
| 90 const base::string16& tooltip_text) { | 107 const base::string16& tooltip_text) { |
| 91 // TOOD(fsamuel): Ask window manager for tooltip? | 108 // TOOD(fsamuel): Ask window manager for tooltip? |
| 92 } | 109 } |
| 93 | 110 |
| 111 void RenderWidgetHostViewMus::EmbedClient() { | |
| 112 std::string url = GetMojoApplicationInstanceURL(host_->GetProcess()); | |
|
Ben Goodger (Google)
2015/11/25 04:07:28
just put this in the ctor since no one else calls
Fady Samuel
2015/11/25 17:45:52
Done.
| |
| 113 mojom::RenderProcessClientPtr render_process_client; | |
| 114 MojoShellConnection::Get()->GetApplication()->ConnectToService( | |
| 115 url, &render_process_client); | |
| 116 | |
| 117 mus::mojom::WindowTreeClientPtr window_tree_client; | |
| 118 render_process_client->OnRenderWidgetHostViewCreated( | |
| 119 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client)); | |
| 120 window_->window()->Embed(window_tree_client.Pass()); | |
| 121 } | |
| 122 | |
| 94 void RenderWidgetHostViewMus::InitAsChild(gfx::NativeView parent_view) { | 123 void RenderWidgetHostViewMus::InitAsChild(gfx::NativeView parent_view) { |
| 95 platform_view_->InitAsChild(parent_view); | 124 platform_view_->InitAsChild(parent_view); |
| 96 } | 125 } |
| 97 | 126 |
| 98 RenderWidgetHost* RenderWidgetHostViewMus::GetRenderWidgetHost() const { | 127 RenderWidgetHost* RenderWidgetHostViewMus::GetRenderWidgetHost() const { |
| 99 return host_; | 128 return host_; |
| 100 } | 129 } |
| 101 | 130 |
| 102 void RenderWidgetHostViewMus::InitAsPopup( | 131 void RenderWidgetHostViewMus::InitAsPopup( |
| 103 RenderWidgetHostView* parent_host_view, | 132 RenderWidgetHostView* parent_host_view, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( | 299 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( |
| 271 gfx::NativeViewAccessible accessible_parent) {} | 300 gfx::NativeViewAccessible accessible_parent) {} |
| 272 | 301 |
| 273 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() | 302 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() |
| 274 const { | 303 const { |
| 275 return gfx::NativeViewId(); | 304 return gfx::NativeViewId(); |
| 276 } | 305 } |
| 277 #endif | 306 #endif |
| 278 | 307 |
| 279 } // namespace content | 308 } // namespace content |
| OLD | NEW |