| Index: chrome/browser/media/desktop_media_list_ash.cc
|
| diff --git a/chrome/browser/media/desktop_media_list_ash.cc b/chrome/browser/media/desktop_media_list_ash.cc
|
| index d24ec21b2b1c493942bb5472bfe57dacb2610b98..f788aa911a247f21e9ecbf3514b1ad9f6126bd33 100644
|
| --- a/chrome/browser/media/desktop_media_list_ash.cc
|
| +++ b/chrome/browser/media/desktop_media_list_ash.cc
|
| @@ -6,11 +6,14 @@
|
|
|
| #include <set>
|
|
|
| +#include "ash/display/display_controller.h"
|
| #include "ash/shell.h"
|
| #include "ash/shell_window_ids.h"
|
| #include "base/hash.h"
|
| #include "base/logging.h"
|
| +#include "base/memory/singleton.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "base/sys_info.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "chrome/browser/media/desktop_media_list_observer.h"
|
| #include "chrome/grit/generated_resources.h"
|
| @@ -18,6 +21,8 @@
|
| #include "media/base/video_util.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/compositor/dip_util.h"
|
| +#include "ui/display/chromeos/display_configurator.h"
|
| +#include "ui/gfx/display_observer.h"
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/snapshot/snapshot.h"
|
|
|
| @@ -29,6 +34,58 @@ namespace {
|
| // Update the list twice per second.
|
| const int kDefaultUpdatePeriod = 500;
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +// Watches for the creation of a virtual display and updates
|
| +// DesktopMediaID::AuraWindowRegistry.
|
| +class VirtualScreenMonitor : public gfx::DisplayObserver {
|
| + public:
|
| + VirtualScreenMonitor();
|
| + ~VirtualScreenMonitor();
|
| +
|
| + // gfx::DisplayObserver overrides:
|
| + void OnDisplayAdded(const gfx::Display& display) override;
|
| + void OnDisplayRemoved(const gfx::Display& display) override {}
|
| + void OnDisplayMetricsChanged(const gfx::Display& display,
|
| + uint32_t metrics) override {}
|
| +
|
| + // static
|
| + static VirtualScreenMonitor* GetInstance();
|
| +
|
| + private:
|
| + friend struct DefaultSingletonTraits<VirtualScreenMonitor>;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(VirtualScreenMonitor);
|
| +};
|
| +
|
| +VirtualScreenMonitor::VirtualScreenMonitor() {
|
| + gfx::Screen::GetNativeScreen()->AddObserver(this);
|
| +}
|
| +
|
| +VirtualScreenMonitor::~VirtualScreenMonitor() {
|
| +}
|
| +
|
| +// Subsequent observers (e.g. from the VirtualDisplayCapturer class) will see
|
| +// the updated virtual screen window as the observers are called in the order
|
| +// they are added.
|
| +void VirtualScreenMonitor::OnDisplayAdded(const gfx::Display& display) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + if (display.id() ==
|
| + ui::DisplayConfigurator::GetInstance()->GetVirtualDisplayId()) {
|
| + aura::Window* window = ash::Shell::GetInstance()
|
| + ->display_controller()
|
| + ->GetRootWindowForDisplayId(display.id());
|
| +
|
| + content::DesktopMediaID::RegisterVirtualScreenAuraWindow(window);
|
| + }
|
| +}
|
| +
|
| +// static
|
| +VirtualScreenMonitor* VirtualScreenMonitor::GetInstance() {
|
| + return Singleton<VirtualScreenMonitor>::get();
|
| +}
|
| +
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| } // namespace
|
|
|
| DesktopMediaListAsh::SourceDescription::SourceDescription(
|
| @@ -209,6 +266,26 @@ void DesktopMediaListAsh::EnumerateSources(
|
| sources, root_windows[i], ash::kShellWindowId_DockedContainer);
|
| }
|
| }
|
| +#if defined(OS_CHROMEOS)
|
| + // DisplayConfigurator only works when running on ChromeOS.
|
| + if (base::SysInfo::IsRunningOnChromeOS()) {
|
| + if (ui::DisplayConfigurator::GetInstance()->GetVirtualDisplayId() ==
|
| + gfx::Display::kInvalidDisplayID) {
|
| + // Instantiate the VirtualScreenMonitor object which will observe for
|
| + // the virtual display being created and store the window so that it can
|
| + // be looked up from the content::DesktopMediaID.
|
| + (void)VirtualScreenMonitor::GetInstance();
|
| + SourceDescription virtual_screen_source(
|
| + content::DesktopMediaID(
|
| + content::DesktopMediaID::TYPE_AURA_VIRTUAL_SCREEN, 0),
|
| + l10n_util::GetStringUTF16(
|
| + IDS_DESTOP_MEDIA_PICKER_VIRTUAL_SCREEN_NAME));
|
| + sources->push_back(virtual_screen_source);
|
| + // TODO(robert.bradford): crbug.com/425060 There is no thumbnail for the
|
| + // virtual screen right now.
|
| + }
|
| + }
|
| +#endif // defined(OS_CHROMEOS)
|
| }
|
|
|
| void DesktopMediaListAsh::CaptureThumbnail(content::DesktopMediaID id,
|
|
|