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(index
);
27 void 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
);
34 void FakeDesktopMediaList::SetSourceThumbnail(int index
) {
35 sources_
[index
].thumbnail
= thumbnail_
;
36 observer_
->OnSourceThumbnailChanged(index
);
39 void FakeDesktopMediaList::SetSourceName(int index
, base::string16 name
) {
40 sources_
[index
].name
= name
;
41 observer_
->OnSourceNameChanged(index
);
44 void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period
) {}
46 void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size
& thumbnail_size
) {}
48 void FakeDesktopMediaList::SetViewDialogWindowId(
49 content::DesktopMediaID::Id dialog_id
) {}
51 void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver
* observer
) {
55 bitmap
.allocN32Pixels(150, 150);
56 bitmap
.eraseARGB(255, 0, 255, 0);
57 thumbnail_
= gfx::ImageSkia::CreateFrom1xBitmap(bitmap
);
60 int FakeDesktopMediaList::GetSourceCount() const { return sources_
.size(); }
62 const DesktopMediaList::Source
& FakeDesktopMediaList::GetSource(
64 return sources_
[index
];