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.
5 #ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_H_
6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_H_
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"
22 class CopyOutputResult
;
23 class SingleReleaseCallback
;
30 // Implementation of DesktopMediaList that shows native screens and
32 class DesktopMediaListAsh
: public DesktopMediaList
{
39 explicit DesktopMediaListAsh(int source_types
);
40 virtual ~DesktopMediaListAsh();
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
;
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
);
56 content::DesktopMediaID id
;
60 // Order comparator for sources. Used to sort list of sources.
61 static bool CompareSources(const SourceDescription
& a
,
62 const SourceDescription
& b
);
65 void EnumerateWindowsForRoot(
66 std::vector
<DesktopMediaListAsh::SourceDescription
>* windows
,
67 aura::Window
* root_window
,
69 void EnumerateSources(
70 std::vector
<DesktopMediaListAsh::SourceDescription
>* windows
);
71 void CaptureThumbnail(content::DesktopMediaID id
, aura::Window
* window
);
72 void OnThumbnailCaptured(content::DesktopMediaID id
,
73 const gfx::Image
& image
);
77 // Time interval between mode updates.
78 base::TimeDelta update_period_
;
80 // Size of thumbnails generated by the model.
81 gfx::Size thumbnail_size_
;
83 // ID of the hosting dialog.
84 content::DesktopMediaID::Id view_dialog_id_
;
86 // The observer passed to StartUpdating().
87 DesktopMediaListObserver
* observer_
;
89 // Current list of sources.
90 std::vector
<Source
> sources_
;
92 int pending_window_capture_requests_
;
94 base::WeakPtrFactory
<DesktopMediaListAsh
> weak_factory_
;
96 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAsh
);
99 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_H_