Index: content/browser/renderer_host/media/media_stream_manager.cc |
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc |
index 864e999d0b32e429081450bfa194e1ad953f465b..bb2862a4a2d7d96bf2a2d3862ccca3ddd4540c00 100644 |
--- a/content/browser/renderer_host/media/media_stream_manager.cc |
+++ b/content/browser/renderer_host/media/media_stream_manager.cc |
@@ -248,11 +248,18 @@ std::string MediaStreamManager::GenerateStreamForDevice( |
const GURL& security_origin) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ int target_render_process_id = -1; |
+ int target_render_view_id = -1; |
+ // We will post the request to the target render view, not the source (i.e. |
+ // source is an extension, and target is the tab we want to capture). |
+ bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget( |
no longer working on chromium
2012/12/07 15:56:39
How about doing an early return with a std::string
justinlin
2012/12/07 15:59:53
I considered that, but is that safe to do? If we d
no longer working on chromium
2012/12/07 16:06:07
It sounds wrong since the requests can fail on cre
justinlin
2012/12/07 17:06:39
OK, changed it to match the CL you just sent. This
|
+ device_id, &target_render_process_id, &target_render_view_id); |
+ |
// Create a new request based on options. |
DeviceRequest* request = new DeviceRequest(requester, options, |
DeviceRequest::GENERATE_STREAM, |
- render_process_id, |
- render_view_id, |
+ target_render_process_id, |
+ target_render_view_id, |
security_origin); |
const std::string& label = AddRequest(request); |
request->requested_device_id = device_id; |
@@ -260,7 +267,8 @@ std::string MediaStreamManager::GenerateStreamForDevice( |
// Get user confirmation to use the capture device. |
PostRequestToUI(label); |
- if (!security_origin.SchemeIs(kExtensionScheme) || |
+ if (!has_valid_device_id || |
+ !security_origin.SchemeIs(kExtensionScheme) || |
(options.audio_type != MEDIA_TAB_AUDIO_CAPTURE && |
options.audio_type != MEDIA_NO_SERVICE) || |
(options.video_type != MEDIA_TAB_VIDEO_CAPTURE && |
@@ -859,6 +867,12 @@ void MediaStreamManager::DevicesAccepted(const std::string& label, |
device_it != devices.end(); ++device_it) { |
StreamDeviceInfo device_info = *device_it; // Make a copy. |
+ // TODO(justinlin): Nicer way to do this? |
+ // Re-append the device_id since we lost it when posting request to UI. |
+ if (device_info.stream_type == content::MEDIA_TAB_VIDEO_CAPTURE || |
+ device_info.stream_type == content::MEDIA_TAB_AUDIO_CAPTURE) |
+ device_info.device_id = request->requested_device_id; |
+ |
// Set in_use to false to be able to track if this device has been |
// opened. in_use might be true if the device type can be used in more |
// than one session. |
@@ -937,22 +951,8 @@ void MediaStreamManager::NotifyDevicesOpened(const DeviceRequest& request) { |
if (opened_devices.empty()) |
return; |
- int target_render_process_id = request.render_process_id; |
- int target_render_view_id = request.render_view_id; |
- |
- // For tab capture requests, we should notify the UI to update the renderer |
- // that is the target of the capture instead of the requester. |
- if (request.options.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || |
- request.options.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { |
- if (!WebContentsCaptureUtil::ExtractTabCaptureTarget( |
- request.requested_device_id, |
- &target_render_process_id, |
- &target_render_view_id)) |
- return; |
- } |
- |
- NotifyUIDevicesOpened(target_render_process_id, |
- target_render_view_id, |
+ NotifyUIDevicesOpened(request.render_process_id, |
+ request.render_view_id, |
opened_devices); |
} |
@@ -963,22 +963,8 @@ void MediaStreamManager::NotifyDevicesClosed(const DeviceRequest& request) { |
if (closed_devices.empty()) |
return; |
- int target_render_process_id = request.render_process_id; |
- int target_render_view_id = request.render_view_id; |
- |
- // For tab capture requests, we should notify the UI to update the renderer |
- // that is the target of the capture instead of the requester. |
- if (request.options.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || |
- request.options.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { |
- if (!WebContentsCaptureUtil::ExtractTabCaptureTarget( |
- request.requested_device_id, |
- &target_render_process_id, |
- &target_render_view_id)) |
- return; |
- } |
- |
- NotifyUIDevicesClosed(target_render_process_id, |
- target_render_view_id, |
+ NotifyUIDevicesClosed(request.render_process_id, |
+ request.render_view_id, |
closed_devices); |
} |