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

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

Issue 100743003: Extend content::DesktopMediaID to allow Aura windows as capture sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/browser/media/desktop_media_picker.h ('k') | chrome/browser/media/native_desktop_media_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/media_capture_devices_dispatcher.cc
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc
index 9f06105db8d78d0308736ac9527e861389ee36ab..ac79ad24bd2c86b0ac0334ce1b1ee21e2f71d1bb 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.cc
+++ b/chrome/browser/media/media_capture_devices_dispatcher.cc
@@ -24,12 +24,12 @@
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/media_devices_monitor.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/desktop_media_id.h"
#include "content/public/common/media_stream_request.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
@@ -37,6 +37,10 @@
#include "media/audio/audio_manager_base.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(OS_CHROMEOS)
+#include "ash/shell.h"
+#endif // defined(OS_CHROMEOS)
+
using content::BrowserThread;
using content::MediaStreamDevices;
@@ -268,18 +272,23 @@ void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest(
return;
}
- // First check if Desktop Capture API (i.e.
- // chrome.desktopCapture.chooseDesktopMedia()) was used to generate device Id.
+ // If the device id wasn't specified then this is a screen capture request
+ // (i.e. chooseDesktopMedia() API wasn't used to generate device id).
+ if (request.requested_video_device_id.empty()) {
+ ProcessScreenCaptureAccessRequest(
+ web_contents, request, callback, extension);
+ return;
+ }
+
+ // Resolve DesktopMediaID for the specified device id.
content::DesktopMediaID media_id =
GetDesktopStreamsRegistry()->RequestMediaForStreamId(
request.requested_video_device_id, request.render_process_id,
request.render_view_id, request.security_origin);
- // If the id wasn't generated using Desktop Capture API then process it as a
- // screen capture request.
+ // Received invalid device id.
if (media_id.type == content::DesktopMediaID::TYPE_NONE) {
- ProcessScreenCaptureAccessRequest(
- web_contents, request, callback, extension);
+ callback.Run(devices, ui.Pass());
return;
}
@@ -312,23 +321,6 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest(
DCHECK_EQ(request.video_type, content::MEDIA_DESKTOP_VIDEO_CAPTURE);
- content::DesktopMediaID media_id =
- content::DesktopMediaID::Parse(request.requested_video_device_id);
- if (media_id.is_null()) {
- LOG(ERROR) << "Invalid desktop media ID: "
- << request.requested_video_device_id;
- callback.Run(devices, ui.Pass());
- return;
- }
-
- // Only screen capture can be requested without using desktop media picker.
- if (media_id.type != content::DesktopMediaID::TYPE_SCREEN) {
- LOG(ERROR) << "Unsupported desktop media ID: "
- << request.requested_video_device_id;
- callback.Run(devices, ui.Pass());
- return;
- }
-
bool loopback_audio_supported = false;
#if defined(USE_CRAS) || defined(OS_WIN)
// Currently loopback audio capture is supported only on Windows and ChromeOS.
@@ -382,6 +374,15 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest(
}
if (user_approved || component_extension) {
+ content::DesktopMediaID screen_id;
+#if defined(OS_CHROMEOS)
+ screen_id = content::DesktopMediaID::RegisterAuraWindow(
+ ash::Shell::GetInstance()->GetPrimaryRootWindow());
+#else // defined(OS_CHROMEOS)
+ screen_id =
+ content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0);
+#endif // !defined(OS_CHROMEOS)
+
bool capture_audio =
(request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE &&
loopback_audio_supported);
@@ -390,7 +391,7 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest(
// display the notification for stream capture.
bool display_notification = !component_extension;
- ui = GetDevicesForDesktopCapture(devices, media_id, capture_audio,
+ ui = GetDevicesForDesktopCapture(devices, screen_id, capture_audio,
display_notification, application_title);
}
}
« no previous file with comments | « chrome/browser/media/desktop_media_picker.h ('k') | chrome/browser/media/native_desktop_media_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698