Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2401)

Unified Diff: chrome/browser/media/desktop_media_list_ash.cc

Issue 615133002: Add support for a virtual display on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ash/ dep from content Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | content/browser/media/capture/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | content/browser/media/capture/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698