Index: services/navigation/view_impl.cc |
diff --git a/services/navigation/view_impl.cc b/services/navigation/view_impl.cc |
index bb6145d7549c0e39ce39f35d0a6211e29519f299..da3a043a77e757a1290ee1726bc16ec9184f2ab6 100644 |
--- a/services/navigation/view_impl.cc |
+++ b/services/navigation/view_impl.cc |
@@ -17,7 +17,8 @@ |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/web_contents.h" |
#include "services/service_manager/public/cpp/connector.h" |
-#include "services/ui/public/cpp/window_tree_client.h" |
+#include "ui/aura/mus/window_tree_client.h" |
+#include "ui/aura/mus/window_tree_host_mus.h" |
#include "ui/views/controls/webview/webview.h" |
#include "ui/views/mus/native_widget_mus.h" |
#include "ui/views/widget/widget.h" |
@@ -80,7 +81,16 @@ ViewImpl::ViewImpl(std::unique_ptr<service_manager::Connector> connector, |
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
content::Source<content::NavigationController>(controller)); |
} |
-ViewImpl::~ViewImpl() {} |
+ |
+ViewImpl::~ViewImpl() { |
+ DeleteTreeAndWidget(); |
+} |
+ |
+void ViewImpl::DeleteTreeAndWidget() { |
+ widget_.reset(); |
+ window_tree_host_.reset(); |
+ window_tree_client_.reset(); |
+} |
void ViewImpl::NavigateTo(const GURL& url) { |
web_view_->GetWebContents()->GetController().LoadURL( |
@@ -111,8 +121,8 @@ void ViewImpl::Stop() { |
} |
void ViewImpl::GetWindowTreeClient(ui::mojom::WindowTreeClientRequest request) { |
- window_tree_client_ = |
- base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request)); |
+ window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( |
+ connector_.get(), this, nullptr, std::move(request)); |
} |
void ViewImpl::ShowInterstitial(const std::string& html) { |
@@ -258,29 +268,48 @@ void ViewImpl::Observe(int type, |
} |
} |
-void ViewImpl::OnEmbed(ui::Window* root) { |
+void ViewImpl::OnEmbed( |
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
+ // TODO: Supplying a WindowTreeHostMus isn't particularly ideal in this case. |
+ // In particular it would be nice if the WindowTreeClientDelegate could create |
+ // its own WindowTreeHostMus, that way this code could directly create a |
+ // DesktopWindowTreeTreeHostMus. |
+ window_tree_host_ = std::move(window_tree_host); |
DCHECK(!widget_.get()); |
+ // TODO: fix this. The following won't work if multiple WindowTreeClients |
+ // are used at the same time. The best fix is to have the ability to specify |
+ // a WindowTreeClient when DesktopNativeWidgetAura is created so that it can |
+ // create WindowPortMus with the correct client. |
widget_.reset(new views::Widget); |
views::Widget::InitParams params( |
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
params.delegate = this; |
- params.native_widget = new views::NativeWidgetMus( |
- widget_.get(), root, ui::mojom::CompositorFrameSinkType::DEFAULT); |
widget_->Init(params); |
widget_->Show(); |
} |
-void ViewImpl::OnEmbedRootDestroyed(ui::Window* root) { |
- window_tree_client_.reset(); |
+void ViewImpl::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) { |
+ DCHECK_EQ(window_tree_host, window_tree_host_.get()); |
+ DeleteTreeAndWidget(); |
} |
-void ViewImpl::OnLostConnection(ui::WindowTreeClient* client) { |
- window_tree_client_.reset(); |
+void ViewImpl::OnLostConnection(aura::WindowTreeClient* client) { |
+ DeleteTreeAndWidget(); |
} |
void ViewImpl::OnPointerEventObserved(const ui::PointerEvent& event, |
- ui::Window* target) {} |
+ aura::Window* target) {} |
+ |
+aura::client::CaptureClient* ViewImpl::GetCaptureClient() { |
+ // TODO: wire this up. This typically comes from WMState. |
+ return nullptr; |
+} |
+ |
+aura::PropertyConverter* ViewImpl::GetPropertyConverter() { |
+ // TODO: wire this up. |
+ return nullptr; |
+} |
views::View* ViewImpl::GetContentsView() { |
return web_view_; |