| OLD | NEW |
| (Empty) |
| 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 #include "chrome/browser/media/fake_desktop_media_list.h" | |
| 6 | |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 #include "chrome/browser/media/desktop_media_list_observer.h" | |
| 9 #include "ui/gfx/skia_util.h" | |
| 10 | |
| 11 FakeDesktopMediaList::FakeDesktopMediaList() : observer_(NULL) {} | |
| 12 FakeDesktopMediaList::~FakeDesktopMediaList() {} | |
| 13 | |
| 14 void FakeDesktopMediaList::AddSource(int id) { | |
| 15 AddSourceByFullMediaID( | |
| 16 content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, id)); | |
| 17 } | |
| 18 | |
| 19 void FakeDesktopMediaList::AddSourceByFullMediaID( | |
| 20 content::DesktopMediaID media_id) { | |
| 21 Source source; | |
| 22 source.id = media_id; | |
| 23 source.name = base::Int64ToString16(media_id.id); | |
| 24 | |
| 25 sources_.push_back(source); | |
| 26 observer_->OnSourceAdded(this, sources_.size() - 1); | |
| 27 } | |
| 28 | |
| 29 void FakeDesktopMediaList::RemoveSource(int index) { | |
| 30 sources_.erase(sources_.begin() + index); | |
| 31 observer_->OnSourceRemoved(this, index); | |
| 32 } | |
| 33 | |
| 34 void FakeDesktopMediaList::MoveSource(int old_index, int new_index) { | |
| 35 Source source = sources_[old_index]; | |
| 36 sources_.erase(sources_.begin() + old_index); | |
| 37 sources_.insert(sources_.begin() + new_index, source); | |
| 38 observer_->OnSourceMoved(this, old_index, new_index); | |
| 39 } | |
| 40 | |
| 41 void FakeDesktopMediaList::SetSourceThumbnail(int index) { | |
| 42 sources_[index].thumbnail = thumbnail_; | |
| 43 observer_->OnSourceThumbnailChanged(this, index); | |
| 44 } | |
| 45 | |
| 46 void FakeDesktopMediaList::SetSourceName(int index, base::string16 name) { | |
| 47 sources_[index].name = name; | |
| 48 observer_->OnSourceNameChanged(this, index); | |
| 49 } | |
| 50 | |
| 51 void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {} | |
| 52 | |
| 53 void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {} | |
| 54 | |
| 55 void FakeDesktopMediaList::SetViewDialogWindowId( | |
| 56 content::DesktopMediaID dialog_id) {} | |
| 57 | |
| 58 void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) { | |
| 59 observer_ = observer; | |
| 60 | |
| 61 SkBitmap bitmap; | |
| 62 bitmap.allocN32Pixels(150, 150); | |
| 63 bitmap.eraseARGB(255, 0, 255, 0); | |
| 64 thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 65 } | |
| 66 | |
| 67 int FakeDesktopMediaList::GetSourceCount() const { return sources_.size(); } | |
| 68 | |
| 69 const DesktopMediaList::Source& FakeDesktopMediaList::GetSource( | |
| 70 int index) const { | |
| 71 return sources_[index]; | |
| 72 } | |
| OLD | NEW |