| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media/fake_desktop_media_list.h" | 5 #include "chrome/browser/media/fake_desktop_media_list.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/media/desktop_media_list_observer.h" | 8 #include "chrome/browser/media/desktop_media_list_observer.h" |
| 9 #include "ui/gfx/skia_util.h" | 9 #include "ui/gfx/skia_util.h" |
| 10 | 10 |
| 11 FakeDesktopMediaList::FakeDesktopMediaList() : observer_(NULL) {} | 11 FakeDesktopMediaList::FakeDesktopMediaList() : observer_(NULL) {} |
| 12 FakeDesktopMediaList::~FakeDesktopMediaList() {} | 12 FakeDesktopMediaList::~FakeDesktopMediaList() {} |
| 13 | 13 |
| 14 void FakeDesktopMediaList::AddSource(int id) { | 14 void FakeDesktopMediaList::AddSource(int id) { |
| 15 Source source; | 15 Source source; |
| 16 source.id = content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, id); | 16 source.id = content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, id); |
| 17 source.name = base::Int64ToString16(id); | 17 source.name = base::Int64ToString16(id); |
| 18 | 18 |
| 19 sources_.push_back(source); | 19 sources_.push_back(source); |
| 20 observer_->OnSourceAdded(sources_.size() - 1); | 20 observer_->OnSourceAdded(this, sources_.size() - 1); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void FakeDesktopMediaList::RemoveSource(int index) { | 23 void FakeDesktopMediaList::RemoveSource(int index) { |
| 24 sources_.erase(sources_.begin() + index); | 24 sources_.erase(sources_.begin() + index); |
| 25 observer_->OnSourceRemoved(index); | 25 observer_->OnSourceRemoved(this, index); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void FakeDesktopMediaList::MoveSource(int old_index, int new_index) { | 28 void FakeDesktopMediaList::MoveSource(int old_index, int new_index) { |
| 29 Source source = sources_[old_index]; | 29 Source source = sources_[old_index]; |
| 30 sources_.erase(sources_.begin() + old_index); | 30 sources_.erase(sources_.begin() + old_index); |
| 31 sources_.insert(sources_.begin() + new_index, source); | 31 sources_.insert(sources_.begin() + new_index, source); |
| 32 observer_->OnSourceMoved(old_index, new_index); | 32 observer_->OnSourceMoved(this, old_index, new_index); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void FakeDesktopMediaList::SetSourceThumbnail(int index) { | 35 void FakeDesktopMediaList::SetSourceThumbnail(int index) { |
| 36 sources_[index].thumbnail = thumbnail_; | 36 sources_[index].thumbnail = thumbnail_; |
| 37 observer_->OnSourceThumbnailChanged(index); | 37 observer_->OnSourceThumbnailChanged(this, index); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void FakeDesktopMediaList::SetSourceName(int index, base::string16 name) { | 40 void FakeDesktopMediaList::SetSourceName(int index, base::string16 name) { |
| 41 sources_[index].name = name; | 41 sources_[index].name = name; |
| 42 observer_->OnSourceNameChanged(index); | 42 observer_->OnSourceNameChanged(this, index); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {} | 45 void FakeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {} |
| 46 | 46 |
| 47 void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {} | 47 void FakeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {} |
| 48 | 48 |
| 49 void FakeDesktopMediaList::SetViewDialogWindowId( | 49 void FakeDesktopMediaList::SetViewDialogWindowId( |
| 50 content::DesktopMediaID dialog_id) {} | 50 content::DesktopMediaID dialog_id) {} |
| 51 | 51 |
| 52 void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) { | 52 void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) { |
| 53 observer_ = observer; | 53 observer_ = observer; |
| 54 | 54 |
| 55 SkBitmap bitmap; | 55 SkBitmap bitmap; |
| 56 bitmap.allocN32Pixels(150, 150); | 56 bitmap.allocN32Pixels(150, 150); |
| 57 bitmap.eraseARGB(255, 0, 255, 0); | 57 bitmap.eraseARGB(255, 0, 255, 0); |
| 58 thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 58 thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int FakeDesktopMediaList::GetSourceCount() const { return sources_.size(); } | 61 int FakeDesktopMediaList::GetSourceCount() const { return sources_.size(); } |
| 62 | 62 |
| 63 const DesktopMediaList::Source& FakeDesktopMediaList::GetSource( | 63 const DesktopMediaList::Source& FakeDesktopMediaList::GetSource( |
| 64 int index) const { | 64 int index) const { |
| 65 return sources_[index]; | 65 return sources_[index]; |
| 66 } | 66 } |
| OLD | NEW |