Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / media / desktop_media_list_ash.h
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_ASH_H_
6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_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 DesktopMediaListAsh : public DesktopMediaList {
33  public:
34   enum SourceTypes {
35     SCREENS = 1,
36     WINDOWS = 2,
37   };
38
39   explicit DesktopMediaListAsh(int source_types);
40   ~DesktopMediaListAsh() override;
41
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::Id dialog_id) override;
49
50  private:
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);
54
55     content::DesktopMediaID id;
56     base::string16 name;
57   };
58
59   // Order comparator for sources. Used to sort list of sources.
60   static bool CompareSources(const SourceDescription& a,
61                              const SourceDescription& b);
62
63   void Refresh();
64   void EnumerateWindowsForRoot(
65       std::vector<DesktopMediaListAsh::SourceDescription>* windows,
66       aura::Window* root_window,
67       int container_id);
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);
73
74   int source_types_;
75
76   // Time interval between mode updates.
77   base::TimeDelta update_period_;
78
79   // Size of thumbnails generated by the model.
80   gfx::Size thumbnail_size_;
81
82   // ID of the hosting dialog.
83   content::DesktopMediaID::Id view_dialog_id_;
84
85   // The observer passed to StartUpdating().
86   DesktopMediaListObserver* observer_;
87
88   // Current list of sources.
89   std::vector<Source> sources_;
90
91   int pending_window_capture_requests_;
92
93   base::WeakPtrFactory<DesktopMediaListAsh> weak_factory_;
94
95   DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAsh);
96 };
97
98 #endif  // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_ASH_H_