OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/ui/ws/window_tree_host_factory_registrar.h" |
| 6 |
| 7 #include "services/ui/ws/default_access_policy.h" |
| 8 #include "services/ui/ws/window_server.h" |
| 9 #include "services/ui/ws/window_tree.h" |
| 10 #include "services/ui/ws/window_tree_host_factory.h" |
| 11 |
| 12 namespace ui { |
| 13 namespace ws { |
| 14 |
| 15 WindowTreeHostFactoryRegistrar::WindowTreeHostFactoryRegistrar( |
| 16 WindowServer* window_server, |
| 17 const UserId& user_id) |
| 18 : window_server_(window_server), user_id_(user_id) {} |
| 19 |
| 20 WindowTreeHostFactoryRegistrar::~WindowTreeHostFactoryRegistrar() {} |
| 21 |
| 22 void WindowTreeHostFactoryRegistrar::Register( |
| 23 mojom::WindowTreeHostFactoryRequest host_factory_request, |
| 24 mojom::WindowTreeRequest tree_request, |
| 25 mojom::WindowTreeClientPtr tree_client) { |
| 26 std::unique_ptr<WindowTreeHostFactory> host_factory( |
| 27 new WindowTreeHostFactory(window_server_, user_id_)); |
| 28 |
| 29 host_factory->AddBinding(std::move(host_factory_request)); |
| 30 |
| 31 std::unique_ptr<ws::WindowTree> tree( |
| 32 new ws::WindowTree(window_server_, user_id_, nullptr /*ServerWindow*/, |
| 33 base::WrapUnique(new DefaultAccessPolicy))); |
| 34 |
| 35 std::unique_ptr<ws::DefaultWindowTreeBinding> tree_binding( |
| 36 new ws::DefaultWindowTreeBinding(tree.get(), window_server_, |
| 37 std::move(tree_request), |
| 38 std::move(tree_client))); |
| 39 |
| 40 // Pass nullptr as mojom::WindowTreePtr (3rd parameter), because in external |
| 41 // window mode, the WindowTreePtr is created on the aura/WindowTreeClient |
| 42 // side. |
| 43 // |
| 44 // NOTE: This call to ::AddTree calls ::Init. However, it will not trigger a |
| 45 // ::OnEmbed call because the WindowTree instance was created above passing |
| 46 // 'nullptr' as the ServerWindow, hence there is no 'root' yet. |
| 47 window_server_->AddTree(std::move(tree), std::move(tree_binding), |
| 48 nullptr /*mojom::WindowTreePtr*/); |
| 49 |
| 50 window_server_->set_window_tree_host_factory(std::move(host_factory)); |
| 51 } |
| 52 |
| 53 } // namespace ws |
| 54 } // namespace ui |
OLD | NEW |