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

Unified Diff: services/ui/ws/window_tree_host_factory.cc

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: addressing fwang/sky feedback Created 3 years, 10 months 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: services/ui/ws/window_tree_host_factory.cc
diff --git a/services/ui/ws/window_tree_host_factory.cc b/services/ui/ws/window_tree_host_factory.cc
index 1a2170b0a67144aeeaf31f6260afcce47ada1e00..f0c9075a0252d94024beab94b3080cd9e2cd5c19 100644
--- a/services/ui/ws/window_tree_host_factory.cc
+++ b/services/ui/ws/window_tree_host_factory.cc
@@ -4,9 +4,12 @@
#include "services/ui/ws/window_tree_host_factory.h"
+#include "services/ui/ws/default_access_policy.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_binding.h"
#include "services/ui/ws/window_server.h"
+#include "services/ui/ws/window_tree.h"
+#include "services/ui/ws/window_tree_binding.h"
namespace ui {
namespace ws {
@@ -22,18 +25,39 @@ WindowTreeHostFactory::WindowTreeHostFactory(WindowServer* window_server,
WindowTreeHostFactory::~WindowTreeHostFactory() {}
-void WindowTreeHostFactory::AddBinding(
- mojom::WindowTreeHostFactoryRequest request) {
+void WindowTreeHostFactory::Init(mojom::WindowTreeHostFactoryRequest request,
+ mojom::WindowTreeRequest tree_request,
+ mojom::WindowTreeClientPtr tree_client) {
bindings_.AddBinding(this, std::move(request));
+
+ std::unique_ptr<ws::WindowTree> tree(
+ new ws::WindowTree(window_server_, user_id_, nullptr /*ServerWindow*/,
+ base::WrapUnique(new DefaultAccessPolicy)));
+
+ std::unique_ptr<ws::DefaultWindowTreeBinding> tree_binding(
+ new ws::DefaultWindowTreeBinding(tree.get(), window_server_,
+ std::move(tree_request),
+ std::move(tree_client)));
+
+ tree_ = tree.get();
+
+ // Pass nullptr as mojom::WindowTreePtr (3rd parameter), because in external
+ // window mode, the WindowTreePtr is created on the aura/WindowTreeClient
+ // side.
+ //
+ // NOTE: This call to ::AddTree calls ::Init. However, it will not trigger a
+ // ::OnEmbed call because the WindowTree instance was created above passing
+ // 'nullptr' as the ServerWindow, hence there is no 'root' yet.
+ window_server_->AddTree(std::move(tree), std::move(tree_binding),
+ nullptr /*mojom::WindowTreePtr*/);
}
void WindowTreeHostFactory::CreateWindowTreeHost(
- mojom::WindowTreeHostRequest host,
- mojom::WindowTreeClientPtr tree_client) {
+ mojom::WindowTreeHostRequest tree_host_request) {
Display* display = new Display(window_server_);
std::unique_ptr<DisplayBindingImpl> display_binding(
- new DisplayBindingImpl(std::move(host), display, user_id_,
- std::move(tree_client), window_server_));
+ new DisplayBindingImpl(std::move(tree_host_request), display, user_id_,
+ nullptr /* tree_client */, window_server_));
display->Init(platform_display_init_params_, std::move(display_binding));
}

Powered by Google App Engine
This is Rietveld 408576698