parent
92cfc4a62d
commit
a864167d46
8 changed files with 100 additions and 93 deletions
|
@ -712,7 +712,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
|||
bool WebContents::CheckMediaAccessPermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) {
|
||||
blink::MediaStreamType type) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
|
|
|
@ -387,7 +387,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
bool final_update) override;
|
||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) override;
|
||||
blink::MediaStreamType type) override;
|
||||
void RequestMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
|
|
|
@ -7,18 +7,16 @@
|
|||
#include "base/logging.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/media_capture_devices.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
using content::BrowserThread;
|
||||
using content::MediaStreamDevices;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// Finds a device in |devices| that has |device_id|, or NULL if not found.
|
||||
const content::MediaStreamDevice* FindDeviceWithId(
|
||||
const content::MediaStreamDevices& devices,
|
||||
const blink::MediaStreamDevice* FindDeviceWithId(
|
||||
const blink::MediaStreamDevices& devices,
|
||||
const std::string& device_id) {
|
||||
auto iter = devices.begin();
|
||||
for (; iter != devices.end(); ++iter) {
|
||||
|
@ -29,11 +27,6 @@ const content::MediaStreamDevice* FindDeviceWithId(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const MediaStreamDevices& EmptyDevices() {
|
||||
static MediaStreamDevices* devices = new MediaStreamDevices;
|
||||
return *devices;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
|
||||
|
@ -49,75 +42,75 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
|
|||
|
||||
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
|
||||
|
||||
const MediaStreamDevices&
|
||||
const blink::MediaStreamDevices&
|
||||
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
if (is_device_enumeration_disabled_)
|
||||
return EmptyDevices();
|
||||
return test_audio_devices_;
|
||||
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
|
||||
}
|
||||
|
||||
const MediaStreamDevices&
|
||||
const blink::MediaStreamDevices&
|
||||
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
if (is_device_enumeration_disabled_)
|
||||
return EmptyDevices();
|
||||
return test_video_devices_;
|
||||
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
||||
bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices) {
|
||||
blink::MediaStreamDevices* devices) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
DCHECK(audio || video);
|
||||
|
||||
if (audio) {
|
||||
const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
||||
const blink::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
}
|
||||
|
||||
if (video) {
|
||||
const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
||||
const blink::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
}
|
||||
}
|
||||
|
||||
const content::MediaStreamDevice*
|
||||
const blink::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
|
||||
const std::string& requested_audio_device_id) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevice* const device =
|
||||
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
const blink::MediaStreamDevice* const device =
|
||||
FindDeviceWithId(audio_devices, requested_audio_device_id);
|
||||
return device;
|
||||
}
|
||||
|
||||
const content::MediaStreamDevice*
|
||||
const blink::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
if (audio_devices.empty())
|
||||
return nullptr;
|
||||
return &(*audio_devices.begin());
|
||||
}
|
||||
|
||||
const content::MediaStreamDevice*
|
||||
const blink::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetRequestedVideoDevice(
|
||||
const std::string& requested_video_device_id) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
const content::MediaStreamDevice* const device =
|
||||
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
const blink::MediaStreamDevice* const device =
|
||||
FindDeviceWithId(video_devices, requested_video_device_id);
|
||||
return device;
|
||||
}
|
||||
|
||||
const content::MediaStreamDevice*
|
||||
const blink::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
if (video_devices.empty())
|
||||
return nullptr;
|
||||
return &(*video_devices.begin());
|
||||
|
@ -136,7 +129,7 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
|||
int render_view_id,
|
||||
int page_request_id,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType stream_type,
|
||||
blink::MediaStreamType stream_type,
|
||||
content::MediaRequestState state) {}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
|
||||
|
@ -146,7 +139,7 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
|
|||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
content::MediaStreamType stream_type,
|
||||
blink::MediaStreamType stream_type,
|
||||
bool is_secure) {}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
#include "base/memory/singleton.h"
|
||||
#include "content/public/browser/media_observer.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
#include "content/public/browser/media_stream_request.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -20,8 +21,8 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
static MediaCaptureDevicesDispatcher* GetInstance();
|
||||
|
||||
// Methods for observers. Called on UI thread.
|
||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
||||
const blink::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const blink::MediaStreamDevices& GetVideoCaptureDevices();
|
||||
|
||||
// Helper to get the default devices which can be used by the media request.
|
||||
// Uses the first available devices if the default devices are not available.
|
||||
|
@ -30,19 +31,19 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// Called on the UI thread.
|
||||
void GetDefaultDevices(bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices);
|
||||
blink::MediaStreamDevices* devices);
|
||||
|
||||
// Helpers for picking particular requested devices, identified by raw id.
|
||||
// If the device requested is not available it will return NULL.
|
||||
const content::MediaStreamDevice* GetRequestedAudioDevice(
|
||||
const blink::MediaStreamDevice* GetRequestedAudioDevice(
|
||||
const std::string& requested_audio_device_id);
|
||||
const content::MediaStreamDevice* GetRequestedVideoDevice(
|
||||
const blink::MediaStreamDevice* GetRequestedVideoDevice(
|
||||
const std::string& requested_video_device_id);
|
||||
|
||||
// Returns the first available audio or video device, or NULL if no devices
|
||||
// are available.
|
||||
const content::MediaStreamDevice* GetFirstAvailableAudioDevice();
|
||||
const content::MediaStreamDevice* GetFirstAvailableVideoDevice();
|
||||
const blink::MediaStreamDevice* GetFirstAvailableAudioDevice();
|
||||
const blink::MediaStreamDevice* GetFirstAvailableVideoDevice();
|
||||
|
||||
// Unittests that do not require actual device enumeration should call this
|
||||
// API on the singleton. It is safe to call this multiple times on the
|
||||
|
@ -56,14 +57,14 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
int render_view_id,
|
||||
int page_request_id,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType stream_type,
|
||||
blink::MediaStreamType stream_type,
|
||||
content::MediaRequestState state) override;
|
||||
void OnCreatingAudioStream(int render_process_id,
|
||||
int render_view_id) override;
|
||||
void OnSetCapturingLinkSecured(int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
content::MediaStreamType stream_type,
|
||||
blink::MediaStreamType stream_type,
|
||||
bool is_secure) override;
|
||||
|
||||
private:
|
||||
|
@ -72,6 +73,12 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
MediaCaptureDevicesDispatcher();
|
||||
~MediaCaptureDevicesDispatcher() override;
|
||||
|
||||
// Only for testing, a list of cached audio capture devices.
|
||||
blink::MediaStreamDevices test_audio_devices_;
|
||||
|
||||
// Only for testing, a list of cached video capture devices.
|
||||
blink::MediaStreamDevices test_video_devices_;
|
||||
|
||||
// Flag used by unittests to disable device enumeration.
|
||||
bool is_device_enumeration_disabled_;
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
|
||||
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
#include "content/public/browser/media_stream_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
bool HasAnyAvailableDevice() {
|
||||
const content::MediaStreamDevices& audio_devices =
|
||||
const blink::MediaStreamDevices& audio_devices =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevices& video_devices =
|
||||
const blink::MediaStreamDevices& video_devices =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
|
||||
|
||||
return !audio_devices.empty() || !video_devices.empty();
|
||||
|
@ -34,33 +34,33 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
|||
// For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam
|
||||
// and microphone to avoid popping two infobars.
|
||||
microphone_requested_(
|
||||
request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
|
||||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
|
||||
request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE ||
|
||||
request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
|
||||
webcam_requested_(
|
||||
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
|
||||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
|
||||
request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE ||
|
||||
request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
|
||||
|
||||
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
||||
if (!callback_.is_null()) {
|
||||
std::move(callback_).Run(content::MediaStreamDevices(),
|
||||
content::MEDIA_DEVICE_INVALID_STATE,
|
||||
std::move(callback_).Run(blink::MediaStreamDevices(),
|
||||
blink::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
}
|
||||
|
||||
bool MediaStreamDevicesController::TakeAction() {
|
||||
// Do special handling of desktop screen cast.
|
||||
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE ||
|
||||
request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE ||
|
||||
request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE ||
|
||||
request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||
if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE ||
|
||||
request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE ||
|
||||
request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE ||
|
||||
request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||
HandleUserMediaRequest();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deny the request if there is no device attached to the OS.
|
||||
if (!HasAnyAvailableDevice()) {
|
||||
Deny(content::MEDIA_DEVICE_NO_HARDWARE);
|
||||
Deny(blink::MEDIA_DEVICE_NO_HARDWARE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,14 +70,14 @@ bool MediaStreamDevicesController::TakeAction() {
|
|||
|
||||
void MediaStreamDevicesController::Accept() {
|
||||
// Get the default devices for the request.
|
||||
content::MediaStreamDevices devices;
|
||||
blink::MediaStreamDevices devices;
|
||||
if (microphone_requested_ || webcam_requested_) {
|
||||
switch (request_.request_type) {
|
||||
case content::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
||||
const content::MediaStreamDevice* device = nullptr;
|
||||
case blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
||||
const blink::MediaStreamDevice* device = nullptr;
|
||||
// For open device request pick the desired device or fall back to the
|
||||
// first available of the given type.
|
||||
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||
if (request_.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||
device =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||
|
@ -86,7 +86,7 @@ void MediaStreamDevicesController::Accept() {
|
|||
device = MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetFirstAvailableAudioDevice();
|
||||
}
|
||||
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
} else if (request_.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
// Pepper API opens only one device at a time.
|
||||
device =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
|
@ -101,13 +101,13 @@ void MediaStreamDevicesController::Accept() {
|
|||
devices.push_back(*device);
|
||||
break;
|
||||
}
|
||||
case content::MEDIA_GENERATE_STREAM: {
|
||||
case blink::MEDIA_GENERATE_STREAM: {
|
||||
bool needs_audio_device = microphone_requested_;
|
||||
bool needs_video_device = webcam_requested_;
|
||||
|
||||
// Get the exact audio or video device if an id is specified.
|
||||
if (!request_.requested_audio_device_id.empty()) {
|
||||
const content::MediaStreamDevice* audio_device =
|
||||
const blink::MediaStreamDevice* audio_device =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||
if (audio_device) {
|
||||
|
@ -116,7 +116,7 @@ void MediaStreamDevicesController::Accept() {
|
|||
}
|
||||
}
|
||||
if (!request_.requested_video_device_id.empty()) {
|
||||
const content::MediaStreamDevice* video_device =
|
||||
const blink::MediaStreamDevice* video_device =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetRequestedVideoDevice(request_.requested_video_device_id);
|
||||
if (video_device) {
|
||||
|
@ -133,40 +133,45 @@ void MediaStreamDevicesController::Accept() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case content::MEDIA_DEVICE_ACCESS:
|
||||
case blink::MEDIA_DEVICE_ACCESS: {
|
||||
// Get the default devices for the request.
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
|
||||
microphone_requested_, webcam_requested_, &devices);
|
||||
break;
|
||||
}
|
||||
case blink::MEDIA_DEVICE_UPDATE: {
|
||||
NOTREACHED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::move(callback_).Run(devices, content::MEDIA_DEVICE_OK,
|
||||
std::move(callback_).Run(devices, blink::MEDIA_DEVICE_OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny(
|
||||
content::MediaStreamRequestResult result) {
|
||||
std::move(callback_).Run(content::MediaStreamDevices(), result,
|
||||
blink::MediaStreamRequestResult result) {
|
||||
std::move(callback_).Run(blink::MediaStreamDevices(), result,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::HandleUserMediaRequest() {
|
||||
content::MediaStreamDevices devices;
|
||||
blink::MediaStreamDevices devices;
|
||||
|
||||
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE) {
|
||||
devices.push_back(content::MediaStreamDevice(
|
||||
content::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", ""));
|
||||
if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE) {
|
||||
devices.push_back(
|
||||
blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", ""));
|
||||
}
|
||||
if (request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE) {
|
||||
devices.push_back(content::MediaStreamDevice(
|
||||
content::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", ""));
|
||||
if (request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE) {
|
||||
devices.push_back(
|
||||
blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", ""));
|
||||
}
|
||||
if (request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) {
|
||||
devices.push_back(content::MediaStreamDevice(
|
||||
content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
|
||||
if (request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) {
|
||||
devices.push_back(blink::MediaStreamDevice(
|
||||
blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
|
||||
}
|
||||
if (request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||
if (request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||
content::DesktopMediaID screen_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).
|
||||
|
@ -179,13 +184,13 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
|
|||
}
|
||||
|
||||
devices.push_back(
|
||||
content::MediaStreamDevice(content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE,
|
||||
screen_id.ToString(), "Screen"));
|
||||
blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE,
|
||||
screen_id.ToString(), "Screen"));
|
||||
}
|
||||
|
||||
std::move(callback_).Run(devices,
|
||||
devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE
|
||||
: content::MEDIA_DEVICE_OK,
|
||||
devices.empty() ? blink::MEDIA_DEVICE_NO_HARDWARE
|
||||
: blink::MEDIA_DEVICE_OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -21,7 +22,7 @@ class MediaStreamDevicesController {
|
|||
|
||||
// Explicitly accept or deny the request.
|
||||
void Accept();
|
||||
void Deny(content::MediaStreamRequestResult result);
|
||||
void Deny(blink::MediaStreamRequestResult result);
|
||||
|
||||
private:
|
||||
// Handle the request of desktop or tab screen cast.
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
namespace {
|
||||
|
||||
std::string MediaStreamTypeToString(content::MediaStreamType type) {
|
||||
std::string MediaStreamTypeToString(blink::MediaStreamType type) {
|
||||
switch (type) {
|
||||
case content::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE:
|
||||
case blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE:
|
||||
return "audio";
|
||||
case content::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE:
|
||||
case blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE:
|
||||
return "video";
|
||||
default:
|
||||
return "unknown";
|
||||
|
@ -40,7 +40,7 @@ void MediaAccessAllowed(const content::MediaStreamRequest& request,
|
|||
if (allowed)
|
||||
controller.TakeAction();
|
||||
else
|
||||
controller.Deny(content::MEDIA_DEVICE_PERMISSION_DENIED);
|
||||
controller.Deny(blink::MEDIA_DEVICE_PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
void OnPointerLockResponse(content::WebContents* web_contents, bool allowed) {
|
||||
|
@ -105,11 +105,11 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
|
|||
base::DictionaryValue details;
|
||||
std::unique_ptr<base::ListValue> media_types(new base::ListValue);
|
||||
if (request.audio_type ==
|
||||
content::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||
blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||
media_types->AppendString("audio");
|
||||
}
|
||||
if (request.video_type ==
|
||||
content::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
media_types->AppendString("video");
|
||||
}
|
||||
details.SetList("mediaTypes", std::move(media_types));
|
||||
|
@ -145,7 +145,7 @@ void WebContentsPermissionHelper::RequestOpenExternalPermission(
|
|||
|
||||
bool WebContentsPermissionHelper::CheckMediaAccessPermission(
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) const {
|
||||
blink::MediaStreamType type) const {
|
||||
base::DictionaryValue details;
|
||||
details.SetString("securityOrigin", security_origin.spec());
|
||||
details.SetString("mediaType", MediaStreamTypeToString(type));
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
#ifndef ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
|
||||
#define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
|
||||
|
||||
#include "content/public/browser/media_stream_request.h"
|
||||
#include "content/public/browser/permission_type.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -36,7 +37,7 @@ class WebContentsPermissionHelper
|
|||
|
||||
// Synchronous Checks
|
||||
bool CheckMediaAccessPermission(const GURL& security_origin,
|
||||
content::MediaStreamType type) const;
|
||||
blink::MediaStreamType type) const;
|
||||
|
||||
private:
|
||||
explicit WebContentsPermissionHelper(content::WebContents* web_contents);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue