Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / chrome / browser / media / fake_desktop_media_list.cc
blob982ad8d19042a5d912fff8dcc48cf345957d7834
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.
5 #include "chrome/browser/media/fake_desktop_media_list.h"
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"
11 FakeDesktopMediaList::FakeDesktopMediaList() : observer_(NULL) {}
12 FakeDesktopMediaList::~FakeDesktopMediaList() {}
14 void FakeDesktopMediaList::AddSource(int id) {
15 Source source;
16 source.id = content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, id);
17 source.name = base::Int64ToString16(id);
19 sources_.push_back(source);
20 observer_->OnSourceAdded(sources_.size() - 1);
23 void FakeDesktopMediaList::RemoveSource(int index) {
24 sources_.erase(sources_.begin() + index);
25 observer_->OnSourceRemoved(index);
28 void FakeDesktopMediaList::MoveSource(int old_index, int new_index) {
29 Source source = sources_[old_index];
30 sources_.erase(sources_.begin() + old_index);
31 sources_.insert(sources_.begin() + new_index, source);
32 observer_->OnSourceMoved(old_index, new_index);
35 void FakeDesktopMediaList::SetSourceThumbnail(int index) {
36 sources_[index].thumbnail = thumbnail_;
37 observer_->OnSourceThumbnailChanged(index);
40 void FakeDesktopMediaList::SetSourceName(int index, base::string16 name) {
41 sources_[index].name = name;
42 observer_->OnSourceNameChanged(index);
45 void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {}
47 void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {}
49 void FakeDesktopMediaList::SetViewDialogWindowId(
50 content::DesktopMediaID dialog_id) {}
52 void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) {
53 observer_ = observer;
55 SkBitmap bitmap;
56 bitmap.allocN32Pixels(150, 150);
57 bitmap.eraseARGB(255, 0, 255, 0);
58 thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
61 int FakeDesktopMediaList::GetSourceCount() const { return sources_.size(); }
63 const DesktopMediaList::Source& FakeDesktopMediaList::GetSource(
64 int index) const {
65 return sources_[index];