Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: content/browser/web_contents/web_contents_view_mus.cc

Issue 1476643002: mustash: Enable connections to mus from the Chrome renderer [take 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create a RenderWidgetWindowTreeeClientFactory in tests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/web_contents/web_contents_view_mus.h" 5 #include "content/browser/web_contents/web_contents_view_mus.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "components/mus/public/cpp/window.h"
9 #include "components/mus/public/cpp/window_tree_connection.h"
8 #include "content/browser/renderer_host/render_widget_host_view_mus.h" 10 #include "content/browser/renderer_host/render_widget_host_view_mus.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/render_widget_host_view.h" 12 #include "content/public/browser/render_widget_host_view.h"
11 #include "third_party/WebKit/public/web/WebDragOperation.h" 13 #include "third_party/WebKit/public/web/WebDragOperation.h"
12 14
13 using blink::WebDragOperation; 15 using blink::WebDragOperation;
14 using blink::WebDragOperationsMask; 16 using blink::WebDragOperationsMask;
15 17
16 namespace content { 18 namespace content {
17 19
18 WebContentsViewMus::WebContentsViewMus( 20 WebContentsViewMus::WebContentsViewMus(
19 WebContentsImpl* web_contents, 21 WebContentsImpl* web_contents,
22 mus::Window* parent_window,
20 scoped_ptr<WebContentsView> platform_view, 23 scoped_ptr<WebContentsView> platform_view,
21 RenderViewHostDelegateView** delegate_view) 24 RenderViewHostDelegateView** delegate_view)
22 : web_contents_(web_contents), 25 : web_contents_(web_contents),
23 platform_view_(platform_view.Pass()), 26 platform_view_(platform_view.Pass()),
24 platform_view_delegate_view_(*delegate_view) { 27 platform_view_delegate_view_(*delegate_view) {
28 DCHECK(parent_window);
25 *delegate_view = this; 29 *delegate_view = this;
30 mus::Window* window = parent_window->connection()->NewWindow();
31 window->SetVisible(true);
32 window->SetBounds(gfx::Rect(300, 300));
33 parent_window->AddChild(window);
34 window_.reset(new mus::ScopedWindowPtr(window));
26 } 35 }
27 36
28 WebContentsViewMus::~WebContentsViewMus() {} 37 WebContentsViewMus::~WebContentsViewMus() {}
29 38
30 gfx::NativeView WebContentsViewMus::GetNativeView() const { 39 gfx::NativeView WebContentsViewMus::GetNativeView() const {
31 return platform_view_->GetNativeView(); 40 return platform_view_->GetNativeView();
32 } 41 }
33 42
34 gfx::NativeView WebContentsViewMus::GetContentNativeView() const { 43 gfx::NativeView WebContentsViewMus::GetContentNativeView() const {
35 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 44 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
36 if (!rwhv) 45 if (!rwhv)
37 return NULL; 46 return NULL;
38 return rwhv->GetNativeView(); 47 return rwhv->GetNativeView();
39 } 48 }
40 49
41 gfx::NativeWindow WebContentsViewMus::GetTopLevelNativeWindow() const { 50 gfx::NativeWindow WebContentsViewMus::GetTopLevelNativeWindow() const {
42 return platform_view_->GetTopLevelNativeWindow(); 51 return platform_view_->GetTopLevelNativeWindow();
43 } 52 }
44 53
45 void WebContentsViewMus::GetContainerBounds(gfx::Rect* out) const { 54 void WebContentsViewMus::GetContainerBounds(gfx::Rect* out) const {
46 // TODO(fsamuel): Get the position right. 55 // TODO(fsamuel): Get the position right.
47 out->set_size(size_); 56 out->set_size(size_);
48 } 57 }
49 58
50 void WebContentsViewMus::SizeContents(const gfx::Size& size) { 59 void WebContentsViewMus::SizeContents(const gfx::Size& size) {
51 size_ = size; 60 size_ = size;
52 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 61 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
53 if (rwhv) 62 if (rwhv)
54 rwhv->SetSize(size); 63 rwhv->SetSize(size);
64 window_->window()->SetBounds(gfx::Rect(size));
55 } 65 }
56 66
57 void WebContentsViewMus::SetInitialFocus() { 67 void WebContentsViewMus::SetInitialFocus() {
58 platform_view_->SetInitialFocus(); 68 platform_view_->SetInitialFocus();
59 } 69 }
60 70
61 gfx::Rect WebContentsViewMus::GetViewBounds() const { 71 gfx::Rect WebContentsViewMus::GetViewBounds() const {
62 return gfx::Rect(size_); 72 return gfx::Rect(size_);
63 } 73 }
64 74
(...skipping 13 matching lines...) Expand all
78 size_ = initial_size; 88 size_ = initial_size;
79 } 89 }
80 90
81 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget( 91 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget(
82 RenderWidgetHost* render_widget_host, 92 RenderWidgetHost* render_widget_host,
83 bool is_guest_view_hack) { 93 bool is_guest_view_hack) {
84 RenderWidgetHostViewBase* platform_widget = 94 RenderWidgetHostViewBase* platform_widget =
85 platform_view_->CreateViewForWidget(render_widget_host, true); 95 platform_view_->CreateViewForWidget(render_widget_host, true);
86 96
87 return new RenderWidgetHostViewMus( 97 return new RenderWidgetHostViewMus(
88 RenderWidgetHostImpl::From(render_widget_host), 98 window_->window(), RenderWidgetHostImpl::From(render_widget_host),
89 platform_widget->GetWeakPtr()); 99 platform_widget->GetWeakPtr());
90 } 100 }
91 101
92 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForPopupWidget( 102 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForPopupWidget(
93 RenderWidgetHost* render_widget_host) { 103 RenderWidgetHost* render_widget_host) {
94 return platform_view_->CreateViewForPopupWidget(render_widget_host); 104 return platform_view_->CreateViewForPopupWidget(render_widget_host);
95 } 105 }
96 106
97 void WebContentsViewMus::SetPageTitle(const base::string16& title) {} 107 void WebContentsViewMus::SetPageTitle(const base::string16& title) {}
98 108
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 162
153 void WebContentsViewMus::StartDragging(const DropData& drop_data, 163 void WebContentsViewMus::StartDragging(const DropData& drop_data,
154 WebDragOperationsMask ops, 164 WebDragOperationsMask ops,
155 const gfx::ImageSkia& image, 165 const gfx::ImageSkia& image,
156 const gfx::Vector2d& image_offset, 166 const gfx::Vector2d& image_offset,
157 const DragEventSourceInfo& event_info) { 167 const DragEventSourceInfo& event_info) {
158 // TODO(fsamuel): Implement drag and drop. 168 // TODO(fsamuel): Implement drag and drop.
159 } 169 }
160 170
161 } // namespace content 171 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698