1 // Copyright 2019 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 CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_LIST_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_LIST_VIEW_H_ 7 8 #include <map> 9 #include <memory> 10 11 #include "base/optional.h" 12 #include "ui/views/controls/scroll_view.h" 13 14 class MediaNotificationContainerImplView; 15 class OverlayMediaNotification; 16 17 // MediaNotificationListView is a container that holds a list of active media 18 // sessions. 19 class MediaNotificationListView : public views::ScrollView { 20 public: 21 struct SeparatorStyle { 22 SeparatorStyle(SkColor separator_color, int separator_thickness); 23 24 const SkColor separator_color; 25 const int separator_thickness; 26 }; 27 28 explicit MediaNotificationListView( 29 const base::Optional<SeparatorStyle>& separator_style); 30 MediaNotificationListView(); 31 ~MediaNotificationListView() override; 32 33 // Adds the given notification into the list. 34 void ShowNotification( 35 const std::string& id, 36 std::unique_ptr<MediaNotificationContainerImplView> notification); 37 38 // Removes the given notification from the list. 39 void HideNotification(const std::string& id); 40 41 // Removes the given notification from the list and returns an 42 // OverlayMediaNotificationView that contains it. 43 std::unique_ptr<OverlayMediaNotification> PopOut(const std::string& id, 44 gfx::Rect bounds); 45 empty()46 bool empty() { return notifications_.empty(); } 47 48 const std::map<const std::string, MediaNotificationContainerImplView*>& notifications_for_testing()49 notifications_for_testing() const { 50 return notifications_; 51 } 52 53 private: 54 std::unique_ptr<MediaNotificationContainerImplView> RemoveNotification( 55 const std::string& id); 56 57 std::map<const std::string, MediaNotificationContainerImplView*> 58 notifications_; 59 60 base::Optional<SeparatorStyle> separator_style_; 61 62 DISALLOW_COPY_AND_ASSIGN(MediaNotificationListView); 63 }; 64 65 #endif // CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_LIST_VIEW_H_ 66