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

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

Issue 1461243002: [OLD ATTEMPT, DO NOT REVIEW] mustash: Enable connections to mus from the Chrome renderer Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ben's comments 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
« no previous file with comments | « content/browser/web_contents/web_contents_view_mus.h ('k') | content/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = window_->window()->bounds();
48 } 57 }
49 58
50 void WebContentsViewMus::SizeContents(const gfx::Size& size) { 59 void WebContentsViewMus::SizeContents(const gfx::Size& size) {
51 size_ = size; 60 gfx::Rect bounds = window_->window()->bounds();
61 if (bounds.size() != size) {
62 bounds.set_size(size);
63 window_->window()->SetBounds(bounds);
64 }
52 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 65 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
53 if (rwhv) 66 if (rwhv)
54 rwhv->SetSize(size); 67 rwhv->SetSize(size);
55 } 68 }
56 69
57 void WebContentsViewMus::SetInitialFocus() { 70 void WebContentsViewMus::SetInitialFocus() {
58 platform_view_->SetInitialFocus(); 71 platform_view_->SetInitialFocus();
59 } 72 }
60 73
61 gfx::Rect WebContentsViewMus::GetViewBounds() const { 74 gfx::Rect WebContentsViewMus::GetViewBounds() const {
62 return gfx::Rect(size_); 75 return window_->window()->bounds();
63 } 76 }
64 77
65 #if defined(OS_MACOSX) 78 #if defined(OS_MACOSX)
66 void WebContentsViewMus::SetAllowOtherViews(bool allow) { 79 void WebContentsViewMus::SetAllowOtherViews(bool allow) {
67 platform_view_->SetAllowOtherViews(allow); 80 platform_view_->SetAllowOtherViews(allow);
68 } 81 }
69 82
70 bool WebContentsViewMus::GetAllowOtherViews() const { 83 bool WebContentsViewMus::GetAllowOtherViews() const {
71 return platform_view_->GetAllowOtherViews(); 84 return platform_view_->GetAllowOtherViews();
72 } 85 }
73 #endif 86 #endif
74 87
75 void WebContentsViewMus::CreateView(const gfx::Size& initial_size, 88 void WebContentsViewMus::CreateView(const gfx::Size& initial_size,
76 gfx::NativeView context) { 89 gfx::NativeView context) {
77 platform_view_->CreateView(initial_size, context); 90 platform_view_->CreateView(initial_size, context);
78 size_ = initial_size; 91 window_->window()->SetBounds(platform_view_->GetViewBounds());
79 } 92 }
80 93
81 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget( 94 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget(
82 RenderWidgetHost* render_widget_host, 95 RenderWidgetHost* render_widget_host,
83 bool is_guest_view_hack) { 96 bool is_guest_view_hack) {
84 RenderWidgetHostViewBase* platform_widget = 97 RenderWidgetHostViewBase* platform_widget =
85 platform_view_->CreateViewForWidget(render_widget_host, true); 98 platform_view_->CreateViewForWidget(render_widget_host, true);
86 99
87 return new RenderWidgetHostViewMus( 100 return new RenderWidgetHostViewMus(
88 RenderWidgetHostImpl::From(render_widget_host), 101 window_->window(), RenderWidgetHostImpl::From(render_widget_host),
89 platform_widget->GetWeakPtr()); 102 platform_widget->GetWeakPtr());
90 } 103 }
91 104
92 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForPopupWidget( 105 RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForPopupWidget(
93 RenderWidgetHost* render_widget_host) { 106 RenderWidgetHost* render_widget_host) {
94 return platform_view_->CreateViewForPopupWidget(render_widget_host); 107 return platform_view_->CreateViewForPopupWidget(render_widget_host);
95 } 108 }
96 109
97 void WebContentsViewMus::SetPageTitle(const base::string16& title) {} 110 void WebContentsViewMus::SetPageTitle(const base::string16& title) {}
98 111
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 165
153 void WebContentsViewMus::StartDragging(const DropData& drop_data, 166 void WebContentsViewMus::StartDragging(const DropData& drop_data,
154 WebDragOperationsMask ops, 167 WebDragOperationsMask ops,
155 const gfx::ImageSkia& image, 168 const gfx::ImageSkia& image,
156 const gfx::Vector2d& image_offset, 169 const gfx::Vector2d& image_offset,
157 const DragEventSourceInfo& event_info) { 170 const DragEventSourceInfo& event_info) {
158 // TODO(fsamuel): Implement drag and drop. 171 // TODO(fsamuel): Implement drag and drop.
159 } 172 }
160 173
161 } // namespace content 174 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_mus.h ('k') | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698