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

Side by Side Diff: chrome/browser/media/combined_desktop_media_list.cc

Issue 1622733002: Add CombinedDesktopMediaList class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media/combined_desktop_media_list.h"
6
7 CombinedDesktopMediaList::CombinedDesktopMediaList(
8 std::vector<scoped_ptr<DesktopMediaList>>& media_lists) {
9 DCHECK(media_lists.size());
10 media_lists_ = std::move(media_lists);
Sergey Ulanov 2016/01/27 00:36:31 This can be moved to the initializer list instead
GeorgeZ 2016/01/27 22:57:16 Done.
11 }
12
13 CombinedDesktopMediaList::~CombinedDesktopMediaList() {}
14
15 void CombinedDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {
16 for (auto& list : media_lists_)
Sergey Ulanov 2016/01/27 00:36:31 const auto&?
GeorgeZ 2016/01/27 22:57:16 Done.
17 list->SetUpdatePeriod(period);
18 }
19
20 void CombinedDesktopMediaList::SetThumbnailSize(
21 const gfx::Size& thumbnail_size) {
22 for (auto& list : media_lists_)
23 list->SetThumbnailSize(thumbnail_size);
24 }
25
26 void CombinedDesktopMediaList::SetViewDialogWindowId(
27 content::DesktopMediaID dialog_id) {
28 for (auto& list : media_lists_)
29 list->SetViewDialogWindowId(dialog_id);
30 }
31
32 void CombinedDesktopMediaList::StartUpdating(
33 DesktopMediaListObserver* observer) {
34 observer_ = observer;
35 for (auto& list : media_lists_)
36 list->StartUpdating(this);
37 }
38
39 int CombinedDesktopMediaList::GetSourceCount() const {
40 int count = 0;
41 for (auto& list : media_lists_)
42 count += list->GetSourceCount();
43
44 return count;
45 }
46
47 const DesktopMediaList::Source& CombinedDesktopMediaList::GetSource(
48 int index) const {
49 for (auto& list : media_lists_) {
50 int count = list->GetSourceCount();
51 if (index < count)
52 return list->GetSource(index);
53
54 index -= count;
55 }
56
57 NOTREACHED();
58 return media_lists_[0]->GetSource(0);
59 }
60
61 void CombinedDesktopMediaList::OnSourceAdded(DesktopMediaList* list,
62 int index) {
63 int count = 0;
64 for (auto& cur_list : media_lists_) {
65 if (cur_list.get() == list) {
66 observer_->OnSourceAdded(this, count + index);
67 return;
68 }
69 count += cur_list->GetSourceCount();
70 }
71
72 NOTREACHED();
73 }
74
75 void CombinedDesktopMediaList::OnSourceRemoved(DesktopMediaList* list,
76 int index) {
77 int count = 0;
78 for (auto& cur_list : media_lists_) {
79 if (cur_list.get() == list) {
80 observer_->OnSourceRemoved(this, count + index);
81 return;
82 }
83 count += cur_list->GetSourceCount();
84 }
85
86 NOTREACHED();
87 }
88
89 void CombinedDesktopMediaList::OnSourceMoved(DesktopMediaList* list,
90 int old_index,
91 int new_index) {
92 int count = 0;
93 for (auto& cur_list : media_lists_) {
94 if (cur_list.get() == list) {
95 observer_->OnSourceMoved(this, count + old_index, count + new_index);
96 return;
97 }
98 count += cur_list->GetSourceCount();
99 }
100
101 NOTREACHED();
102 }
103
104 void CombinedDesktopMediaList::OnSourceNameChanged(DesktopMediaList* list,
105 int index) {
106 int count = 0;
107 for (auto& cur_list : media_lists_) {
108 if (cur_list.get() == list) {
109 observer_->OnSourceNameChanged(this, count + index);
110 return;
111 }
112 count += cur_list->GetSourceCount();
113 }
114
115 NOTREACHED();
116 }
117
118 void CombinedDesktopMediaList::OnSourceThumbnailChanged(DesktopMediaList* list,
119 int index) {
120 int count = 0;
121 for (auto& cur_list : media_lists_) {
122 if (cur_list.get() == list) {
123 observer_->OnSourceThumbnailChanged(this, count + index);
124 return;
125 }
126 count += cur_list->GetSourceCount();
127 }
128
129 NOTREACHED();
130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698