OLD | NEW |
(Empty) | |
| 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_ASH_DESKTOP_MEDIA_LIST_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ASH_DESKTOP_MEDIA_LIST_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/sequenced_task_runner.h" |
| 12 #include "chrome/browser/media/desktop_media_list.h" |
| 13 #include "content/public/browser/desktop_media_id.h" |
| 14 |
| 15 class SkBitmap; |
| 16 |
| 17 namespace aura { |
| 18 class Window; |
| 19 } |
| 20 |
| 21 namespace cc { |
| 22 class CopyOutputResult; |
| 23 class SingleReleaseCallback; |
| 24 } |
| 25 |
| 26 namespace gfx { |
| 27 class Image; |
| 28 } |
| 29 |
| 30 // Implementation of DesktopMediaList that shows native screens and |
| 31 // native windows. |
| 32 class AshDesktopMediaList : public DesktopMediaList { |
| 33 public: |
| 34 enum SourceTypes { |
| 35 SCREENS = 1, |
| 36 WINDOWS = 2, |
| 37 }; |
| 38 |
| 39 explicit AshDesktopMediaList(int source_types); |
| 40 virtual ~AshDesktopMediaList(); |
| 41 |
| 42 // DesktopMediaList interface. |
| 43 virtual void SetUpdatePeriod(base::TimeDelta period) OVERRIDE; |
| 44 virtual void SetThumbnailSize(const gfx::Size& thumbnail_size) OVERRIDE; |
| 45 virtual void StartUpdating(DesktopMediaListObserver* observer) OVERRIDE; |
| 46 virtual int GetSourceCount() const OVERRIDE; |
| 47 virtual const Source& GetSource(int index) const OVERRIDE; |
| 48 virtual void SetViewDialogWindowId( |
| 49 content::DesktopMediaID::Id dialog_id) OVERRIDE; |
| 50 |
| 51 private: |
| 52 // Struct used to represent sources list the model gets from the Worker. |
| 53 struct SourceDescription { |
| 54 SourceDescription(content::DesktopMediaID id, const base::string16& name); |
| 55 |
| 56 content::DesktopMediaID id; |
| 57 base::string16 name; |
| 58 }; |
| 59 |
| 60 // Order comparator for sources. Used to sort list of sources. |
| 61 static bool CompareSources(const SourceDescription& a, |
| 62 const SourceDescription& b); |
| 63 |
| 64 void Refresh(); |
| 65 void EnumerateWindowsForRoot( |
| 66 std::vector<AshDesktopMediaList::SourceDescription>* windows, |
| 67 aura::Window* root_window, |
| 68 int container_id); |
| 69 void EnumerateSources( |
| 70 std::vector<AshDesktopMediaList::SourceDescription>* windows); |
| 71 void CaptureThumbnail(content::DesktopMediaID id, aura::Window* window); |
| 72 void OnThumbnailCaptured(content::DesktopMediaID id, |
| 73 const gfx::Image& image); |
| 74 |
| 75 int source_types_; |
| 76 |
| 77 // Time interval between mode updates. |
| 78 base::TimeDelta update_period_; |
| 79 |
| 80 // Size of thumbnails generated by the model. |
| 81 gfx::Size thumbnail_size_; |
| 82 |
| 83 // ID of the hosting dialog. |
| 84 content::DesktopMediaID::Id view_dialog_id_; |
| 85 |
| 86 // The observer passed to StartUpdating(). |
| 87 DesktopMediaListObserver* observer_; |
| 88 |
| 89 // Current list of sources. |
| 90 std::vector<Source> sources_; |
| 91 |
| 92 int pending_window_capture_requests_; |
| 93 |
| 94 base::WeakPtrFactory<AshDesktopMediaList> weak_factory_; |
| 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(AshDesktopMediaList); |
| 97 }; |
| 98 |
| 99 #endif // CHROME_BROWSER_MEDIA_ASH_DESKTOP_MEDIA_LIST_H_ |
OLD | NEW |