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