OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 | 1465 |
1466 if (request->security_origin.is_valid()) { | 1466 if (request->security_origin.is_valid()) { |
1467 for (StreamDeviceInfoArray::iterator it = request->devices.begin(); | 1467 for (StreamDeviceInfoArray::iterator it = request->devices.begin(); |
1468 it != request->devices.end(); ++it) { | 1468 it != request->devices.end(); ++it) { |
1469 TranslateDeviceIdToSourceId(request, &it->device); | 1469 TranslateDeviceIdToSourceId(request, &it->device); |
1470 } | 1470 } |
1471 } else { | 1471 } else { |
1472 request->devices.clear(); | 1472 request->devices.clear(); |
1473 } | 1473 } |
1474 | 1474 |
| 1475 if (use_fake_ui_) { |
| 1476 if (!fake_ui_) |
| 1477 fake_ui_.reset(new FakeMediaStreamUIProxy()); |
| 1478 request->ui_proxy = fake_ui_.Pass(); |
| 1479 } else { |
| 1480 request->ui_proxy = MediaStreamUIProxy::Create(); |
| 1481 } |
| 1482 |
1475 // Output label permissions are based on input permission. | 1483 // Output label permissions are based on input permission. |
1476 MediaStreamType type = | 1484 MediaStreamType type = |
1477 request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE || | 1485 request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE || |
1478 request->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT | 1486 request->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT |
1479 ? MEDIA_DEVICE_AUDIO_CAPTURE | 1487 ? MEDIA_DEVICE_AUDIO_CAPTURE |
1480 : MEDIA_DEVICE_VIDEO_CAPTURE; | 1488 : MEDIA_DEVICE_VIDEO_CAPTURE; |
1481 | 1489 |
1482 BrowserThread::PostTaskAndReplyWithResult( | 1490 request->ui_proxy->CheckAccess( |
1483 BrowserThread::UI, | 1491 request->security_origin, |
1484 FROM_HERE, | 1492 type, |
1485 base::Bind(&MediaStreamManager::CheckMediaAccessPermissionOnUIThread, | 1493 request->requesting_process_id, |
1486 base::Unretained(this), | 1494 request->requesting_frame_id, |
1487 request->requesting_process_id, | |
1488 request->security_origin, | |
1489 type), | |
1490 base::Bind(&MediaStreamManager::HandleCheckMediaAccessResponse, | 1495 base::Bind(&MediaStreamManager::HandleCheckMediaAccessResponse, |
1491 base::Unretained(this), | 1496 base::Unretained(this), |
1492 label)); | 1497 label)); |
1493 } | 1498 } |
1494 | 1499 |
1495 bool MediaStreamManager::CheckMediaAccessPermissionOnUIThread( | |
1496 int render_process_id, | |
1497 const GURL& security_origin, | |
1498 MediaStreamType type) { | |
1499 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
1500 | |
1501 RenderProcessHost* host = | |
1502 RenderProcessHost::FromID(render_process_id); | |
1503 if (!host) { | |
1504 // This can happen if the renderer goes away during the lifetime of a | |
1505 // request. | |
1506 return false; | |
1507 } | |
1508 content::BrowserContext* context = host->GetBrowserContext(); | |
1509 DCHECK(context); | |
1510 return GetContentClient()->browser()->CheckMediaAccessPermission( | |
1511 context, | |
1512 security_origin, | |
1513 type); | |
1514 } | |
1515 | |
1516 void MediaStreamManager::HandleCheckMediaAccessResponse( | 1500 void MediaStreamManager::HandleCheckMediaAccessResponse( |
1517 const std::string& label, | 1501 const std::string& label, |
1518 bool have_access) { | 1502 bool have_access) { |
1519 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1503 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1520 | 1504 |
1521 DeviceRequest* request = FindRequest(label); | 1505 DeviceRequest* request = FindRequest(label); |
1522 if (!request) { | 1506 if (!request) { |
1523 // This can happen if the request was cancelled. | 1507 // This can happen if the request was cancelled. |
1524 DVLOG(1) << "The request with label " << label << " does not exist."; | 1508 DVLOG(1) << "The request with label " << label << " does not exist."; |
1525 return; | 1509 return; |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 2071 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
2088 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, | 2072 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, |
2089 window_id); | 2073 window_id); |
2090 break; | 2074 break; |
2091 } | 2075 } |
2092 } | 2076 } |
2093 } | 2077 } |
2094 } | 2078 } |
2095 | 2079 |
2096 } // namespace content | 2080 } // namespace content |
OLD | NEW |