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