| 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/webrtc/media_capture_devices_dispatcher.h" | 5 #include "chrome/browser/media/webrtc/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 13 matching lines...) Expand all Loading... |
| 24 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
| 25 #include "components/prefs/scoped_user_pref_update.h" | 25 #include "components/prefs/scoped_user_pref_update.h" |
| 26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/media_capture_devices.h" | 27 #include "content/public/browser/media_capture_devices.h" |
| 28 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 29 #include "content/public/browser/render_frame_host.h" | 29 #include "content/public/browser/render_frame_host.h" |
| 30 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/common/media_stream_request.h" | 32 #include "content/public/common/media_stream_request.h" |
| 33 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
| 34 #include "extensions/features/features.h" |
| 34 #include "media/base/media_switches.h" | 35 #include "media/base/media_switches.h" |
| 35 | 36 |
| 36 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 37 #include "ash/shell.h" | 38 #include "ash/shell.h" |
| 38 #endif // defined(OS_CHROMEOS) | 39 #endif // defined(OS_CHROMEOS) |
| 39 | 40 |
| 40 #if defined(ENABLE_EXTENSIONS) | 41 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 41 #include "chrome/browser/media/extension_media_access_handler.h" | 42 #include "chrome/browser/media/extension_media_access_handler.h" |
| 42 #include "chrome/browser/media/webrtc/desktop_capture_access_handler.h" | 43 #include "chrome/browser/media/webrtc/desktop_capture_access_handler.h" |
| 43 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h" | 44 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h" |
| 44 #include "extensions/browser/extension_registry.h" | 45 #include "extensions/browser/extension_registry.h" |
| 45 #include "extensions/common/extension.h" | 46 #include "extensions/common/extension.h" |
| 46 #include "extensions/common/permissions/permissions_data.h" | 47 #include "extensions/common/permissions/permissions_data.h" |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 using content::BrowserThread; | 50 using content::BrowserThread; |
| 50 using content::MediaCaptureDevices; | 51 using content::MediaCaptureDevices; |
| 51 using content::MediaStreamDevices; | 52 using content::MediaStreamDevices; |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 // Finds a device in |devices| that has |device_id|, or NULL if not found. | 56 // Finds a device in |devices| that has |device_id|, or NULL if not found. |
| 56 const content::MediaStreamDevice* FindDeviceWithId( | 57 const content::MediaStreamDevice* FindDeviceWithId( |
| 57 const content::MediaStreamDevices& devices, | 58 const content::MediaStreamDevices& devices, |
| 58 const std::string& device_id) { | 59 const std::string& device_id) { |
| 59 content::MediaStreamDevices::const_iterator iter = devices.begin(); | 60 content::MediaStreamDevices::const_iterator iter = devices.begin(); |
| 60 for (; iter != devices.end(); ++iter) { | 61 for (; iter != devices.end(); ++iter) { |
| 61 if (iter->id == device_id) { | 62 if (iter->id == device_id) { |
| 62 return &(*iter); | 63 return &(*iter); |
| 63 } | 64 } |
| 64 } | 65 } |
| 65 return NULL; | 66 return NULL; |
| 66 } | 67 } |
| 67 | 68 |
| 68 #if defined(ENABLE_EXTENSIONS) | 69 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 69 inline CaptureAccessHandlerBase* ToCaptureAccessHandlerBase( | 70 inline CaptureAccessHandlerBase* ToCaptureAccessHandlerBase( |
| 70 MediaAccessHandler* handler) { | 71 MediaAccessHandler* handler) { |
| 71 return static_cast<CaptureAccessHandlerBase*>(handler); | 72 return static_cast<CaptureAccessHandlerBase*>(handler); |
| 72 } | 73 } |
| 73 #endif | 74 #endif |
| 74 } // namespace | 75 } // namespace |
| 75 | 76 |
| 76 MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { | 77 MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { |
| 77 return base::Singleton<MediaCaptureDevicesDispatcher>::get(); | 78 return base::Singleton<MediaCaptureDevicesDispatcher>::get(); |
| 78 } | 79 } |
| 79 | 80 |
| 80 MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() | 81 MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() |
| 81 : is_device_enumeration_disabled_(false), | 82 : is_device_enumeration_disabled_(false), |
| 82 media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) { | 83 media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) { |
| 83 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 84 | 85 |
| 85 #if defined(ENABLE_EXTENSIONS) | 86 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 86 media_access_handlers_.push_back(new ExtensionMediaAccessHandler()); | 87 media_access_handlers_.push_back(new ExtensionMediaAccessHandler()); |
| 87 media_access_handlers_.push_back(new DesktopCaptureAccessHandler()); | 88 media_access_handlers_.push_back(new DesktopCaptureAccessHandler()); |
| 88 media_access_handlers_.push_back(new TabCaptureAccessHandler()); | 89 media_access_handlers_.push_back(new TabCaptureAccessHandler()); |
| 89 #endif | 90 #endif |
| 90 media_access_handlers_.push_back(new PermissionBubbleMediaAccessHandler()); | 91 media_access_handlers_.push_back(new PermissionBubbleMediaAccessHandler()); |
| 91 } | 92 } |
| 92 | 93 |
| 93 MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} | 94 MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} |
| 94 | 95 |
| 95 void MediaCaptureDevicesDispatcher::RegisterProfilePrefs( | 96 void MediaCaptureDevicesDispatcher::RegisterProfilePrefs( |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 int render_frame_id) { | 370 int render_frame_id) { |
| 370 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 371 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 371 for (auto& observer : observers_) | 372 for (auto& observer : observers_) |
| 372 observer.OnCreatingAudioStream(render_process_id, render_frame_id); | 373 observer.OnCreatingAudioStream(render_process_id, render_frame_id); |
| 373 } | 374 } |
| 374 | 375 |
| 375 bool MediaCaptureDevicesDispatcher::IsInsecureCapturingInProgress( | 376 bool MediaCaptureDevicesDispatcher::IsInsecureCapturingInProgress( |
| 376 int render_process_id, | 377 int render_process_id, |
| 377 int render_frame_id) { | 378 int render_frame_id) { |
| 378 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 379 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 379 #if defined(ENABLE_EXTENSIONS) | 380 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 380 for (MediaAccessHandler* handler : media_access_handlers_) { | 381 for (MediaAccessHandler* handler : media_access_handlers_) { |
| 381 if (handler->SupportsStreamType(content::MEDIA_DESKTOP_VIDEO_CAPTURE, | 382 if (handler->SupportsStreamType(content::MEDIA_DESKTOP_VIDEO_CAPTURE, |
| 382 nullptr) || | 383 nullptr) || |
| 383 handler->SupportsStreamType(content::MEDIA_TAB_VIDEO_CAPTURE, | 384 handler->SupportsStreamType(content::MEDIA_TAB_VIDEO_CAPTURE, |
| 384 nullptr)) { | 385 nullptr)) { |
| 385 if (ToCaptureAccessHandlerBase(handler)->IsInsecureCapturingInProgress( | 386 if (ToCaptureAccessHandlerBase(handler)->IsInsecureCapturingInProgress( |
| 386 render_process_id, render_frame_id)) | 387 render_process_id, render_frame_id)) |
| 387 return true; | 388 return true; |
| 388 } | 389 } |
| 389 } | 390 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 int render_process_id, | 424 int render_process_id, |
| 424 int render_frame_id, | 425 int render_frame_id, |
| 425 int page_request_id, | 426 int page_request_id, |
| 426 content::MediaStreamType stream_type, | 427 content::MediaStreamType stream_type, |
| 427 bool is_secure) { | 428 bool is_secure) { |
| 428 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 429 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 429 if (stream_type != content::MEDIA_TAB_VIDEO_CAPTURE && | 430 if (stream_type != content::MEDIA_TAB_VIDEO_CAPTURE && |
| 430 stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) | 431 stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) |
| 431 return; | 432 return; |
| 432 | 433 |
| 433 #if defined(ENABLE_EXTENSIONS) | 434 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 434 for (MediaAccessHandler* handler : media_access_handlers_) { | 435 for (MediaAccessHandler* handler : media_access_handlers_) { |
| 435 if (handler->SupportsStreamType(stream_type, nullptr)) { | 436 if (handler->SupportsStreamType(stream_type, nullptr)) { |
| 436 ToCaptureAccessHandlerBase(handler)->UpdateCapturingLinkSecured( | 437 ToCaptureAccessHandlerBase(handler)->UpdateCapturingLinkSecured( |
| 437 render_process_id, render_frame_id, page_request_id, is_secure); | 438 render_process_id, render_frame_id, page_request_id, is_secure); |
| 438 break; | 439 break; |
| 439 } | 440 } |
| 440 } | 441 } |
| 441 #endif | 442 #endif |
| 442 } | 443 } |
| OLD | NEW |