Index: chrome/browser/media/media_capture_devices_dispatcher.cc |
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc |
index 136139a4d68ce254809c377c010face81becb097..7806eb9dca389d192e605dc715124fdb3cde9122 100644 |
--- a/chrome/browser/media/media_capture_devices_dispatcher.cc |
+++ b/chrome/browser/media/media_capture_devices_dispatcher.cc |
@@ -36,6 +36,7 @@ |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/render_frame_host.h" |
+#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/media_stream_request.h" |
#include "extensions/common/constants.h" |
@@ -394,11 +395,24 @@ void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( |
// The extension name that the stream is registered with. |
std::string original_extension_name; |
// Resolve DesktopMediaID for the specified device id. |
- content::DesktopMediaID media_id = |
- GetDesktopStreamsRegistry()->RequestMediaForStreamId( |
- request.requested_video_device_id, request.render_process_id, |
- request.render_view_id, request.security_origin, |
- &original_extension_name); |
+ content::DesktopMediaID media_id; |
+ // TODO(miu): Replace "main RenderFrame" IDs with the request's actual |
+ // RenderFrame IDs once the desktop capture extension API implementation is |
+ // fixed. http://crbug.com/304341 |
+ content::WebContents* const web_contents_for_stream = |
+ content::WebContents::FromRenderFrameHost( |
+ content::RenderFrameHost::FromID(request.render_process_id, |
+ request.render_frame_id)); |
+ content::RenderFrameHost* const main_frame = web_contents_for_stream ? |
+ web_contents_for_stream->GetMainFrame() : NULL; |
+ if (main_frame) { |
+ media_id = GetDesktopStreamsRegistry()->RequestMediaForStreamId( |
+ request.requested_video_device_id, |
+ main_frame->GetProcess()->GetID(), |
+ main_frame->GetRoutingID(), |
+ request.security_origin, |
+ &original_extension_name); |
+ } |
// Received invalid device id. |
if (media_id.type == content::DesktopMediaID::TYPE_NONE) { |
@@ -545,9 +559,8 @@ void MediaCaptureDevicesDispatcher::ProcessTabCaptureAccessRequest( |
callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); |
return; |
} |
- bool tab_capture_allowed = |
- tab_capture_registry->VerifyRequest(request.render_process_id, |
- request.render_view_id); |
+ const bool tab_capture_allowed = tab_capture_registry->VerifyRequest( |
+ request.render_process_id, request.render_frame_id, extension->id()); |
if (request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE && |
tab_capture_allowed && |
@@ -576,7 +589,7 @@ void MediaCaptureDevicesDispatcher::ProcessTabCaptureAccessRequest( |
ui.Pass()); |
#else // defined(ENABLE_EXTENSIONS) |
callback.Run(devices, content::MEDIA_DEVICE_TAB_CAPTURE_FAILURE, ui.Pass()); |
-#endif // !defined(OS_ANDROID) |
+#endif // defined(ENABLE_EXTENSIONS) |
} |
void MediaCaptureDevicesDispatcher:: |
@@ -804,18 +817,18 @@ void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() { |
void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( |
int render_process_id, |
- int render_view_id, |
+ int render_frame_id, |
int page_request_id, |
const GURL& security_origin, |
- const content::MediaStreamDevice& device, |
+ content::MediaStreamType stream_type, |
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, |
- page_request_id, security_origin, device, state)); |
+ base::Unretained(this), render_process_id, render_frame_id, |
+ page_request_id, security_origin, stream_type, state)); |
} |
void MediaCaptureDevicesDispatcher::OnAudioStreamPlaying( |
@@ -877,17 +890,17 @@ void MediaCaptureDevicesDispatcher::NotifyVideoDevicesChangedOnUIThread() { |
void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( |
int render_process_id, |
- int render_view_id, |
+ int render_frame_id, |
int page_request_id, |
const GURL& security_origin, |
- const content::MediaStreamDevice& device, |
+ content::MediaStreamType stream_type, |
content::MediaRequestState state) { |
// Track desktop capture sessions. Tracking is necessary to avoid unbalanced |
// session counts since not all requests will reach MEDIA_REQUEST_STATE_DONE, |
// but they will all reach MEDIA_REQUEST_STATE_CLOSING. |
- if (device.type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) { |
+ if (stream_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) { |
if (state == content::MEDIA_REQUEST_STATE_DONE) { |
- DesktopCaptureSession session = { render_process_id, render_view_id, |
+ DesktopCaptureSession session = { render_process_id, render_frame_id, |
page_request_id }; |
desktop_capture_sessions_.push_back(session); |
} else if (state == content::MEDIA_REQUEST_STATE_CLOSING) { |
@@ -896,7 +909,7 @@ void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( |
it != desktop_capture_sessions_.end(); |
++it) { |
if (it->render_process_id == render_process_id && |
- it->render_view_id == render_view_id && |
+ it->render_frame_id == render_frame_id && |
it->page_request_id == page_request_id) { |
desktop_capture_sessions_.erase(it); |
break; |
@@ -914,7 +927,7 @@ void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( |
for (RequestsQueue::iterator it = queue.begin(); |
it != queue.end(); ++it) { |
if (it->request.render_process_id == render_process_id && |
- it->request.render_view_id == render_view_id && |
+ it->request.render_frame_id == render_frame_id && |
it->request.page_request_id == page_request_id) { |
queue.erase(it); |
found = true; |
@@ -927,7 +940,7 @@ void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( |
} |
#if defined(OS_CHROMEOS) |
- if (IsOriginForCasting(security_origin) && IsVideoMediaType(device.type)) { |
+ if (IsOriginForCasting(security_origin) && IsVideoMediaType(stream_type)) { |
// Notify ash that casting state has changed. |
if (state == content::MEDIA_REQUEST_STATE_DONE) { |
ash::Shell::GetInstance()->OnCastingSessionStartedOrStopped(true); |
@@ -939,8 +952,8 @@ void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( |
FOR_EACH_OBSERVER(Observer, observers_, |
OnRequestUpdate(render_process_id, |
- render_view_id, |
- device, |
+ render_frame_id, |
+ stream_type, |
state)); |
} |