| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 "components/mus/ws/window_manager_window_tree_factory.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "components/mus/ws/window_manager_window_tree_factory_set.h" | |
| 9 #include "components/mus/ws/window_server.h" | |
| 10 #include "components/mus/ws/window_tree.h" | |
| 11 | |
| 12 namespace mus { | |
| 13 namespace ws { | |
| 14 | |
| 15 WindowManagerWindowTreeFactory::WindowManagerWindowTreeFactory( | |
| 16 WindowManagerWindowTreeFactorySet* window_manager_window_tree_factory_set, | |
| 17 const UserId& user_id, | |
| 18 mojo::InterfaceRequest<mojom::WindowManagerWindowTreeFactory> request) | |
| 19 : window_manager_window_tree_factory_set_( | |
| 20 window_manager_window_tree_factory_set), | |
| 21 user_id_(user_id), | |
| 22 binding_(this), | |
| 23 window_tree_(nullptr) { | |
| 24 if (request.is_pending()) | |
| 25 binding_.Bind(std::move(request)); | |
| 26 } | |
| 27 | |
| 28 WindowManagerWindowTreeFactory::~WindowManagerWindowTreeFactory() {} | |
| 29 | |
| 30 void WindowManagerWindowTreeFactory::CreateWindowTree( | |
| 31 mojom::WindowTreeRequest window_tree_request, | |
| 32 mojom::WindowTreeClientPtr window_tree_client) { | |
| 33 // CreateWindowTree() can only be called once, so there is no reason to keep | |
| 34 // the binding around. | |
| 35 if (binding_.is_bound()) | |
| 36 binding_.Close(); | |
| 37 | |
| 38 SetWindowTree(GetWindowServer()->CreateTreeForWindowManager( | |
| 39 user_id_, std::move(window_tree_request), std::move(window_tree_client))); | |
| 40 } | |
| 41 | |
| 42 WindowManagerWindowTreeFactory::WindowManagerWindowTreeFactory( | |
| 43 WindowManagerWindowTreeFactorySet* window_manager_window_tree_factory_set, | |
| 44 const UserId& user_id) | |
| 45 : window_manager_window_tree_factory_set_( | |
| 46 window_manager_window_tree_factory_set), | |
| 47 user_id_(user_id), | |
| 48 binding_(this), | |
| 49 window_tree_(nullptr) {} | |
| 50 | |
| 51 WindowServer* WindowManagerWindowTreeFactory::GetWindowServer() { | |
| 52 return window_manager_window_tree_factory_set_->window_server(); | |
| 53 } | |
| 54 | |
| 55 void WindowManagerWindowTreeFactory::SetWindowTree(WindowTree* window_tree) { | |
| 56 DCHECK(!window_tree_); | |
| 57 window_tree_ = window_tree; | |
| 58 | |
| 59 window_manager_window_tree_factory_set_ | |
| 60 ->OnWindowManagerWindowTreeFactoryReady(this); | |
| 61 } | |
| 62 | |
| 63 } // namespace ws | |
| 64 } // namespace mus | |
| OLD | NEW |