commit
4e5f6a10f9
15 changed files with 270 additions and 132 deletions
|
@ -44,6 +44,16 @@ private:
|
|||
return getter_->GetURLRequestContext();
|
||||
}
|
||||
|
||||
// FIXME: We should probably allow clients to override this to implement more restrictive policies.
|
||||
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: We should probably allow clients to override this to implement more restrictive policies.
|
||||
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
|
||||
URLRequestContextGetter* getter_;
|
||||
};
|
||||
|
||||
|
@ -51,6 +61,18 @@ BrowserContext::BrowserContext() : resource_context_(new ResourceContext) {
|
|||
}
|
||||
|
||||
void BrowserContext::Initialize() {
|
||||
base::FilePath path;
|
||||
#if defined(OS_LINUX)
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
path = base::nix::GetXDGDirectory(env.get(),
|
||||
base::nix::kXdgConfigHomeEnvVar,
|
||||
base::nix::kDotConfigDir);
|
||||
#else
|
||||
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
|
||||
#endif
|
||||
|
||||
path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
|
||||
|
||||
auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences"));
|
||||
PrefServiceBuilder builder;
|
||||
builder.WithUserFilePrefs(prefs_path,
|
||||
|
@ -86,21 +108,7 @@ scoped_ptr<NetworkDelegate> BrowserContext::CreateNetworkDelegate() {
|
|||
return make_scoped_ptr(new NetworkDelegate).Pass();
|
||||
}
|
||||
|
||||
base::FilePath BrowserContext::GetPath() {
|
||||
if (!path_.empty())
|
||||
return path_;
|
||||
|
||||
base::FilePath path;
|
||||
#if defined(OS_LINUX)
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
path = base::nix::GetXDGDirectory(env.get(),
|
||||
base::nix::kXdgConfigHomeEnvVar,
|
||||
base::nix::kDotConfigDir);
|
||||
#else
|
||||
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
|
||||
#endif
|
||||
|
||||
path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
|
||||
base::FilePath BrowserContext::GetPath() const {
|
||||
return path_;
|
||||
}
|
||||
|
||||
|
@ -128,6 +136,10 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForStoragePa
|
|||
return GetRequestContext();
|
||||
}
|
||||
|
||||
void BrowserContext::RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback) {
|
||||
callback.Run(false);
|
||||
}
|
||||
|
||||
content::ResourceContext* BrowserContext::GetResourceContext() {
|
||||
return resource_context_.get();
|
||||
}
|
||||
|
@ -142,10 +154,6 @@ content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionC
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
content::SpeechRecognitionPreferences* BrowserContext::GetSpeechRecognitionPreferences() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
|||
// Subclasses should override this to provide a custom NetworkDelegate implementation.
|
||||
virtual scoped_ptr<NetworkDelegate> CreateNetworkDelegate();
|
||||
|
||||
virtual base::FilePath GetPath() OVERRIDE;
|
||||
virtual base::FilePath GetPath() const OVERRIDE;
|
||||
|
||||
private:
|
||||
class ResourceContext;
|
||||
|
@ -48,10 +48,10 @@ private:
|
|||
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
|
||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE;
|
||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory);
|
||||
virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback&) OVERRIDE;
|
||||
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
|
||||
virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
|
||||
virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE;
|
||||
virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE;
|
||||
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
|
||||
|
||||
base::FilePath path_;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "base/prefs/pref_registry_simple.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/devtools_client_host.h"
|
||||
|
@ -123,6 +123,15 @@ void InspectableWebContentsImpl::AddFileSystem() {
|
|||
void InspectableWebContentsImpl::RemoveFileSystem(const std::string& file_system_path) {
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::IndexPath(int request_id, const std::string& file_system_path) {
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::StopIndexing(int request_id) {
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::SearchInPath(int request_id, const std::string& file_system_path, const std::string& query) {
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ private:
|
|||
virtual void RequestFileSystems() OVERRIDE;
|
||||
virtual void AddFileSystem() OVERRIDE;
|
||||
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
||||
virtual void IndexPath(int request_id, const std::string& file_system_path) OVERRIDE;
|
||||
virtual void StopIndexing(int request_id) OVERRIDE;
|
||||
virtual void SearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) OVERRIDE;
|
||||
virtual void InspectedContentsClosing() OVERRIDE;
|
||||
|
||||
// content::WebContentsObserver
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#import "browser/inspectable_web_contents_view.h"
|
||||
|
||||
#import "base/memory/scoped_nsobject.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
|
||||
@class BRYInspectableWebContentsView;
|
||||
|
||||
|
@ -26,7 +26,7 @@ private:
|
|||
// Owns us.
|
||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||
|
||||
scoped_nsobject<BRYInspectableWebContentsView> view_;
|
||||
base::scoped_nsobject<BRYInspectableWebContentsView> view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
|
||||
};
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
#include "browser/media/media_capture_devices_dispatcher.h"
|
||||
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/logging.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/media_devices_monitor.h"
|
||||
#include "content/public/common/desktop_media_id.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -16,41 +17,40 @@ using content::MediaStreamDevices;
|
|||
|
||||
namespace {
|
||||
|
||||
const content::MediaStreamDevice* FindDefaultDeviceWithId(
|
||||
// Finds a device in |devices| that has |device_id|, or NULL if not found.
|
||||
const content::MediaStreamDevice* FindDeviceWithId(
|
||||
const content::MediaStreamDevices& devices,
|
||||
const std::string& device_id) {
|
||||
if (devices.empty())
|
||||
return NULL;
|
||||
|
||||
content::MediaStreamDevices::const_iterator iter = devices.begin();
|
||||
for (; iter != devices.end(); ++iter) {
|
||||
if (iter->id == device_id) {
|
||||
return &(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
return &(*devices.begin());
|
||||
return NULL;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
|
||||
return Singleton<MediaCaptureDevicesDispatcher>::get();
|
||||
}
|
||||
|
||||
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
|
||||
: devices_enumerated_(false) {}
|
||||
: devices_enumerated_(false),
|
||||
is_device_enumeration_disabled_(false) {
|
||||
// MediaCaptureDevicesDispatcher is a singleton. It should be created on
|
||||
// UI thread.
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
}
|
||||
|
||||
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
|
||||
|
||||
const MediaStreamDevices&
|
||||
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
if (!devices_enumerated_) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&content::EnsureMonitorCaptureDevices));
|
||||
if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
|
||||
content::EnsureMonitorCaptureDevices();
|
||||
devices_enumerated_ = true;
|
||||
}
|
||||
return audio_devices_;
|
||||
|
@ -59,17 +59,14 @@ MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
|||
const MediaStreamDevices&
|
||||
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
if (!devices_enumerated_) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&content::EnsureMonitorCaptureDevices));
|
||||
if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
|
||||
content::EnsureMonitorCaptureDevices();
|
||||
devices_enumerated_ = true;
|
||||
}
|
||||
return video_devices_;
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::GetRequestedDevice(
|
||||
const std::string& requested_device_id,
|
||||
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
||||
bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices) {
|
||||
|
@ -77,32 +74,58 @@ void MediaCaptureDevicesDispatcher::GetRequestedDevice(
|
|||
DCHECK(audio || video);
|
||||
|
||||
if (audio) {
|
||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevice* const device =
|
||||
FindDefaultDeviceWithId(audio_devices, requested_device_id);
|
||||
const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
}
|
||||
|
||||
if (video) {
|
||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
const content::MediaStreamDevice* const device =
|
||||
FindDefaultDeviceWithId(video_devices, requested_device_id);
|
||||
const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
||||
bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices) {
|
||||
if (audio) {
|
||||
GetRequestedDevice(std::string(), true, false, devices);
|
||||
}
|
||||
const content::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 =
|
||||
FindDeviceWithId(audio_devices, requested_audio_device_id);
|
||||
return device;
|
||||
}
|
||||
|
||||
if (video) {
|
||||
GetRequestedDevice(std::string(), false, true, devices);
|
||||
}
|
||||
const content::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||
if (audio_devices.empty())
|
||||
return NULL;
|
||||
return &(*audio_devices.begin());
|
||||
}
|
||||
|
||||
const content::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 =
|
||||
FindDeviceWithId(video_devices, requested_video_device_id);
|
||||
return device;
|
||||
}
|
||||
|
||||
const content::MediaStreamDevice*
|
||||
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||
if (video_devices.empty())
|
||||
return NULL;
|
||||
return &(*video_devices.begin());
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::DisableDeviceEnumerationForTesting() {
|
||||
is_device_enumeration_disabled_ = true;
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged(
|
||||
|
@ -126,15 +149,22 @@ void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged(
|
|||
void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
int page_request_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(
|
||||
&MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread,
|
||||
base::Unretained(this), render_process_id, render_view_id, device,
|
||||
state));
|
||||
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
|
||||
int render_process_id, int render_view_id, int stream_id,
|
||||
bool is_playing, float power_dbfs, bool clipped) {
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(
|
||||
int render_process_id,
|
||||
int render_view_id) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
|
||||
|
@ -145,17 +175,10 @@ void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
|
|||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread(
|
||||
const content::MediaStreamDevices& devices) {
|
||||
const content::MediaStreamDevices& devices){
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
devices_enumerated_ = true;
|
||||
video_devices_ = devices;
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state) {
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "base/callback.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "content/public/browser/media_observer.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -20,20 +20,35 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
public:
|
||||
static MediaCaptureDevicesDispatcher* GetInstance();
|
||||
|
||||
// Helper for picking the device that was requested for an OpenDevice request.
|
||||
// If the device requested is not available it will revert to using the first
|
||||
// available one instead or will return an empty list if no devices of the
|
||||
// requested kind are present.
|
||||
void GetRequestedDevice(const std::string& requested_device_id,
|
||||
bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices);
|
||||
// Methods for observers. Called on UI thread.
|
||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const content::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.
|
||||
// If the return list is empty, it means there is no available device on the
|
||||
// OS.
|
||||
// Called on the UI thread.
|
||||
void GetDefaultDevices(bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices);
|
||||
|
||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
||||
// 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 std::string& requested_audio_device_id);
|
||||
const content::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();
|
||||
|
||||
// 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
|
||||
// signleton.
|
||||
void DisableDeviceEnumerationForTesting();
|
||||
|
||||
// Overridden from content::MediaObserver:
|
||||
virtual void OnAudioCaptureDevicesChanged(
|
||||
|
@ -43,13 +58,18 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
virtual void OnMediaRequestStateChanged(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
int page_request_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state) OVERRIDE;
|
||||
virtual void OnAudioStreamPlayingChanged(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
int stream_id,
|
||||
bool playing) OVERRIDE {}
|
||||
bool is_playing,
|
||||
float power_dBFS,
|
||||
bool clipped) OVERRIDE;
|
||||
virtual void OnCreatingAudioStream(int render_process_id,
|
||||
int render_view_id) OVERRIDE;
|
||||
|
||||
private:
|
||||
friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
|
||||
|
@ -60,11 +80,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// Called by the MediaObserver() functions, executed on UI thread.
|
||||
void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
|
||||
void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices);
|
||||
void UpdateMediaRequestStateOnUIThread(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state);
|
||||
|
||||
// A list of cached audio capture devices.
|
||||
content::MediaStreamDevices audio_devices_;
|
||||
|
@ -75,8 +90,13 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// Flag to indicate if device enumeration has been done/doing.
|
||||
// Only accessed on UI thread.
|
||||
bool devices_enumerated_;
|
||||
|
||||
// Flag used by unittests to disable device enumeration.
|
||||
bool is_device_enumeration_disabled_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
#include "browser/media/media_stream_devices_controller.h"
|
||||
|
||||
#include "base/values.h"
|
||||
#include "browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -20,7 +19,7 @@ bool HasAnyAvailableDevice() {
|
|||
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
|
||||
|
||||
return !audio_devices.empty() || !video_devices.empty();
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -29,15 +28,39 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
|||
const content::MediaResponseCallback& callback)
|
||||
: request_(request),
|
||||
callback_(callback),
|
||||
// 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.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
|
||||
request.request_type == content::MEDIA_OPEN_DEVICE),
|
||||
webcam_requested_(
|
||||
request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
|
||||
request.request_type == content::MEDIA_OPEN_DEVICE) {
|
||||
}
|
||||
|
||||
MediaStreamDevicesController::~MediaStreamDevicesController() {}
|
||||
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
||||
if (!callback_.is_null()) {
|
||||
callback_.Run(content::MediaStreamDevices(),
|
||||
scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
}
|
||||
|
||||
bool MediaStreamDevicesController::TakeAction() {
|
||||
// Tab capture is allowed for extensions only and infobar is not shown for
|
||||
// extensions.
|
||||
if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE ||
|
||||
request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) {
|
||||
Deny();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deny the request if the security origin is empty, this happens with
|
||||
// file access without |--allow-file-access-from-files| flag.
|
||||
if (request_.security_origin.is_empty()) {
|
||||
Deny();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deny the request if there is no device attached to the OS.
|
||||
if (!HasAnyAvailableDevice()) {
|
||||
Deny();
|
||||
|
@ -53,34 +76,87 @@ void MediaStreamDevicesController::Accept() {
|
|||
content::MediaStreamDevices devices;
|
||||
if (microphone_requested_ || webcam_requested_) {
|
||||
switch (request_.request_type) {
|
||||
case content::MEDIA_OPEN_DEVICE:
|
||||
case content::MEDIA_OPEN_DEVICE: {
|
||||
const content::MediaStreamDevice* device = NULL;
|
||||
// For open device request pick the desired device or fall back to the
|
||||
// first available of the given type.
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
|
||||
request_.requested_device_id,
|
||||
microphone_requested_,
|
||||
webcam_requested_,
|
||||
&devices);
|
||||
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||
device = MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||
// TODO(wjia): Confirm this is the intended behavior.
|
||||
if (!device) {
|
||||
device = MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetFirstAvailableAudioDevice();
|
||||
}
|
||||
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||
// Pepper API opens only one device at a time.
|
||||
device = MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetRequestedVideoDevice(request_.requested_video_device_id);
|
||||
// TODO(wjia): Confirm this is the intended behavior.
|
||||
if (!device) {
|
||||
device = MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetFirstAvailableVideoDevice();
|
||||
}
|
||||
}
|
||||
if (device)
|
||||
devices.push_back(*device);
|
||||
break;
|
||||
case content::MEDIA_DEVICE_ACCESS:
|
||||
case content::MEDIA_GENERATE_STREAM:
|
||||
case content::MEDIA_ENUMERATE_DEVICES:
|
||||
} case content::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 =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||
if (audio_device) {
|
||||
devices.push_back(*audio_device);
|
||||
needs_audio_device = false;
|
||||
}
|
||||
}
|
||||
if (!request_.requested_video_device_id.empty()) {
|
||||
const content::MediaStreamDevice* video_device =
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetRequestedVideoDevice(request_.requested_video_device_id);
|
||||
if (video_device) {
|
||||
devices.push_back(*video_device);
|
||||
needs_video_device = false;
|
||||
}
|
||||
}
|
||||
|
||||
// If either or both audio and video devices were requested but not
|
||||
// specified by id, get the default devices.
|
||||
if (needs_audio_device || needs_video_device) {
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetDefaultDevices(needs_audio_device,
|
||||
needs_video_device,
|
||||
&devices);
|
||||
}
|
||||
break;
|
||||
} case content::MEDIA_DEVICE_ACCESS:
|
||||
// Get the default devices for the request.
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->
|
||||
GetDefaultDevices(microphone_requested_,
|
||||
webcam_requested_,
|
||||
&devices);
|
||||
break;
|
||||
case content::MEDIA_ENUMERATE_DEVICES:
|
||||
// Do nothing.
|
||||
NOTREACHED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Accept";
|
||||
callback_.Run(devices, scoped_ptr<content::MediaStreamUI>());
|
||||
content::MediaResponseCallback cb = callback_;
|
||||
callback_.Reset();
|
||||
cb.Run(devices, scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny() {
|
||||
callback_.Run(content::MediaStreamDevices(),
|
||||
scoped_ptr<content::MediaStreamUI>());
|
||||
content::MediaResponseCallback cb = callback_;
|
||||
callback_.Reset();
|
||||
cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||
#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -16,18 +18,12 @@ class MediaStreamDevicesController {
|
|||
|
||||
virtual ~MediaStreamDevicesController();
|
||||
|
||||
// Public method to be called before creating the MediaStreamInfoBarDelegate.
|
||||
// This function will check the content settings exceptions and take the
|
||||
// corresponding action on exception which matches the request.
|
||||
bool TakeAction();
|
||||
|
||||
// Public methods to be called by MediaStreamInfoBarDelegate;
|
||||
bool has_audio() const { return microphone_requested_; }
|
||||
bool has_video() const { return webcam_requested_; }
|
||||
private:
|
||||
void Accept();
|
||||
void Deny();
|
||||
|
||||
private:
|
||||
// The original request for access to devices.
|
||||
const content::MediaStreamRequest request_;
|
||||
|
||||
|
@ -41,6 +37,6 @@ class MediaStreamDevicesController {
|
|||
DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#import "browser/notification_presenter.h"
|
||||
|
||||
#import "base/memory/scoped_nsobject.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#import <map>
|
||||
|
||||
@class BRYUserNotificationCenterDelegate;
|
||||
|
@ -30,8 +30,8 @@ class NotificationPresenterMac : public NotificationPresenter {
|
|||
int notification_id) OVERRIDE;
|
||||
|
||||
private:
|
||||
std::map<std::string, scoped_nsobject<NSUserNotification>> notification_map_;
|
||||
scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
||||
std::map<std::string, base::scoped_nsobject<NSUserNotification>> notification_map_;
|
||||
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#import "browser/notification_presenter_mac.h"
|
||||
|
||||
#import "base/stringprintf.h"
|
||||
#import "base/strings/stringprintf.h"
|
||||
#import "base/strings/sys_string_conversions.h"
|
||||
#import "content/public/browser/render_view_host.h"
|
||||
#import "content/public/common/show_desktop_notification_params.h"
|
||||
|
@ -56,7 +56,7 @@ struct NotificationID {
|
|||
int notification_id;
|
||||
};
|
||||
|
||||
scoped_nsobject<NSUserNotification> CreateUserNotification(
|
||||
base::scoped_nsobject<NSUserNotification> CreateUserNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
int render_process_id,
|
||||
int render_view_id) {
|
||||
|
@ -65,7 +65,7 @@ scoped_nsobject<NSUserNotification> CreateUserNotification(
|
|||
notification.informativeText = base::SysUTF16ToNSString(params.body);
|
||||
notification.userInfo = NotificationID(render_process_id, render_view_id, params.notification_id).GetUserInfo();
|
||||
|
||||
return scoped_nsobject<NSUserNotification>(notification);
|
||||
return base::scoped_nsobject<NSUserNotification>(notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "browser/url_request_context_getter.h"
|
||||
|
||||
#include "network_delegate.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/cookie_store_factory.h"
|
||||
|
@ -87,7 +87,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
|||
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
|
||||
storage_->set_http_auth_handler_factory(
|
||||
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
|
||||
storage_->set_http_server_properties(new net::HttpServerPropertiesImpl);
|
||||
scoped_ptr<net::HttpServerProperties> server_properties(new net::HttpServerPropertiesImpl);
|
||||
storage_->set_http_server_properties(server_properties.Pass());
|
||||
|
||||
base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
|
||||
net::HttpCache::DefaultBackend* main_backend =
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "common/application_info.h"
|
||||
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "webkit/common/user_agent/user_agent_util.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a56056d8f6af9d66ffdd998d136323ef659c10c6
|
||||
Subproject commit bfb2d7bd95b41f328989622f7ac416c9544a9478
|
Loading…
Reference in a new issue