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 ~DesktopMediaListAsh() override
;
42 // DesktopMediaList interface.
43 void SetUpdatePeriod(base::TimeDelta period
) override
;
44 void SetThumbnailSize(const gfx::Size
& thumbnail_size
) override
;
45 void StartUpdating(DesktopMediaListObserver
* observer
) override
;
46 int GetSourceCount() const override
;
47 const Source
& GetSource(int index
) const override
;
48 void SetViewDialogWindowId(content::DesktopMediaID dialog_id
) override
;
51 // Struct used to represent sources list the model gets from the Worker.
52 struct SourceDescription
{
53 SourceDescription(content::DesktopMediaID id
, const base::string16
& name
);
55 content::DesktopMediaID id
;
59 // Order comparator for sources. Used to sort list of sources.
60 static bool CompareSources(const SourceDescription
& a
,
61 const SourceDescription
& b
);
64 void EnumerateWindowsForRoot(
65 std::vector
<DesktopMediaListAsh::SourceDescription
>* windows
,
66 aura::Window
* root_window
,
68 void EnumerateSources(
69 std::vector
<DesktopMediaListAsh::SourceDescription
>* windows
);
70 void CaptureThumbnail(content::DesktopMediaID id
, aura::Window
* window
);
71 void OnThumbnailCaptured(content::DesktopMediaID id
,
72 const gfx::Image
& image
);
76 // Time interval between mode updates.
77 base::TimeDelta update_period_
;
79 // Size of thumbnails generated by the model.
80 gfx::Size thumbnail_size_
;
82 // ID of the hosting dialog.
83 content::DesktopMediaID view_dialog_id_
;
85 // The observer passed to StartUpdating().
86 DesktopMediaListObserver
* observer_
;
88 // Current list of sources.
89 std::vector
<Source
> sources_
;
91 int pending_window_capture_requests_
;
93 base::WeakPtrFactory
<DesktopMediaListAsh
> weak_factory_
;
95 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAsh
);
98 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_H_