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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_view_mus.cc
diff --git a/content/browser/web_contents/web_contents_view_mus.cc b/content/browser/web_contents/web_contents_view_mus.cc
index 97e45f8c90fdc73a54959ff442d62975f2c6b383..625ff329760a0f23f6855574f16c07197f152822 100644
--- a/content/browser/web_contents/web_contents_view_mus.cc
+++ b/content/browser/web_contents/web_contents_view_mus.cc
@@ -5,6 +5,8 @@
#include "content/browser/web_contents/web_contents_view_mus.h"
#include "build/build_config.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "content/browser/renderer_host/render_widget_host_view_mus.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -17,12 +19,19 @@ namespace content {
WebContentsViewMus::WebContentsViewMus(
WebContentsImpl* web_contents,
+ mus::Window* parent_window,
scoped_ptr<WebContentsView> platform_view,
RenderViewHostDelegateView** delegate_view)
: web_contents_(web_contents),
platform_view_(platform_view.Pass()),
platform_view_delegate_view_(*delegate_view) {
+ DCHECK(parent_window);
*delegate_view = this;
+ mus::Window* window = parent_window->connection()->NewWindow();
+ window->SetVisible(true);
+ window->SetBounds(gfx::Rect(300, 300));
+ parent_window->AddChild(window);
+ window_.reset(new mus::ScopedWindowPtr(window));
}
WebContentsViewMus::~WebContentsViewMus() {}
@@ -44,11 +53,15 @@ gfx::NativeWindow WebContentsViewMus::GetTopLevelNativeWindow() const {
void WebContentsViewMus::GetContainerBounds(gfx::Rect* out) const {
// TODO(fsamuel): Get the position right.
- out->set_size(size_);
+ *out = window_->window()->bounds();
}
void WebContentsViewMus::SizeContents(const gfx::Size& size) {
- size_ = size;
+ gfx::Rect bounds = window_->window()->bounds();
+ if (bounds.size() != size) {
+ bounds.set_size(size);
+ window_->window()->SetBounds(bounds);
+ }
RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetSize(size);
@@ -59,7 +72,7 @@ void WebContentsViewMus::SetInitialFocus() {
}
gfx::Rect WebContentsViewMus::GetViewBounds() const {
- return gfx::Rect(size_);
+ return window_->window()->bounds();
}
#if defined(OS_MACOSX)
@@ -75,7 +88,7 @@ bool WebContentsViewMus::GetAllowOtherViews() const {
void WebContentsViewMus::CreateView(const gfx::Size& initial_size,
gfx::NativeView context) {
platform_view_->CreateView(initial_size, context);
- size_ = initial_size;
+ window_->window()->SetBounds(platform_view_->GetViewBounds());
}
RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget(
@@ -85,7 +98,7 @@ RenderWidgetHostViewBase* WebContentsViewMus::CreateViewForWidget(
platform_view_->CreateViewForWidget(render_widget_host, true);
return new RenderWidgetHostViewMus(
- RenderWidgetHostImpl::From(render_widget_host),
+ window_->window(), RenderWidgetHostImpl::From(render_widget_host),
platform_widget->GetWeakPtr());
}

Powered by Google App Engine
This is Rietveld 408576698