| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/mus/ws/window_manager_factory_registry.h" | 5 #include "components/mus/ws/window_manager_factory_registry.h" |
| 6 | 6 |
| 7 #include "components/mus/ws/user_id_tracker_observer.h" | 7 #include "components/mus/ws/user_id_tracker_observer.h" |
| 8 #include "components/mus/ws/window_manager_factory_registry_observer.h" | 8 #include "components/mus/ws/window_manager_factory_registry_observer.h" |
| 9 #include "components/mus/ws/window_manager_factory_service.h" | 9 #include "components/mus/ws/window_manager_factory_service.h" |
| 10 #include "components/mus/ws/window_server.h" | 10 #include "components/mus/ws/window_server.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 WindowManagerFactoryRegistry::~WindowManagerFactoryRegistry() { | 22 WindowManagerFactoryRegistry::~WindowManagerFactoryRegistry() { |
| 23 id_tracker_->RemoveObserver(this); | 23 id_tracker_->RemoveObserver(this); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void WindowManagerFactoryRegistry::Register( | 26 void WindowManagerFactoryRegistry::Register( |
| 27 const UserId& user_id, | 27 const UserId& user_id, |
| 28 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request) { | 28 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request) { |
| 29 if (ContainsServiceForUser(user_id)) | 29 if (ContainsServiceForUser(user_id)) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 scoped_ptr<WindowManagerFactoryService> service( | 32 std::unique_ptr<WindowManagerFactoryService> service( |
| 33 new WindowManagerFactoryService(this, user_id, std::move(request))); | 33 new WindowManagerFactoryService(this, user_id, std::move(request))); |
| 34 AddServiceImpl(std::move(service)); | 34 AddServiceImpl(std::move(service)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 std::vector<WindowManagerFactoryService*> | 37 std::vector<WindowManagerFactoryService*> |
| 38 WindowManagerFactoryRegistry::GetServices() { | 38 WindowManagerFactoryRegistry::GetServices() { |
| 39 std::vector<WindowManagerFactoryService*> result; | 39 std::vector<WindowManagerFactoryService*> result; |
| 40 for (auto& service_ptr : services_) | 40 for (auto& service_ptr : services_) |
| 41 result.push_back(service_ptr.get()); | 41 result.push_back(service_ptr.get()); |
| 42 return result; | 42 return result; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void WindowManagerFactoryRegistry::AddObserver( | 45 void WindowManagerFactoryRegistry::AddObserver( |
| 46 WindowManagerFactoryRegistryObserver* observer) { | 46 WindowManagerFactoryRegistryObserver* observer) { |
| 47 observers_.AddObserver(observer); | 47 observers_.AddObserver(observer); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void WindowManagerFactoryRegistry::RemoveObserver( | 50 void WindowManagerFactoryRegistry::RemoveObserver( |
| 51 WindowManagerFactoryRegistryObserver* observer) { | 51 WindowManagerFactoryRegistryObserver* observer) { |
| 52 observers_.RemoveObserver(observer); | 52 observers_.RemoveObserver(observer); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void WindowManagerFactoryRegistry::AddServiceImpl( | 55 void WindowManagerFactoryRegistry::AddServiceImpl( |
| 56 scoped_ptr<WindowManagerFactoryService> service) { | 56 std::unique_ptr<WindowManagerFactoryService> service) { |
| 57 services_.push_back(std::move(service)); | 57 services_.push_back(std::move(service)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool WindowManagerFactoryRegistry::ContainsServiceForUser( | 60 bool WindowManagerFactoryRegistry::ContainsServiceForUser( |
| 61 const UserId& user_id) const { | 61 const UserId& user_id) const { |
| 62 for (auto& service_ptr : services_) { | 62 for (auto& service_ptr : services_) { |
| 63 if (service_ptr->user_id() == user_id) { | 63 if (service_ptr->user_id() == user_id) { |
| 64 LOG(ERROR) << "WindowManagerFactoryService already registered for " | 64 LOG(ERROR) << "WindowManagerFactoryService already registered for " |
| 65 << user_id; | 65 << user_id; |
| 66 return true; | 66 return true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 for (auto iter = services_.begin(); iter != services_.end(); ++iter) { | 103 for (auto iter = services_.begin(); iter != services_.end(); ++iter) { |
| 104 if ((*iter)->user_id() == id) { | 104 if ((*iter)->user_id() == id) { |
| 105 services_.erase(iter); | 105 services_.erase(iter); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace ws | 111 } // namespace ws |
| 112 } // namespace mus | 112 } // namespace mus |
| OLD | NEW |