Chromium Code Reviews| 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( | |
|
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.
| |
| 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 host_factory->set_window_tree(tree.get()); | |
| 41 | |
| 42 // Pass nullptr as mojom::WindowTreePtr (3rd parameter), because in external | |
| 43 // window mode, the WindowTreePtr is created on the aura/WindowTreeClient | |
| 44 // side. | |
| 45 // | |
| 46 // NOTE: This call to ::AddTree calls ::Init. However, it will not trigger a | |
| 47 // ::OnEmbed call because the WindowTree instance was created above passing | |
| 48 // 'nullptr' as the ServerWindow, hence there is no 'root' yet. | |
| 49 window_server_->AddTree(std::move(tree), std::move(tree_binding), | |
| 50 nullptr /*mojom::WindowTreePtr*/); | |
| 51 | |
| 52 window_server_->set_window_tree_host_factory(std::move(host_factory)); | |
| 53 } | |
| 54 | |
| 55 } // namespace ws | |
| 56 } // namespace ui | |
| OLD | NEW |