Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: chrome/browser/media/native_desktop_media_list.h

Issue 1503563004: Desktop chrome tab capture-chooseDesktopMedia() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review round 1 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_NATIVE_DESKTOP_MEDIA_LIST_H_ 5 #ifndef CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_
6 #define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ 6 #define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "chrome/browser/media/desktop_media_list.h" 12 #include "chrome/browser/media/desktop_media_list.h"
13 #include "content/public/browser/desktop_media_id.h" 13 #include "content/public/browser/desktop_media_id.h"
14 #include "ui/gfx/image/image.h"
14 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/native_widget_types.h"
15 17
16 namespace webrtc { 18 namespace webrtc {
17 class ScreenCapturer; 19 class ScreenCapturer;
18 class WindowCapturer; 20 class WindowCapturer;
19 } 21 }
20 22
21 // Implementation of DesktopMediaList that shows native screens and 23 // Implementation of DesktopMediaList that shows native screens and
22 // native windows. 24 // native windows.
23 class NativeDesktopMediaList : public DesktopMediaList { 25 class NativeDesktopMediaList : public DesktopMediaList {
24 public: 26 public:
25 // Caller may pass NULL for either of the arguments in case when only some 27 // Caller may pass NULL for either of the arguments in case when only some
26 // types of sources the model should be populated with (e.g. it will only 28 // types of sources the model should be populated with (e.g. it will only
27 // contain windows, if |screen_capturer| is NULL). 29 // contain windows, if |screen_capturer| is NULL).
28 NativeDesktopMediaList( 30 NativeDesktopMediaList(scoped_ptr<webrtc::ScreenCapturer> screen_capturer,
29 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, 31 scoped_ptr<webrtc::WindowCapturer> window_capturer,
30 scoped_ptr<webrtc::WindowCapturer> window_capturer); 32 bool tab_capture_enabled);
31 ~NativeDesktopMediaList() override; 33 ~NativeDesktopMediaList() override;
32 34
33 // DesktopMediaList interface. 35 // DesktopMediaList interface.
34 void SetUpdatePeriod(base::TimeDelta period) override; 36 void SetUpdatePeriod(base::TimeDelta period) override;
35 void SetThumbnailSize(const gfx::Size& thumbnail_size) override; 37 void SetThumbnailSize(const gfx::Size& thumbnail_size) override;
36 void StartUpdating(DesktopMediaListObserver* observer) override; 38 void StartUpdating(DesktopMediaListObserver* observer) override;
37 int GetSourceCount() const override; 39 int GetSourceCount() const override;
38 const Source& GetSource(int index) const override; 40 const Source& GetSource(int index) const override;
39 void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override; 41 void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override;
40 42
41 private: 43 private:
42 class Worker; 44 class Worker;
43 friend class Worker; 45 friend class Worker;
44 46
45 // Struct used to represent sources list the model gets from the Worker. 47 // Struct used to represent sources list the model gets from the Worker.
46 struct SourceDescription { 48 struct SourceDescription {
47 SourceDescription(content::DesktopMediaID id, const base::string16& name); 49 SourceDescription(content::DesktopMediaID id, const base::string16& name);
48
49 content::DesktopMediaID id; 50 content::DesktopMediaID id;
50 base::string16 name; 51 base::string16 name;
51 }; 52 };
52 53
53 // Order comparator for sources. Used to sort list of sources. 54 // Order comparator for sources. Used to sort list of sources.
54 static bool CompareSources(const SourceDescription& a, 55 static bool CompareSources(const SourceDescription& a,
55 const SourceDescription& b); 56 const SourceDescription& b);
56 57
57 // Post a task for the |worker_| to update list of windows and get thumbnails. 58 // Post a task for the |worker_| to update list of windows and get thumbnails.
58 void Refresh(); 59 void Refresh();
59 60
61 // Get the source descriptions for tabs.
62 void GetTabSourceDescriptions(std::vector<SourceDescription>& tab_sources);
miu 2015/12/12 00:00:33 style guide: You must pass by pointer, not by refe
GeorgeZ 2015/12/14 18:33:07 Done.
63
60 // Called by |worker_| to refresh the model. First it posts tasks for 64 // Called by |worker_| to refresh the model. First it posts tasks for
61 // OnSourcesList() with the fresh list of sources, then follows with 65 // OnSourcesList() with the fresh list of sources, then follows with
62 // OnSourceThumbnail() for each changed thumbnail and then calls 66 // OnSourceThumbnail() or OnSourceTabThumbnail() for each changed thumbnail
63 // OnRefreshFinished() at the end. 67 // and then calls OnRefreshFinished() at the end.
64 void OnSourcesList(const std::vector<SourceDescription>& sources); 68 void OnSourcesList(const std::vector<SourceDescription>& sources);
65 void OnSourceThumbnail(int index, const gfx::ImageSkia& thumbnail); 69 void OnSourceThumbnail(int index, const gfx::ImageSkia& thumbnail);
70 void OnSourceTabThumbnail(SourceDescription source);
66 void OnRefreshFinished(); 71 void OnRefreshFinished();
67 72
68 // Capturers specified in SetCapturers() and passed to the |worker_| later. 73 // Capturers specified in SetCapturers() and passed to the |worker_| later.
69 scoped_ptr<webrtc::ScreenCapturer> screen_capturer_; 74 scoped_ptr<webrtc::ScreenCapturer> screen_capturer_;
70 scoped_ptr<webrtc::WindowCapturer> window_capturer_; 75 scoped_ptr<webrtc::WindowCapturer> window_capturer_;
71 76
77 // Whether allow tab capture.
78 const bool tab_capture_enabled_;
79
80 // Map between tab id and corresponding favicon.
81 std::map<int, gfx::ImageSkia> tab_icon_map_;
miu 2015/12/12 00:00:33 Please make the key a std::pair<int, int> instead.
GeorgeZ 2015/12/14 18:33:07 Done.
82
72 // Time interval between mode updates. 83 // Time interval between mode updates.
73 base::TimeDelta update_period_; 84 base::TimeDelta update_period_;
74 85
75 // Size of thumbnails generated by the model. 86 // Size of thumbnails generated by the model.
76 gfx::Size thumbnail_size_; 87 gfx::Size thumbnail_size_;
77 88
78 // ID of the hosting dialog. 89 // ID of the hosting dialog.
79 content::DesktopMediaID view_dialog_id_; 90 content::DesktopMediaID view_dialog_id_;
80 91
81 // The observer passed to StartUpdating(). 92 // The observer passed to StartUpdating().
82 DesktopMediaListObserver* observer_; 93 DesktopMediaListObserver* observer_;
83 94
84 // Task runner used for the |worker_|. 95 // Task runner used for the |worker_|.
85 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; 96 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_;
86 97
87 // An object that does all the work of getting list of sources on a background 98 // An object that does all the work of getting list of sources on a background
88 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| 99 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_|
89 // after the model is destroyed. 100 // after the model is destroyed.
90 scoped_ptr<Worker> worker_; 101 scoped_ptr<Worker> worker_;
91 102
92 // Current list of sources. 103 // Current list of sources.
93 std::vector<Source> sources_; 104 std::vector<Source> sources_;
94 105
95 base::WeakPtrFactory<NativeDesktopMediaList> weak_factory_; 106 base::WeakPtrFactory<NativeDesktopMediaList> weak_factory_;
96 107
97 DISALLOW_COPY_AND_ASSIGN(NativeDesktopMediaList); 108 DISALLOW_COPY_AND_ASSIGN(NativeDesktopMediaList);
98 }; 109 };
99 110
100 #endif // CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ 111 #endif // CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698