| 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 #ifndef UI_VIEWS_MUS_DISPLAY_LIST_H_ |
| 6 #define UI_VIEWS_MUS_DISPLAY_LIST_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <vector> |
| 11 |
| 12 #include "base/observer_list.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "ui/display/display.h" |
| 15 #include "ui/views/mus/mus_export.h" |
| 16 |
| 17 namespace display { |
| 18 class Display; |
| 19 class DisplayObserver; |
| 20 } |
| 21 |
| 22 namespace views { |
| 23 |
| 24 // Maintains an ordered list of display::Displays as well as operations to add, |
| 25 // remove and update said list. Additionally maintains display::DisplayObservers |
| 26 // and updates them as appropriate. |
| 27 class VIEWS_MUS_EXPORT DisplayList { |
| 28 public: |
| 29 using Displays = std::vector<display::Display>; |
| 30 |
| 31 enum class Type { |
| 32 PRIMARY, |
| 33 NOT_PRIMARY, |
| 34 }; |
| 35 |
| 36 DisplayList(); |
| 37 ~DisplayList(); |
| 38 |
| 39 void AddObserver(display::DisplayObserver* observer); |
| 40 void RemoveObserver(display::DisplayObserver* observer); |
| 41 |
| 42 const Displays& displays() const { return displays_; } |
| 43 |
| 44 Displays::const_iterator FindDisplayById(int64_t id) const; |
| 45 Displays::iterator FindDisplayById(int64_t id); |
| 46 |
| 47 Displays::const_iterator GetPrimaryDisplayIterator() const; |
| 48 |
| 49 // Updates the cached id based on display.id() as well as whether the Display |
| 50 // is the primary display. |
| 51 void UpdateDisplay(const display::Display& display, Type type); |
| 52 |
| 53 // Adds a new Display. |
| 54 void AddDisplay(const display::Display& display, Type type); |
| 55 |
| 56 // Removes the Display with the specified id. |
| 57 void RemoveDisplay(int64_t id); |
| 58 |
| 59 private: |
| 60 std::vector<display::Display> displays_; |
| 61 int primary_display_index_ = -1; |
| 62 base::ObserverList<display::DisplayObserver> observers_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(DisplayList); |
| 65 }; |
| 66 |
| 67 } // namespace views |
| 68 |
| 69 #endif // UI_VIEWS_MUS_DISPLAY_LIST_H_ |
| OLD | NEW |