summaryrefslogtreecommitdiffstats
path: root/src/core/media_capture_devices_dispatcher.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-07-28 17:29:14 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-14 16:43:32 +0200
commitb1d423a3fc2cb3eeacc2a3e91ac9bdd2211c2613 (patch)
tree53f39e4e7c6a76d19a92fc23fde0728e6df95fc7 /src/core/media_capture_devices_dispatcher.cpp
parentf987b713b9f4e363056bf5174a762acb5b77ed79 (diff)
Update the QtWebEngineCore library to run on top of Chromium 37
Most of the patch is about upstream classes/methods that changed. Other important details: - icu data files are now used by default - cygwin is no longer required to build on Windows - RenderFrameHost has been replacing RenderViewHost in a few places, following the separate process iframes support in Chromium - The user agent is accessed through ContentClient::GetUserAgent instead of from the command line switches Change-Id: I86cc93aff7ce31176a80b0b4a5d54025674a451c Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core/media_capture_devices_dispatcher.cpp')
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp87
1 files changed, 16 insertions, 71 deletions
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 2997576ff..d9c0db52a 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -53,7 +53,7 @@
#include "chrome/browser/media/desktop_streams_registry.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/media_capture_devices.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
@@ -80,7 +80,7 @@ const content::MediaStreamDevice *findDeviceWithId(const content::MediaStreamDev
base::string16 getContentsUrl(content::WebContents *webContents)
{
- return UTF8ToUTF16(webContents->GetURL().GetOrigin().spec());
+ return base::UTF8ToUTF16(webContents->GetURL().GetOrigin().spec());
}
scoped_ptr<content::MediaStreamUI> getDevicesForDesktopCapture(content::MediaStreamDevices &devices, content::DesktopMediaID mediaId
@@ -183,7 +183,7 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content:
BrowserThread::UI, FROM_HERE, base::Bind(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, base::Unretained(this), webContents));
}
- callback.Run(devices, scoped_ptr<content::MediaStreamUI>());
+ callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, scoped_ptr<content::MediaStreamUI>());
}
@@ -194,7 +194,6 @@ MediaCaptureDevicesDispatcher *MediaCaptureDevicesDispatcher::GetInstance()
}
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
- : m_devicesEnumerated(false)
{
// MediaCaptureDevicesDispatcher is a singleton. It should be created on
// UI thread. Otherwise, it will not receive
@@ -209,26 +208,6 @@ MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher()
{
}
-const MediaStreamDevices &MediaCaptureDevicesDispatcher::getAudioCaptureDevices()
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!m_devicesEnumerated) {
- content::EnsureMonitorCaptureDevices();
- m_devicesEnumerated = true;
- }
- return m_audioDevices;
-}
-
-const MediaStreamDevices &MediaCaptureDevicesDispatcher::getVideoCaptureDevices()
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!m_devicesEnumerated) {
- content::EnsureMonitorCaptureDevices();
- m_devicesEnumerated = true;
- }
- return m_videoDevices;
-}
-
void MediaCaptureDevicesDispatcher::Observe(int type, const content::NotificationSource &source, const content::NotificationDetails &details)
{
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -267,7 +246,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
scoped_ptr<content::MediaStreamUI> ui;
if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
- callback.Run(devices, ui.Pass());
+ callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass());
return;
}
@@ -279,15 +258,18 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
return;
}
+ // The extension name that the stream is registered with.
+ std::string originalExtensionName;
// Resolve DesktopMediaID for the specified device id.
content::DesktopMediaID mediaId =
getDesktopStreamsRegistry()->RequestMediaForStreamId(
request.requested_video_device_id, request.render_process_id,
- request.render_view_id, request.security_origin);
+ request.render_view_id, request.security_origin,
+ &originalExtensionName);
// Received invalid device id.
if (mediaId.type == content::DesktopMediaID::TYPE_NONE) {
- callback.Run(devices, ui.Pass());
+ callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass());
return;
}
@@ -299,7 +281,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
devices, mediaId, capture_audio, true,
getContentsUrl(webContents));
- callback.Run(devices, ui.Pass());
+ callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, ui.Pass());
}
void MediaCaptureDevicesDispatcher::processScreenCaptureAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request
@@ -324,7 +306,7 @@ void MediaCaptureDevicesDispatcher::processScreenCaptureAccessRequest(content::W
JavaScriptDialogManagerQt::GetInstance()->runDialogForContents(webContents, WebContentsAdapterClient::InternalAuthorizationDialog, message
, QString(), securityOrigin, dialogCallback, title);
} else
- callback.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
+ callback.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_INVALID_STATE, scoped_ptr<content::MediaStreamUI>());
}
void MediaCaptureDevicesDispatcher::handleScreenCaptureAccessRequest(content::WebContents *webContents, bool userAccepted, const base::string16 &)
@@ -349,7 +331,7 @@ void MediaCaptureDevicesDispatcher::handleScreenCaptureAccessRequest(content::We
content::MediaResponseCallback callback = queue.front().callback;
queue.pop_front();
- callback.Run(devices, ui.Pass());
+ callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, ui.Pass());
}
void MediaCaptureDevicesDispatcher::enqueueMediaAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request
@@ -377,7 +359,7 @@ void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest(content::WebConte
content::MediaStreamRequest &request = queue.front().request;
DCHECK(!it->second.empty());
- WebContentsAdapterClient *adapterClient = WebContentsViewQt::from(webContents->GetView())->client();
+ WebContentsAdapterClient *adapterClient = WebContentsViewQt::from(static_cast<content::WebContentsImpl*>(webContents)->GetView())->client();
adapterClient->runMediaAccessPermissionRequest(toQt(request.security_origin), mediaRequestFlagsForRequest(request));
}
@@ -388,7 +370,7 @@ void MediaCaptureDevicesDispatcher::getDefaultDevices(const std::string &audioDe
DCHECK(audio || video);
if (audio) {
- const content::MediaStreamDevices &audioDevices = getAudioCaptureDevices();
+ const content::MediaStreamDevices &audioDevices = content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
const content::MediaStreamDevice *device = findDeviceWithId(audioDevices, audioDeviceId);
if (!device && !audioDevices.empty())
device = &(*audioDevices.begin());
@@ -397,7 +379,7 @@ void MediaCaptureDevicesDispatcher::getDefaultDevices(const std::string &audioDe
}
if (video) {
- const content::MediaStreamDevices &videoDevices = getVideoCaptureDevices();
+ const content::MediaStreamDevices &videoDevices = content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
const content::MediaStreamDevice *device = findDeviceWithId(videoDevices, videoDeviceId);
if (!device && !videoDevices.empty())
device = &(*videoDevices.begin());
@@ -413,25 +395,7 @@ DesktopStreamsRegistry *MediaCaptureDevicesDispatcher::getDesktopStreamsRegistry
return m_desktopStreamsRegistry.get();
}
-void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged(const content::MediaStreamDevices &devices)
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::updateAudioDevicesOnUIThread,
- base::Unretained(this), devices));
-}
-
-void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged(const content::MediaStreamDevices &devices)
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::updateVideoDevicesOnUIThread,
- base::Unretained(this), devices));
-}
-
-void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int renderProcessId, int renderViewId, int pageRequestId
+void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int renderProcessId, int renderViewId, int pageRequestId, const GURL& securityOrigin
, const content::MediaStreamDevice &device, content::MediaRequestState state)
{
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -443,25 +407,6 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int renderProcess
pageRequestId, device, state));
}
-void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int /*renderProcessId*/, int /*renderViewId*/)
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-}
-
-void MediaCaptureDevicesDispatcher::updateAudioDevicesOnUIThread(const content::MediaStreamDevices &devices)
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- m_devicesEnumerated = true;
- m_audioDevices = devices;
-}
-
-void MediaCaptureDevicesDispatcher::updateVideoDevicesOnUIThread(const content::MediaStreamDevices &devices)
-{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- m_devicesEnumerated = true;
- m_videoDevices = devices;
-}
-
void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int renderProcessId, int renderViewId, int pageRequestId
, const content::MediaStreamDevice &device, content::MediaRequestState state)
{