1 // Copyright 2013 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_MEDIA_DESKTOP_MEDIA_LIST_H_ 6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_ 7 8 #include "base/basictypes.h" 9 #include "base/time/time.h" 10 #include "content/public/browser/desktop_media_id.h" 11 #include "ui/gfx/image/image_skia.h" 12 13 class DesktopMediaListObserver; 14 15 // DesktopMediaList provides the list of desktop media source (screens, windows, 16 // tabs), and their thumbnails, to the desktop media picker dialog. It 17 // transparently updates the list in the background, and notifies the desktop 18 // media picker when something changes. 19 class DesktopMediaList { 20 public: 21 // Struct used to represent each entry in the list. 22 struct Source { 23 // Id of the source. 24 content::DesktopMediaID id; 25 26 // Name of the source that should be shown to the user. 27 base::string16 name; 28 29 // The thumbnail for the source. 30 gfx::ImageSkia thumbnail; 31 }; 32 ~DesktopMediaList()33 virtual ~DesktopMediaList() {} 34 35 // Sets time interval between updates. By default list of sources and their 36 // thumbnail are updated once per second. If called after StartUpdating() then 37 // it will take effect only after the next update. 38 virtual void SetUpdatePeriod(base::TimeDelta period) = 0; 39 40 // Sets size to which the thumbnails should be scaled. If called after 41 // StartUpdating() then some thumbnails may be still scaled to the old size 42 // until they are updated. 43 virtual void SetThumbnailSize(const gfx::Size& thumbnail_size) = 0; 44 45 // Sets ID of the hosting desktop picker dialog. The window with this ID will 46 // be filtered out from the list of sources. 47 virtual void SetViewDialogWindowId(content::DesktopMediaID::Id dialog_id) = 0; 48 49 // Starts updating the model. The model is initially empty, so OnSourceAdded() 50 // notifications will be generated for each existing source as it is 51 // enumerated. After the initial enumeration the model will be refreshed based 52 // on the update period, and notifications generated only for changes in the 53 // model. 54 virtual void StartUpdating(DesktopMediaListObserver* observer) = 0; 55 56 virtual int GetSourceCount() const = 0; 57 virtual const Source& GetSource(int index) const = 0; 58 }; 59 60 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_ 61