| 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 "services/ui/ws/user_display_manager.h" | 5 #include "services/ui/ws/user_display_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "services/ui/display/platform_screen.h" | 9 #include "services/ui/display/platform_screen.h" |
| 10 #include "services/ui/ws/display.h" | 10 #include "services/ui/ws/display.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 display_manager_observers_.ForAllPtrs([this]( | 32 display_manager_observers_.ForAllPtrs([this]( |
| 33 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); | 33 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); |
| 34 if (test_observer_) | 34 if (test_observer_) |
| 35 CallOnDisplays(test_observer_); | 35 CallOnDisplays(test_observer_); |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 | 38 |
| 39 mojo::Array<mojom::WsDisplayPtr> displays = GetAllDisplays(); | 39 mojo::Array<mojom::WsDisplayPtr> displays = GetAllDisplays(); |
| 40 display_manager_observers_.ForAllPtrs( | 40 display_manager_observers_.ForAllPtrs( |
| 41 [this, &displays](mojom::DisplayManagerObserver* observer) { | 41 [this, &displays](mojom::DisplayManagerObserver* observer) { |
| 42 observer->OnDisplaysChanged(displays.Clone()); | 42 observer->OnDisplaysChanged(displays.Clone().PassStorage()); |
| 43 }); | 43 }); |
| 44 if (test_observer_) | 44 if (test_observer_) |
| 45 test_observer_->OnDisplaysChanged(displays.Clone()); | 45 test_observer_->OnDisplaysChanged(displays.Clone().PassStorage()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void UserDisplayManager::AddDisplayManagerBinding( | 48 void UserDisplayManager::AddDisplayManagerBinding( |
| 49 mojo::InterfaceRequest<mojom::DisplayManager> request) { | 49 mojo::InterfaceRequest<mojom::DisplayManager> request) { |
| 50 display_manager_bindings_.AddBinding(this, std::move(request)); | 50 display_manager_bindings_.AddBinding(this, std::move(request)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void UserDisplayManager::OnDisplayUpdate(Display* display) { | 53 void UserDisplayManager::OnDisplayUpdate(Display* display) { |
| 54 if (!got_valid_frame_decorations_) | 54 if (!got_valid_frame_decorations_) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 mojo::Array<mojom::WsDisplayPtr> displays(1); | 57 mojo::Array<mojom::WsDisplayPtr> displays(1); |
| 58 displays[0] = GetWsDisplayPtr(*display); | 58 displays[0] = GetWsDisplayPtr(*display); |
| 59 | 59 |
| 60 display_manager_observers_.ForAllPtrs( | 60 display_manager_observers_.ForAllPtrs( |
| 61 [&displays](mojom::DisplayManagerObserver* observer) { | 61 [&displays](mojom::DisplayManagerObserver* observer) { |
| 62 observer->OnDisplaysChanged(displays.Clone()); | 62 observer->OnDisplaysChanged(displays.Clone().PassStorage()); |
| 63 }); | 63 }); |
| 64 if (test_observer_) | 64 if (test_observer_) |
| 65 test_observer_->OnDisplaysChanged(displays.Clone()); | 65 test_observer_->OnDisplaysChanged(displays.Clone().PassStorage()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void UserDisplayManager::OnWillDestroyDisplay(Display* display) { | 68 void UserDisplayManager::OnWillDestroyDisplay(Display* display) { |
| 69 if (!got_valid_frame_decorations_) | 69 if (!got_valid_frame_decorations_) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 display_manager_observers_.ForAllPtrs( | 72 display_manager_observers_.ForAllPtrs( |
| 73 [&display](mojom::DisplayManagerObserver* observer) { | 73 [&display](mojom::DisplayManagerObserver* observer) { |
| 74 observer->OnDisplayRemoved(display->GetId()); | 74 observer->OnDisplayRemoved(display->GetId()); |
| 75 }); | 75 }); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 ++i; | 152 ++i; |
| 153 } | 153 } |
| 154 | 154 |
| 155 return display_ptrs; | 155 return display_ptrs; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void UserDisplayManager::CallOnDisplays( | 158 void UserDisplayManager::CallOnDisplays( |
| 159 mojom::DisplayManagerObserver* observer) { | 159 mojom::DisplayManagerObserver* observer) { |
| 160 // TODO(kylechar): Pass internal display id to clients here. | 160 // TODO(kylechar): Pass internal display id to clients here. |
| 161 observer->OnDisplays( | 161 observer->OnDisplays( |
| 162 GetAllDisplays(), | 162 GetAllDisplays().PassStorage(), |
| 163 display::PlatformScreen::GetInstance()->GetPrimaryDisplayId(), | 163 display::PlatformScreen::GetInstance()->GetPrimaryDisplayId(), |
| 164 display::Display::kInvalidDisplayID); | 164 display::Display::kInvalidDisplayID); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void UserDisplayManager::AddObserver( | 167 void UserDisplayManager::AddObserver( |
| 168 mojom::DisplayManagerObserverPtr observer) { | 168 mojom::DisplayManagerObserverPtr observer) { |
| 169 mojom::DisplayManagerObserver* observer_impl = observer.get(); | 169 mojom::DisplayManagerObserver* observer_impl = observer.get(); |
| 170 display_manager_observers_.AddPtr(std::move(observer)); | 170 display_manager_observers_.AddPtr(std::move(observer)); |
| 171 OnObserverAdded(observer_impl); | 171 OnObserverAdded(observer_impl); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace ws | 174 } // namespace ws |
| 175 } // namespace ui | 175 } // namespace ui |
| OLD | NEW |