| 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 cea1883c5b038e152c7cfcd6c8156b076bf9e385..decffca7f5de3bb8e7f878ba65c5827e7105b882 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;
|
|
|
| @@ -235,18 +239,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;
|
| }
|
|
|
| @@ -287,23 +296,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.
|
| @@ -349,8 +341,17 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest(
|
| }
|
|
|
| if (user_approved || component_extension) {
|
| - devices.push_back(content::MediaStreamDevice(
|
| - content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen"));
|
| + 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)
|
| + devices.push_back(
|
| + content::MediaStreamDevice(content::MEDIA_DESKTOP_VIDEO_CAPTURE,
|
| + screen_id.ToString(), "Screen"));
|
| if (request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE &&
|
| loopback_audio_supported) {
|
| // Use the special loopback device ID for system audio capture.
|
|
|