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 10FakeDesktopMediaList::FakeDesktopMediaList() : observer_(NULL) {} 11FakeDesktopMediaList::~FakeDesktopMediaList() {} 12 13void 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 22void FakeDesktopMediaList::RemoveSource(int index) { 23 sources_.erase(sources_.begin() + index); 24 observer_->OnSourceRemoved(index); 25} 26 27void FakeDesktopMediaList::MoveSource(int old_index, int new_index) { 28 Source source = sources_[old_index]; 29 sources_.erase(sources_.begin() + old_index); 30 sources_.insert(sources_.begin() + new_index, source); 31 observer_->OnSourceMoved(old_index, new_index); 32} 33 34void FakeDesktopMediaList::SetSourceThumbnail(int index) { 35 sources_[index].thumbnail = thumbnail_; 36 observer_->OnSourceThumbnailChanged(index); 37} 38 39void FakeDesktopMediaList::SetSourceName(int index, base::string16 name) { 40 sources_[index].name = name; 41 observer_->OnSourceNameChanged(index); 42} 43 44void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {} 45 46void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {} 47 48void FakeDesktopMediaList::SetViewDialogWindowId( 49 content::DesktopMediaID::Id dialog_id) {} 50 51void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) { 52 observer_ = observer; 53 54 SkBitmap bitmap; 55 bitmap.allocN32Pixels(150, 150); 56 bitmap.eraseARGB(255, 0, 255, 0); 57 thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 58} 59 60int FakeDesktopMediaList::GetSourceCount() const { return sources_.size(); } 61 62const DesktopMediaList::Source& FakeDesktopMediaList::GetSource( 63 int index) const { 64 return sources_[index]; 65} 66