diff options
Diffstat (limited to 'chrome/browser/media')
-rw-r--r-- | chrome/browser/media/native_desktop_media_list.cc | 24 | ||||
-rw-r--r-- | chrome/browser/media/native_desktop_media_list_unittest.cc | 8 |
2 files changed, 26 insertions, 6 deletions
diff --git a/chrome/browser/media/native_desktop_media_list.cc b/chrome/browser/media/native_desktop_media_list.cc index 7f5128b..3e48f90 100644 --- a/chrome/browser/media/native_desktop_media_list.cc +++ b/chrome/browser/media/native_desktop_media_list.cc @@ -5,6 +5,7 @@ #include "chrome/browser/media/native_desktop_media_list.h" #include <map> +#include <sstream> #include "base/hash.h" #include "base/logging.h" @@ -134,10 +135,23 @@ void NativeDesktopMediaList::Worker::Refresh( std::vector<SourceDescription> sources; if (screen_capturer_) { - // TODO(sergeyu): Enumerate each screen when ScreenCapturer supports it. - sources.push_back(SourceDescription(DesktopMediaID( - DesktopMediaID::TYPE_SCREEN, 0), - l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SCREEN_NAME))); + webrtc::ScreenCapturer::ScreenList screens; + if (screen_capturer_->GetScreenList(&screens)) { + bool mutiple_screens = screens.size() > 1; + base::string16 title; + for (size_t i = 0; i < screens.size(); ++i) { + if (mutiple_screens) { + title = l10n_util::GetStringFUTF16Int( + IDS_DESKTOP_MEDIA_PICKER_MULTIPLE_SCREEN_NAME, + static_cast<int>(i + 1)); + } else { + title = l10n_util::GetStringUTF16( + IDS_DESKTOP_MEDIA_PICKER_SINGLE_SCREEN_NAME); + } + sources.push_back(SourceDescription(DesktopMediaID( + DesktopMediaID::TYPE_SCREEN, screens[i].id), title)); + } + } } if (window_capturer_) { @@ -171,6 +185,8 @@ void NativeDesktopMediaList::Worker::Refresh( SourceDescription& source = sources[i]; switch (source.id.type) { case DesktopMediaID::TYPE_SCREEN: + if (!screen_capturer_->SelectScreen(source.id.id)) + continue; screen_capturer_->Capture(webrtc::DesktopRegion()); DCHECK(current_frame_); break; diff --git a/chrome/browser/media/native_desktop_media_list_unittest.cc b/chrome/browser/media/native_desktop_media_list_unittest.cc index 4610ac3..83c6c42 100644 --- a/chrome/browser/media/native_desktop_media_list_unittest.cc +++ b/chrome/browser/media/native_desktop_media_list_unittest.cc @@ -52,11 +52,15 @@ class FakeScreenCapturer : public webrtc::ScreenCapturer { } virtual bool GetScreenList(ScreenList* screens) OVERRIDE { - return false; + webrtc::ScreenCapturer::Screen screen; + screen.id = 0; + screens->push_back(screen); + return true; } virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE { - return false; + EXPECT_EQ(0, id); + return true; } protected: |