OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ |
6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ | 6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ |
7 | 7 |
8 #include "chrome/browser/media/desktop_media_list.h" | 8 #include "chrome/browser/media/desktop_media_list.h" |
9 #include "content/public/browser/desktop_media_id.h" | 9 #include "content/public/browser/desktop_media_id.h" |
10 | 10 |
11 // Thumbnail size is 100*100 pixels | 11 // Thumbnail size is 100*100 pixels |
12 static const int kDefaultThumbnailSize = 100; | 12 static const int kDefaultThumbnailSize = 100; |
13 | 13 |
14 // Base class for DesktopMedaiList implementations. Implements logic shared | 14 // Base class for DesktopMediaList implementations. Implements logic shared |
15 // between implementations. Specifically it's responsible for keeping current | 15 // between implementations. Specifically it's responsible for keeping current |
16 // list of sources and calling the observer when the list changes. | 16 // list of sources and calling the observer when the list changes. |
17 class DesktopMediaListBase : public DesktopMediaList { | 17 class DesktopMediaListBase : public DesktopMediaList { |
18 public: | 18 public: |
19 struct SourceDescription { | |
Sergey Ulanov
2016/01/27 00:36:31
Why does it need to be public.
GeorgeZ
2016/01/27 22:57:16
Good catch. This struct was used in unit test TabD
| |
20 SourceDescription(content::DesktopMediaID id, const base::string16& name); | |
21 | |
22 content::DesktopMediaID id; | |
23 base::string16 name; | |
24 }; | |
25 | |
19 explicit DesktopMediaListBase(base::TimeDelta update_period); | 26 explicit DesktopMediaListBase(base::TimeDelta update_period); |
20 ~DesktopMediaListBase() override; | 27 ~DesktopMediaListBase() override; |
21 | 28 |
22 // DesktopMediaList interface. | 29 // DesktopMediaList interface. |
23 void SetUpdatePeriod(base::TimeDelta period) override; | 30 void SetUpdatePeriod(base::TimeDelta period) override; |
24 void SetThumbnailSize(const gfx::Size& thumbnail_size) override; | 31 void SetThumbnailSize(const gfx::Size& thumbnail_size) override; |
25 void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override; | 32 void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override; |
26 void StartUpdating(DesktopMediaListObserver* observer) override; | 33 void StartUpdating(DesktopMediaListObserver* observer) override; |
27 int GetSourceCount() const override; | 34 int GetSourceCount() const override; |
28 const Source& GetSource(int index) const override; | 35 const Source& GetSource(int index) const override; |
29 | 36 |
30 protected: | 37 protected: |
31 struct SourceDescription { | |
32 SourceDescription(content::DesktopMediaID id, const base::string16& name); | |
33 | |
34 content::DesktopMediaID id; | |
35 base::string16 name; | |
36 }; | |
37 | |
38 virtual void Refresh() = 0; | 38 virtual void Refresh() = 0; |
39 | 39 |
40 // Update source media list to observer. | 40 // Update source media list to observer. |
41 void UpdateSourcesList(const std::vector<SourceDescription>& new_sources); | 41 void UpdateSourcesList(const std::vector<SourceDescription>& new_sources); |
42 | 42 |
43 // Update a thumbnail to observer. | 43 // Update a thumbnail to observer. |
44 void UpdateSourceThumbnail(content::DesktopMediaID id, | 44 void UpdateSourceThumbnail(content::DesktopMediaID id, |
45 const gfx::ImageSkia& image); | 45 const gfx::ImageSkia& image); |
46 | 46 |
47 // Post a task for next list update. | 47 // Post a task for next list update. |
(...skipping 16 matching lines...) Expand all Loading... | |
64 | 64 |
65 // The observer passed to StartUpdating(). | 65 // The observer passed to StartUpdating(). |
66 DesktopMediaListObserver* observer_ = nullptr; | 66 DesktopMediaListObserver* observer_ = nullptr; |
67 | 67 |
68 base::WeakPtrFactory<DesktopMediaListBase> weak_factory_; | 68 base::WeakPtrFactory<DesktopMediaListBase> weak_factory_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListBase); | 70 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListBase); |
71 }; | 71 }; |
72 | 72 |
73 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ | 73 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_BASE_H_ |
OLD | NEW |