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/public/common/mojo_shell_connection.h" |
| 13 #include "mojo/application/public/cpp/application_impl.h" |
8 | 14 |
9 namespace blink { | 15 namespace blink { |
10 struct WebScreenInfo; | 16 struct WebScreenInfo; |
11 } | 17 } |
12 | 18 |
13 namespace content { | 19 namespace content { |
14 | 20 |
15 RenderWidgetHostViewMus::RenderWidgetHostViewMus( | 21 RenderWidgetHostViewMus::RenderWidgetHostViewMus( |
| 22 mus::Window* parent_window, |
16 RenderWidgetHostImpl* host, | 23 RenderWidgetHostImpl* host, |
17 base::WeakPtr<RenderWidgetHostViewBase> platform_view) | 24 base::WeakPtr<RenderWidgetHostViewBase> platform_view) |
18 : host_(host), platform_view_(platform_view) { | 25 : host_(host), platform_view_(platform_view) { |
| 26 DCHECK(parent_window); |
| 27 mus::Window* window = parent_window->connection()->NewWindow(); |
| 28 window->SetVisible(true); |
| 29 window->SetBounds(parent_window->bounds()); |
| 30 parent_window->AddChild(window); |
| 31 window_.reset(new mus::ScopedWindowPtr(window)); |
19 host_->SetView(this); | 32 host_->SetView(this); |
20 } | 33 } |
21 | 34 |
22 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} | 35 RenderWidgetHostViewMus::~RenderWidgetHostViewMus() {} |
23 | 36 |
24 void RenderWidgetHostViewMus::Show() { | 37 void RenderWidgetHostViewMus::Show() { |
25 // TODO(fsamuel): Update visibility in Mus. | 38 // TODO(fsamuel): Update visibility in Mus. |
26 // There is some interstitial complexity that we'll need to figure out here. | 39 // There is some interstitial complexity that we'll need to figure out here. |
27 host_->WasShown(ui::LatencyInfo()); | 40 host_->WasShown(ui::LatencyInfo()); |
28 } | 41 } |
29 | 42 |
30 void RenderWidgetHostViewMus::Hide() { | 43 void RenderWidgetHostViewMus::Hide() { |
31 host_->WasHidden(); | 44 host_->WasHidden(); |
32 } | 45 } |
33 | 46 |
34 bool RenderWidgetHostViewMus::IsShowing() { | 47 bool RenderWidgetHostViewMus::IsShowing() { |
35 return !host_->is_hidden(); | 48 return !host_->is_hidden(); |
36 } | 49 } |
37 | 50 |
38 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { | 51 void RenderWidgetHostViewMus::SetSize(const gfx::Size& size) { |
39 size_ = size; | 52 gfx::Rect bounds = window_->window()->bounds(); |
40 host_->WasResized(); | 53 bounds.set_size(size); |
| 54 SetBounds(bounds); |
41 } | 55 } |
42 | 56 |
43 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { | 57 void RenderWidgetHostViewMus::SetBounds(const gfx::Rect& rect) { |
44 SetSize(rect.size()); | 58 window_->window()->SetBounds(rect); |
| 59 host_->WasResized(); |
45 } | 60 } |
46 | 61 |
47 void RenderWidgetHostViewMus::Focus() { | 62 void RenderWidgetHostViewMus::Focus() { |
48 // TODO(fsamuel): Request focus for the associated Mus::Window | 63 // TODO(fsamuel): Request focus for the associated Mus::Window |
49 // We need to be careful how we propagate focus as we navigate to and | 64 // We need to be careful how we propagate focus as we navigate to and |
50 // from interstitials. | 65 // from interstitials. |
| 66 window_->window()->SetFocus(); |
51 } | 67 } |
52 | 68 |
53 bool RenderWidgetHostViewMus::HasFocus() const { | 69 bool RenderWidgetHostViewMus::HasFocus() const { |
54 return true; | 70 return true; |
55 } | 71 } |
56 | 72 |
57 bool RenderWidgetHostViewMus::IsSurfaceAvailableForCopy() const { | 73 bool RenderWidgetHostViewMus::IsSurfaceAvailableForCopy() const { |
58 NOTIMPLEMENTED(); | 74 NOTIMPLEMENTED(); |
59 return false; | 75 return false; |
60 } | 76 } |
61 | 77 |
62 gfx::Rect RenderWidgetHostViewMus::GetViewBounds() const { | 78 gfx::Rect RenderWidgetHostViewMus::GetViewBounds() const { |
63 return gfx::Rect(size_); | 79 return window_->window()->bounds(); |
64 } | 80 } |
65 | 81 |
66 gfx::Vector2dF RenderWidgetHostViewMus::GetLastScrollOffset() const { | 82 gfx::Vector2dF RenderWidgetHostViewMus::GetLastScrollOffset() const { |
67 return gfx::Vector2dF(); | 83 return gfx::Vector2dF(); |
68 } | 84 } |
69 | 85 |
70 void RenderWidgetHostViewMus::RenderProcessGone(base::TerminationStatus status, | 86 void RenderWidgetHostViewMus::RenderProcessGone(base::TerminationStatus status, |
71 int error_code) { | 87 int error_code) { |
72 // TODO(fsamuel): Figure out the interstitial lifetime issues here. | 88 // TODO(fsamuel): Figure out the interstitial lifetime issues here. |
73 platform_view_->Destroy(); | 89 platform_view_->Destroy(); |
(...skipping 10 matching lines...) Expand all Loading... |
84 | 100 |
85 base::string16 RenderWidgetHostViewMus::GetSelectedText() const { | 101 base::string16 RenderWidgetHostViewMus::GetSelectedText() const { |
86 return platform_view_->GetSelectedText(); | 102 return platform_view_->GetSelectedText(); |
87 } | 103 } |
88 | 104 |
89 void RenderWidgetHostViewMus::SetTooltipText( | 105 void RenderWidgetHostViewMus::SetTooltipText( |
90 const base::string16& tooltip_text) { | 106 const base::string16& tooltip_text) { |
91 // TOOD(fsamuel): Ask window manager for tooltip? | 107 // TOOD(fsamuel): Ask window manager for tooltip? |
92 } | 108 } |
93 | 109 |
| 110 void RenderWidgetHostViewMus::Embed( |
| 111 mus::mojom::WindowTreeClientPtr tree_client) { |
| 112 window_->window()->Embed(tree_client.Pass()); |
| 113 } |
| 114 |
94 void RenderWidgetHostViewMus::InitAsChild(gfx::NativeView parent_view) { | 115 void RenderWidgetHostViewMus::InitAsChild(gfx::NativeView parent_view) { |
95 platform_view_->InitAsChild(parent_view); | 116 platform_view_->InitAsChild(parent_view); |
96 } | 117 } |
97 | 118 |
98 RenderWidgetHost* RenderWidgetHostViewMus::GetRenderWidgetHost() const { | 119 RenderWidgetHost* RenderWidgetHostViewMus::GetRenderWidgetHost() const { |
99 return host_; | 120 return host_; |
100 } | 121 } |
101 | 122 |
| 123 RenderWidgetHostViewMus* RenderWidgetHostViewMus::AsMusView() { |
| 124 return this; |
| 125 } |
| 126 |
102 void RenderWidgetHostViewMus::InitAsPopup( | 127 void RenderWidgetHostViewMus::InitAsPopup( |
103 RenderWidgetHostView* parent_host_view, | 128 RenderWidgetHostView* parent_host_view, |
104 const gfx::Rect& bounds) { | 129 const gfx::Rect& bounds) { |
105 // TODO(fsamuel): Implement popups in Mus. | 130 // TODO(fsamuel): Implement popups in Mus. |
106 } | 131 } |
107 | 132 |
108 void RenderWidgetHostViewMus::InitAsFullscreen( | 133 void RenderWidgetHostViewMus::InitAsFullscreen( |
109 RenderWidgetHostView* reference_host_view) { | 134 RenderWidgetHostView* reference_host_view) { |
110 // TODO(fsamuel): Implement full screen windows in Mus. | 135 // TODO(fsamuel): Implement full screen windows in Mus. |
111 } | 136 } |
112 | 137 |
113 gfx::NativeView RenderWidgetHostViewMus::GetNativeView() const { | 138 gfx::NativeView RenderWidgetHostViewMus::GetNativeView() const { |
114 return gfx::NativeView(); | 139 return platform_view_->GetNativeView(); |
115 } | 140 } |
116 | 141 |
117 gfx::NativeViewId RenderWidgetHostViewMus::GetNativeViewId() const { | 142 gfx::NativeViewId RenderWidgetHostViewMus::GetNativeViewId() const { |
118 return gfx::NativeViewId(); | 143 return platform_view_->GetNativeViewId(); |
119 } | 144 } |
120 | 145 |
121 gfx::NativeViewAccessible RenderWidgetHostViewMus::GetNativeViewAccessible() { | 146 gfx::NativeViewAccessible RenderWidgetHostViewMus::GetNativeViewAccessible() { |
122 return gfx::NativeViewAccessible(); | 147 return gfx::NativeViewAccessible(); |
123 } | 148 } |
124 | 149 |
125 void RenderWidgetHostViewMus::MovePluginWindows( | 150 void RenderWidgetHostViewMus::MovePluginWindows( |
126 const std::vector<WebPluginGeometry>& moves) { | 151 const std::vector<WebPluginGeometry>& moves) { |
127 platform_view_->MovePluginWindows(moves); | 152 platform_view_->MovePluginWindows(moves); |
128 } | 153 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // TODO(fsamuel): Populate screen info from Mus. | 230 // TODO(fsamuel): Populate screen info from Mus. |
206 } | 231 } |
207 | 232 |
208 bool RenderWidgetHostViewMus::GetScreenColorProfile( | 233 bool RenderWidgetHostViewMus::GetScreenColorProfile( |
209 std::vector<char>* color_profile) { | 234 std::vector<char>* color_profile) { |
210 // TODO(fsamuel): Implement color profile in Mus. | 235 // TODO(fsamuel): Implement color profile in Mus. |
211 return false; | 236 return false; |
212 } | 237 } |
213 | 238 |
214 gfx::Rect RenderWidgetHostViewMus::GetBoundsInRootWindow() { | 239 gfx::Rect RenderWidgetHostViewMus::GetBoundsInRootWindow() { |
215 return GetViewBounds(); | 240 return platform_view_->GetBoundsInRootWindow(); |
216 } | 241 } |
217 | 242 |
218 #if defined(OS_MACOSX) | 243 #if defined(OS_MACOSX) |
219 void RenderWidgetHostViewMus::SetActive(bool active) { | 244 void RenderWidgetHostViewMus::SetActive(bool active) { |
220 platform_view_->SetActive(active); | 245 platform_view_->SetActive(active); |
221 } | 246 } |
222 | 247 |
223 void RenderWidgetHostViewMus::SetWindowVisibility(bool visible) { | 248 void RenderWidgetHostViewMus::SetWindowVisibility(bool visible) { |
224 // TODO(fsamuel): Propagate visibility to Mus? | 249 // TODO(fsamuel): Propagate visibility to Mus? |
225 platform_view_->SetWindowVisibility(visible); | 250 platform_view_->SetWindowVisibility(visible); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( | 295 void RenderWidgetHostViewMus::SetParentNativeViewAccessible( |
271 gfx::NativeViewAccessible accessible_parent) {} | 296 gfx::NativeViewAccessible accessible_parent) {} |
272 | 297 |
273 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() | 298 gfx::NativeViewId RenderWidgetHostViewMus::GetParentForWindowlessPlugin() |
274 const { | 299 const { |
275 return gfx::NativeViewId(); | 300 return gfx::NativeViewId(); |
276 } | 301 } |
277 #endif | 302 #endif |
278 | 303 |
279 } // namespace content | 304 } // namespace content |
OLD | NEW |