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

Unified Diff: chrome/browser/media/combined_desktop_media_list.cc

Issue 1554243002: Add CombinedDesktopMediaList. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/combined_desktop_media_list.h ('k') | chrome/browser/media/desktop_media_list_ash.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/combined_desktop_media_list.cc
diff --git a/chrome/browser/media/combined_desktop_media_list.cc b/chrome/browser/media/combined_desktop_media_list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f7950e5f8104e6b036c6175d54ffb8cea37bcc98
--- /dev/null
+++ b/chrome/browser/media/combined_desktop_media_list.cc
@@ -0,0 +1,87 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/media/combined_desktop_media_list.h"
+
+CombinedDesktopMediaList::CombinedDesktopMediaList(
+ scoped_ptr<DesktopMediaList> list1,
+ scoped_ptr<DesktopMediaList> list2)
+ : list1_(std::move(list1)), list2_(std::move(list2)) {}
+
+CombinedDesktopMediaList::~CombinedDesktopMediaList() {}
+
+void CombinedDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {
+ list1_->SetUpdatePeriod(period);
+ list2_->SetUpdatePeriod(period);
+}
+
+void CombinedDesktopMediaList::SetThumbnailSize(
+ const gfx::Size& thumbnail_size) {
+ list1_->SetThumbnailSize(thumbnail_size);
+ list2_->SetThumbnailSize(thumbnail_size);
+}
+
+void CombinedDesktopMediaList::SetViewDialogWindowId(
+ content::DesktopMediaID dialog_id) {
+ list1_->SetViewDialogWindowId(dialog_id);
+ list2_->SetViewDialogWindowId(dialog_id);
+}
+
+void CombinedDesktopMediaList::StartUpdating(
+ DesktopMediaListObserver* observer) {
+ observer_ = observer;
+ list1_->StartUpdating(this);
+ list2_->StartUpdating(this);
+}
+
+int CombinedDesktopMediaList::GetSourceCount() const {
+ return list1_->GetSourceCount() + list2_->GetSourceCount();
+}
+
+const DesktopMediaList::Source& CombinedDesktopMediaList::GetSource(
+ int index) const {
+ int list1_count = list1_->GetSourceCount();
+ return (index < list1_count) ? list1_->GetSource(index)
+ : list2_->GetSource(index - list1_count);
+}
+
+void CombinedDesktopMediaList::OnSourceAdded(DesktopMediaList* list,
+ int index) {
+ observer_->OnSourceAdded(this, (list == list1_.get())
+ ? index
+ : (index + list1_->GetSourceCount()));
+}
+
+void CombinedDesktopMediaList::OnSourceRemoved(DesktopMediaList* list,
+ int index) {
+ observer_->OnSourceRemoved(this, (list == list1_.get())
+ ? index
+ : (index + list1_->GetSourceCount()));
+}
+
+void CombinedDesktopMediaList::OnSourceMoved(DesktopMediaList* list,
+ int old_index,
+ int new_index) {
+ if (list == list1_.get()) {
+ observer_->OnSourceMoved(this, old_index, new_index);
+ } else {
+ int list1_count = list1_->GetSourceCount();
+ observer_->OnSourceMoved(this, list1_count + old_index,
+ list1_count + new_index);
+ }
+}
+
+void CombinedDesktopMediaList::OnSourceNameChanged(DesktopMediaList* list,
+ int index) {
+ observer_->OnSourceNameChanged(
+ this,
+ (list == list1_.get()) ? index : (index + list1_->GetSourceCount()));
+}
+
+void CombinedDesktopMediaList::OnSourceThumbnailChanged(DesktopMediaList* list,
+ int index) {
+ observer_->OnSourceThumbnailChanged(
+ this,
+ (list == list1_.get()) ? index : (index + list1_->GetSourceCount()));
+}
« no previous file with comments | « chrome/browser/media/combined_desktop_media_list.h ('k') | chrome/browser/media/desktop_media_list_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698