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 "chrome/browser/media/media_capture_devices_dispatcher.h" | 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 content::MediaStreamDevices::const_iterator iter = devices.begin(); | 59 content::MediaStreamDevices::const_iterator iter = devices.begin(); |
60 for (; iter != devices.end(); ++iter) { | 60 for (; iter != devices.end(); ++iter) { |
61 if (iter->id == device_id) { | 61 if (iter->id == device_id) { |
62 return &(*iter); | 62 return &(*iter); |
63 } | 63 } |
64 } | 64 } |
65 return NULL; | 65 return NULL; |
66 } | 66 } |
67 | 67 |
68 #if defined(ENABLE_EXTENSIONS) | 68 #if defined(ENABLE_EXTENSIONS) |
69 inline DesktopCaptureAccessHandler* ToDesktopCaptureAccessHandler( | 69 inline DesktopCaptureAccessHandler* ToDesktopCaptureAccessHandler( |
miu
2016/04/26 01:25:13
I think you can delete this function now.
xjz
2016/04/29 00:11:42
This is used by |IsDesktopCaptureInProgress()| for
miu
2016/05/02 21:02:45
Yes, but can IsDesktopCaptureInProgress() just cal
xjz
2016/05/04 18:23:48
Done. Actually now changed the OutputProtectionDel
| |
70 MediaAccessHandler* handler) { | 70 MediaAccessHandler* handler) { |
71 return static_cast<DesktopCaptureAccessHandler*>(handler); | 71 return static_cast<DesktopCaptureAccessHandler*>(handler); |
72 } | 72 } |
73 | |
74 inline CaptureAccessHandlerBase* ToCaptureAccessHandlerBase( | |
75 MediaAccessHandler* handler) { | |
76 return static_cast<CaptureAccessHandlerBase*>(handler); | |
77 } | |
73 #endif | 78 #endif |
74 } // namespace | 79 } // namespace |
75 | 80 |
76 MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { | 81 MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { |
77 return base::Singleton<MediaCaptureDevicesDispatcher>::get(); | 82 return base::Singleton<MediaCaptureDevicesDispatcher>::get(); |
78 } | 83 } |
79 | 84 |
80 MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() | 85 MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() |
81 : is_device_enumeration_disabled_(false), | 86 : is_device_enumeration_disabled_(false), |
82 media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) { | 87 media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) { |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 for (MediaAccessHandler* handler : media_access_handlers_) { | 384 for (MediaAccessHandler* handler : media_access_handlers_) { |
380 if (handler->SupportsStreamType(content::MEDIA_DESKTOP_VIDEO_CAPTURE, | 385 if (handler->SupportsStreamType(content::MEDIA_DESKTOP_VIDEO_CAPTURE, |
381 NULL)) { | 386 NULL)) { |
382 return ToDesktopCaptureAccessHandler(handler)->IsCaptureInProgress(); | 387 return ToDesktopCaptureAccessHandler(handler)->IsCaptureInProgress(); |
383 } | 388 } |
384 } | 389 } |
385 #endif | 390 #endif |
386 return false; | 391 return false; |
387 } | 392 } |
388 | 393 |
394 bool MediaCaptureDevicesDispatcher::IsInsecureCapturingInProgress( | |
395 int render_process_id, | |
396 int render_frame_id) { | |
397 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
398 #if defined(ENABLE_EXTENSIONS) | |
399 for (MediaAccessHandler* handler : media_access_handlers_) { | |
400 if (handler->SupportsStreamType(content::MEDIA_DESKTOP_VIDEO_CAPTURE, | |
401 nullptr) || | |
402 handler->SupportsStreamType(content::MEDIA_TAB_VIDEO_CAPTURE, | |
403 nullptr)) { | |
404 if (ToCaptureAccessHandlerBase(handler)->IsInsecureCapturingInProgress( | |
405 render_process_id, render_frame_id)) | |
406 return true; | |
407 } | |
408 } | |
409 #endif | |
410 return false; | |
411 } | |
412 | |
389 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 413 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
390 const MediaStreamDevices& devices) { | 414 const MediaStreamDevices& devices) { |
391 test_audio_devices_ = devices; | 415 test_audio_devices_ = devices; |
392 } | 416 } |
393 | 417 |
394 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 418 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
395 const MediaStreamDevices& devices) { | 419 const MediaStreamDevices& devices) { |
396 test_video_devices_ = devices; | 420 test_video_devices_ = devices; |
397 } | 421 } |
422 | |
423 void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured( | |
424 int render_process_id, | |
425 int render_frame_id, | |
426 int page_request_id, | |
427 content::MediaStreamType stream_type, | |
428 bool is_secure) { | |
429 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
430 if (stream_type != content::MEDIA_TAB_VIDEO_CAPTURE && | |
431 stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) | |
432 return; | |
433 | |
434 BrowserThread::PostTask( | |
435 BrowserThread::UI, FROM_HERE, | |
436 base::Bind(&MediaCaptureDevicesDispatcher::UpdateCapturingLinkSecured, | |
437 base::Unretained(this), render_process_id, render_frame_id, | |
438 page_request_id, stream_type, is_secure)); | |
439 } | |
440 | |
441 void MediaCaptureDevicesDispatcher::UpdateCapturingLinkSecured( | |
442 int render_process_id, | |
443 int render_frame_id, | |
444 int page_request_id, | |
445 content::MediaStreamType stream_type, | |
446 bool is_secure) { | |
447 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
448 if (stream_type != content::MEDIA_TAB_VIDEO_CAPTURE && | |
449 stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) | |
450 return; | |
451 | |
452 #if defined(ENABLE_EXTENSIONS) | |
453 for (MediaAccessHandler* handler : media_access_handlers_) { | |
454 if (handler->SupportsStreamType(stream_type, nullptr)) { | |
455 ToCaptureAccessHandlerBase(handler)->UpdateCapturingLinkSecured( | |
456 render_process_id, render_frame_id, page_request_id, is_secure); | |
457 break; | |
458 } | |
459 } | |
460 #endif | |
461 } | |
OLD | NEW |