summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 22:50:52 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 22:50:52 +0000
commitae6ef14fe8d5c5df694efc7e09bcf86e4747d7ad (patch)
tree86009a4aaab8a5df46c8e7652cf23fe9fdf16de2
parentea5ef4c89bd17065f32e1f294d8b922a0735fd25 (diff)
downloadchromium_src-ae6ef14fe8d5c5df694efc7e09bcf86e4747d7ad.zip
chromium_src-ae6ef14fe8d5c5df694efc7e09bcf86e4747d7ad.tar.gz
chromium_src-ae6ef14fe8d5c5df694efc7e09bcf86e4747d7ad.tar.bz2
Make the infobar popup when Pepper Flash requests the camera/microphone
This makes opening the microphone/camera devices for pepper pop the same infobar as WebRTC with an allow/deny button. BUG=249335 TBR=tsepez@chromium.org, xians@chromium.org, yzshen@chromium.org Review URL: https://codereview.chromium.org/16920003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206188 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/media/media_stream_devices_controller.cc19
-rw-r--r--chrome/browser/policy/policy_browsertest.cc14
-rw-r--r--content/renderer/pepper/pepper_audio_input_host.cc11
-rw-r--r--content/renderer/pepper/pepper_platform_audio_input_impl.cc8
-rw-r--r--content/renderer/pepper/pepper_platform_audio_input_impl.h4
-rw-r--r--content/renderer/pepper/pepper_platform_video_capture_impl.cc23
-rw-r--r--content/renderer/pepper/pepper_platform_video_capture_impl.h3
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.cc10
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.h3
-rw-r--r--content/renderer/pepper/pepper_video_capture_host.cc19
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc2
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h2
13 files changed, 77 insertions, 43 deletions
diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc
index 4f4545f..535135d 100644
--- a/chrome/browser/media/media_stream_devices_controller.cc
+++ b/chrome/browser/media/media_stream_devices_controller.cc
@@ -61,10 +61,14 @@ MediaStreamDevicesController::MediaStreamDevicesController(
: web_contents_(web_contents),
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) {
profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext());
content_settings_ = TabSpecificContentSettings::FromWebContents(web_contents);
@@ -107,13 +111,6 @@ void MediaStreamDevicesController::RegisterUserPrefs(
bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() {
- // If this is a no UI check for policies only go straight to accept - policy
- // check will be done automatically on the way.
- if (request_.request_type == content::MEDIA_OPEN_DEVICE) {
- Accept(false);
- return true;
- }
-
// Tab capture is allowed for extensions only and infobar is not shown for
// extensions.
if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE ||
@@ -178,8 +175,8 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
// first available of the given type.
MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request_.requested_device_id,
- microphone_requested_,
- webcam_requested_,
+ request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE,
+ request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE,
&devices);
break;
case content::MEDIA_DEVICE_ACCESS:
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 2ea0c62..2c59387 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -2281,26 +2281,32 @@ class MediaStreamDevicesControllerBrowserTest
void FinishAudioTest() {
content::MediaStreamRequest request(0, 0, request_url_.GetOrigin(),
- content::MEDIA_OPEN_DEVICE, "fake_dev",
+ content::MEDIA_DEVICE_ACCESS,
+ "fake_dev",
content::MEDIA_DEVICE_AUDIO_CAPTURE,
content::MEDIA_NO_SERVICE);
+ // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
+ // and microphone permissions at the same time.
MediaStreamDevicesController controller(
browser()->tab_strip_model()->GetActiveWebContents(), request,
base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept, this));
- controller.DismissInfoBarAndTakeActionOnSettings();
+ controller.Accept(false);
base::MessageLoop::current()->QuitWhenIdle();
}
void FinishVideoTest() {
+ // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
+ // and microphone permissions at the same time.
content::MediaStreamRequest request(0, 0, request_url_.GetOrigin(),
- content::MEDIA_OPEN_DEVICE, "fake_dev",
+ content::MEDIA_DEVICE_ACCESS,
+ "fake_dev",
content::MEDIA_NO_SERVICE,
content::MEDIA_DEVICE_VIDEO_CAPTURE);
MediaStreamDevicesController controller(
browser()->tab_strip_model()->GetActiveWebContents(), request,
base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept, this));
- controller.DismissInfoBarAndTakeActionOnSettings();
+ controller.Accept(false);
base::MessageLoop::current()->QuitWhenIdle();
}
diff --git a/content/renderer/pepper/pepper_audio_input_host.cc b/content/renderer/pepper/pepper_audio_input_host.cc
index 7d494b1..63aef62 100644
--- a/content/renderer/pepper/pepper_audio_input_host.cc
+++ b/content/renderer/pepper/pepper_audio_input_host.cc
@@ -14,6 +14,9 @@
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_structs.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace content {
@@ -102,10 +105,16 @@ int32_t PepperAudioInputHost::OnOpen(
if (!plugin_delegate)
return PP_ERROR_FAILED;
+ webkit::ppapi::PluginInstance* instance =
+ renderer_ppapi_host_->GetPluginInstance(pp_instance());
+ if (!instance)
+ return PP_ERROR_FAILED;
+
// When it is done, we'll get called back on StreamCreated() or
// StreamCreationFailed().
audio_input_ = plugin_delegate->CreateAudioInput(
- device_id, sample_rate, sample_frame_count, this);
+ device_id, instance->container()->element().document().url(),
+ sample_rate, sample_frame_count, this);
if (audio_input_) {
open_context_.reset(new ppapi::host::ReplyMessageContext(
context->MakeReplyMessageContext()));
diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.cc b/content/renderer/pepper/pepper_platform_audio_input_impl.cc
index 3d95888..6c0daf9 100644
--- a/content/renderer/pepper/pepper_platform_audio_input_impl.cc
+++ b/content/renderer/pepper/pepper_platform_audio_input_impl.cc
@@ -12,6 +12,7 @@
#include "content/renderer/media/audio_input_message_filter.h"
#include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
#include "content/renderer/render_thread_impl.h"
+#include "googleurl/src/gurl.h"
#include "media/audio/audio_manager_base.h"
namespace content {
@@ -20,13 +21,14 @@ namespace content {
PepperPlatformAudioInputImpl* PepperPlatformAudioInputImpl::Create(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
int sample_rate,
int frames_per_buffer,
webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
scoped_refptr<PepperPlatformAudioInputImpl> audio_input(
new PepperPlatformAudioInputImpl());
- if (audio_input->Initialize(plugin_delegate, device_id, sample_rate,
- frames_per_buffer, client)) {
+ if (audio_input->Initialize(plugin_delegate, device_id, document_url,
+ sample_rate, frames_per_buffer, client)) {
// Balanced by Release invoked in
// PepperPlatformAudioInputImpl::ShutDownOnIOThread().
audio_input->AddRef();
@@ -132,6 +134,7 @@ PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl()
bool PepperPlatformAudioInputImpl::Initialize(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
int sample_rate,
int frames_per_buffer,
webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
@@ -155,6 +158,7 @@ bool PepperPlatformAudioInputImpl::Initialize(
plugin_delegate_->OpenDevice(
PP_DEVICETYPE_DEV_AUDIOCAPTURE,
device_id.empty() ? media::AudioManagerBase::kDefaultDeviceId : device_id,
+ document_url,
base::Bind(&PepperPlatformAudioInputImpl::OnDeviceOpened, this));
return true;
diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.h b/content/renderer/pepper/pepper_platform_audio_input_impl.h
index 14ab0e8..4a32e6d 100644
--- a/content/renderer/pepper/pepper_platform_audio_input_impl.h
+++ b/content/renderer/pepper/pepper_platform_audio_input_impl.h
@@ -16,6 +16,8 @@
#include "media/audio/audio_parameters.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
+class GURL;
+
namespace media {
class AudioParameters;
}
@@ -42,6 +44,7 @@ class PepperPlatformAudioInputImpl
static PepperPlatformAudioInputImpl* Create(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
int sample_rate,
int frames_per_buffer,
webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client);
@@ -72,6 +75,7 @@ class PepperPlatformAudioInputImpl
bool Initialize(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
int sample_rate,
int frames_per_buffer,
webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client);
diff --git a/content/renderer/pepper/pepper_platform_video_capture_impl.cc b/content/renderer/pepper/pepper_platform_video_capture_impl.cc
index 598b567..95fc6d0 100644
--- a/content/renderer/pepper/pepper_platform_video_capture_impl.cc
+++ b/content/renderer/pepper/pepper_platform_video_capture_impl.cc
@@ -10,6 +10,7 @@
#include "content/renderer/media/video_capture_impl_manager.h"
#include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
#include "content/renderer/render_thread_impl.h"
+#include "googleurl/src/gurl.h"
#include "media/video/capture/video_capture_proxy.h"
namespace content {
@@ -17,6 +18,7 @@ namespace content {
PepperPlatformVideoCaptureImpl::PepperPlatformVideoCaptureImpl(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler* handler)
: plugin_delegate_(plugin_delegate),
device_id_(device_id),
@@ -26,19 +28,14 @@ PepperPlatformVideoCaptureImpl::PepperPlatformVideoCaptureImpl(
handler_(handler),
video_capture_(NULL),
unbalanced_start_(false) {
- if (device_id.empty()) {
- // "1" is the session ID for the default device.
- session_id_ = 1;
- Initialize();
- } else {
- // We need to open the device and obtain the label and session ID before
- // initializing.
- if (plugin_delegate_.get()) {
- plugin_delegate_->OpenDevice(
- PP_DEVICETYPE_DEV_VIDEOCAPTURE,
- device_id,
- base::Bind(&PepperPlatformVideoCaptureImpl::OnDeviceOpened, this));
- }
+ // We need to open the device and obtain the label and session ID before
+ // initializing.
+ if (plugin_delegate_.get()) {
+ plugin_delegate_->OpenDevice(
+ PP_DEVICETYPE_DEV_VIDEOCAPTURE,
+ device_id,
+ document_url,
+ base::Bind(&PepperPlatformVideoCaptureImpl::OnDeviceOpened, this));
}
}
diff --git a/content/renderer/pepper/pepper_platform_video_capture_impl.h b/content/renderer/pepper/pepper_platform_video_capture_impl.h
index a198133..be20e1b 100644
--- a/content/renderer/pepper/pepper_platform_video_capture_impl.h
+++ b/content/renderer/pepper/pepper_platform_video_capture_impl.h
@@ -15,6 +15,8 @@
#include "media/video/capture/video_capture_types.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
+class GURL;
+
namespace media {
class VideoCaptureHandlerProxy;
}
@@ -30,6 +32,7 @@ class PepperPlatformVideoCaptureImpl
PepperPlatformVideoCaptureImpl(
const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
const std::string& device_id,
+ const GURL& document_url,
webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler* handler);
// webkit::ppapi::PluginDelegate::PlatformVideoCapture implementation.
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
index 92a7b2c..bcc408e 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
@@ -832,8 +832,10 @@ webkit::ppapi::PluginDelegate::PlatformContext3D*
webkit::ppapi::PluginDelegate::PlatformVideoCapture*
PepperPluginDelegateImpl::CreateVideoCapture(
const std::string& device_id,
+ const GURL& document_url,
PlatformVideoCaptureEventHandler* handler) {
- return new PepperPlatformVideoCaptureImpl(AsWeakPtr(), device_id, handler);
+ return new PepperPlatformVideoCaptureImpl(AsWeakPtr(), device_id,
+ document_url, handler);
}
webkit::ppapi::PluginDelegate::PlatformVideoDecoder*
@@ -878,11 +880,12 @@ PepperPluginDelegateImpl::CreateAudioOutput(
webkit::ppapi::PluginDelegate::PlatformAudioInput*
PepperPluginDelegateImpl::CreateAudioInput(
const std::string& device_id,
+ const GURL& document_url,
uint32_t sample_rate,
uint32_t sample_count,
webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
return PepperPlatformAudioInputImpl::Create(
- AsWeakPtr(), device_id, static_cast<int>(sample_rate),
+ AsWeakPtr(), device_id, document_url, static_cast<int>(sample_rate),
static_cast<int>(sample_count), client);
}
@@ -1606,6 +1609,7 @@ int PepperPluginDelegateImpl::GetRoutingID() const {
int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type,
const std::string& device_id,
+ const GURL& document_url,
const OpenDeviceCallback& callback) {
int request_id =
device_enumeration_event_handler_->RegisterOpenDeviceCallback(callback);
@@ -1616,7 +1620,7 @@ int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type,
device_enumeration_event_handler_.get()->AsWeakPtr(),
device_id,
PepperDeviceEnumerationEventHandler::FromPepperDeviceType(type),
- GURL());
+ document_url.GetOrigin());
#else
base::MessageLoop::current()->PostTask(
FROM_HERE,
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h
index 5e611b0..1c0089a 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h
@@ -101,6 +101,7 @@ class PepperPluginDelegateImpl
// CloseDevice() and GetSesssionID().
int OpenDevice(PP_DeviceType_Dev type,
const std::string& device_id,
+ const GURL& document_url,
const OpenDeviceCallback& callback);
void CloseDevice(const std::string& label);
// Gets audio/video session ID given a label.
@@ -182,6 +183,7 @@ class PepperPluginDelegateImpl
PlatformAudioOutputClient* client) OVERRIDE;
virtual PlatformAudioInput* CreateAudioInput(
const std::string& device_id,
+ const GURL& document_url,
uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioInputClient* client) OVERRIDE;
@@ -192,6 +194,7 @@ class PepperPluginDelegateImpl
virtual PlatformContext3D* CreateContext3D() OVERRIDE;
virtual PlatformVideoCapture* CreateVideoCapture(
const std::string& device_id,
+ const GURL& document_url,
PlatformVideoCaptureEventHandler* handler) OVERRIDE;
virtual PlatformVideoDecoder* CreateVideoDecoder(
media::VideoDecodeAccelerator::Client* client,
diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc
index e2951c1..0ab21b9 100644
--- a/content/renderer/pepper/pepper_video_capture_host.cc
+++ b/content/renderer/pepper/pepper_video_capture_host.cc
@@ -11,6 +11,9 @@
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_buffer_api.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -259,19 +262,17 @@ int32_t PepperVideoCaptureHost::OnOpen(
SetRequestedInfo(requested_info, buffer_count);
+ webkit::ppapi::PluginInstance* instance =
+ renderer_ppapi_host_->GetPluginInstance(pp_instance());
+ if (!instance)
+ return PP_ERROR_FAILED;
+
platform_video_capture_ =
- plugin_delegate->CreateVideoCapture(device_id, this);
+ plugin_delegate->CreateVideoCapture(device_id,
+ instance->container()->element().document().url(), this);
open_reply_context_ = context->MakeReplyMessageContext();
- // It is able to complete synchronously if the default device is used.
- bool sync_completion = device_id.empty();
- if (sync_completion) {
- // Send OpenACK directly, but still need to return PP_OK_COMPLETIONPENDING
- // to make PluginResource happy.
- OnInitialized(platform_video_capture_.get(), true);
- }
-
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 2fa4140..5f27a2e 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -99,6 +99,7 @@ MockPluginDelegate::CreateVideoDecoder(
MockPluginDelegate::PlatformVideoCapture*
MockPluginDelegate::CreateVideoCapture(
const std::string& device_id,
+ const GURL& document_url,
PlatformVideoCaptureEventHandler* handler){
return NULL;
}
@@ -120,6 +121,7 @@ MockPluginDelegate::PlatformAudioOutput* MockPluginDelegate::CreateAudioOutput(
MockPluginDelegate::PlatformAudioInput* MockPluginDelegate::CreateAudioInput(
const std::string& device_id,
+ const GURL& document_url,
uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioInputClient* client) {
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index 4fa945ff..c1d74f0 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -46,6 +46,7 @@ class MockPluginDelegate : public PluginDelegate {
int32 command_buffer_route_id);
virtual PlatformVideoCapture* CreateVideoCapture(
const std::string& device_id,
+ const GURL& document_url,
PlatformVideoCaptureEventHandler* handler);
virtual uint32_t GetAudioHardwareOutputSampleRate();
virtual uint32_t GetAudioHardwareOutputBufferSize();
@@ -55,6 +56,7 @@ class MockPluginDelegate : public PluginDelegate {
PlatformAudioOutputClient* client);
virtual PlatformAudioInput* CreateAudioInput(
const std::string& device_id,
+ const GURL& document_url,
uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioInputClient* client);
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 06962e0..acd7310 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -417,6 +417,7 @@ class PluginDelegate {
// object.
virtual PlatformVideoCapture* CreateVideoCapture(
const std::string& device_id,
+ const GURL& document_url,
PlatformVideoCaptureEventHandler* handler) = 0;
// The caller will own the pointer returned from this.
@@ -442,6 +443,7 @@ class PluginDelegate {
// to clean up the corresponding resources allocated during this call.
virtual PlatformAudioInput* CreateAudioInput(
const std::string& device_id,
+ const GURL& document_url,
uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioInputClient* client) = 0;