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

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

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: addressed sky/fwang feedback (take 5), simpler mus_demo changes / passing unittests Created 3 years, 9 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_registrar.cc
diff --git a/services/ui/ws/window_tree_host_factory_registrar.cc b/services/ui/ws/window_tree_host_factory_registrar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e1ccb561533294e307d505c7b03798d40dc5893
--- /dev/null
+++ b/services/ui/ws/window_tree_host_factory_registrar.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/ui/ws/window_tree_host_factory_registrar.h"
+
+#include "services/ui/ws/default_access_policy.h"
+#include "services/ui/ws/window_server.h"
+#include "services/ui/ws/window_tree.h"
+#include "services/ui/ws/window_tree_host_factory.h"
+
+namespace ui {
+namespace ws {
+
+WindowTreeHostFactoryRegistrar::WindowTreeHostFactoryRegistrar(
+ WindowServer* window_server,
+ const UserId& user_id)
+ : window_server_(window_server), user_id_(user_id) {}
+
+WindowTreeHostFactoryRegistrar::~WindowTreeHostFactoryRegistrar() {}
+
+void WindowTreeHostFactoryRegistrar::Register(
+ mojom::WindowTreeHostFactoryRequest host_factory_request,
+ mojom::WindowTreeRequest tree_request,
+ mojom::WindowTreeClientPtr tree_client) {
+ std::unique_ptr<WindowTreeHostFactory> host_factory(
kylechar 2017/03/07 18:19:37 It's preferred to use MakeUnique, so something lik
tonikitoo 2017/03/07 20:09:36 Will fix.
+ new WindowTreeHostFactory(window_server_, user_id_));
+
+ host_factory->AddBinding(std::move(host_factory_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)));
+
+ host_factory->set_window_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*/);
+
+ window_server_->set_window_tree_host_factory(std::move(host_factory));
+}
+
+} // namespace ws
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698