| 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // UI thread. Otherwise, it will not receive | 255 // UI thread. Otherwise, it will not receive |
| 256 // content::NOTIFICATION_WEB_CONTENTS_DESTROYED, and that will result in | 256 // content::NOTIFICATION_WEB_CONTENTS_DESTROYED, and that will result in |
| 257 // possible use after free. | 257 // possible use after free. |
| 258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 259 notifications_registrar_.Add( | 259 notifications_registrar_.Add( |
| 260 this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 260 this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 261 content::NotificationService::AllSources()); | 261 content::NotificationService::AllSources()); |
| 262 | 262 |
| 263 #if defined(OS_MACOSX) | 263 #if defined(OS_MACOSX) |
| 264 // AVFoundation is used for video/audio device monitoring and video capture. | 264 // AVFoundation is used for video/audio device monitoring and video capture. |
| 265 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceQTKit)) { | 265 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 266 CommandLine::ForCurrentProcess()->AppendSwitch( | 266 switches::kForceQTKit)) { |
| 267 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 267 switches::kEnableAVFoundation); | 268 switches::kEnableAVFoundation); |
| 268 } | 269 } |
| 269 #endif | 270 #endif |
| 270 } | 271 } |
| 271 | 272 |
| 272 MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} | 273 MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} |
| 273 | 274 |
| 274 void MediaCaptureDevicesDispatcher::RegisterProfilePrefs( | 275 void MediaCaptureDevicesDispatcher::RegisterProfilePrefs( |
| 275 user_prefs::PrefRegistrySyncable* registry) { | 276 user_prefs::PrefRegistrySyncable* registry) { |
| 276 registry->RegisterStringPref( | 277 registry->RegisterStringPref( |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 switches::kEnableUserMediaScreenCapturing); | 567 switches::kEnableUserMediaScreenCapturing); |
| 567 #if defined(ENABLE_EXTENSIONS) | 568 #if defined(ENABLE_EXTENSIONS) |
| 568 screen_capture_enabled |= | 569 screen_capture_enabled |= |
| 569 IsOriginForCasting(request.security_origin) || | 570 IsOriginForCasting(request.security_origin) || |
| 570 IsBuiltInExtension(request.security_origin); | 571 IsBuiltInExtension(request.security_origin); |
| 571 #endif | 572 #endif |
| 572 | 573 |
| 573 const bool origin_is_secure = | 574 const bool origin_is_secure = |
| 574 request.security_origin.SchemeIsSecure() || | 575 request.security_origin.SchemeIsSecure() || |
| 575 request.security_origin.SchemeIs(extensions::kExtensionScheme) || | 576 request.security_origin.SchemeIs(extensions::kExtensionScheme) || |
| 576 CommandLine::ForCurrentProcess()->HasSwitch( | 577 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 577 switches::kAllowHttpScreenCapture); | 578 switches::kAllowHttpScreenCapture); |
| 578 | 579 |
| 579 // If basic conditions (screen capturing is enabled and origin is secure) | 580 // If basic conditions (screen capturing is enabled and origin is secure) |
| 580 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set | 581 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set |
| 581 // it after checking permission. | 582 // it after checking permission. |
| 582 // TODO(grunell): It would be good to change this result for something else, | 583 // TODO(grunell): It would be good to change this result for something else, |
| 583 // probably a new one. | 584 // probably a new one. |
| 584 content::MediaStreamRequestResult result = | 585 content::MediaStreamRequestResult result = |
| 585 content::MEDIA_DEVICE_INVALID_STATE; | 586 content::MEDIA_DEVICE_INVALID_STATE; |
| 586 | 587 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 | 1110 |
| 1110 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1111 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
| 1111 const MediaStreamDevices& devices) { | 1112 const MediaStreamDevices& devices) { |
| 1112 test_audio_devices_ = devices; | 1113 test_audio_devices_ = devices; |
| 1113 } | 1114 } |
| 1114 | 1115 |
| 1115 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1116 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
| 1116 const MediaStreamDevices& devices) { | 1117 const MediaStreamDevices& devices) { |
| 1117 test_video_devices_ = devices; | 1118 test_video_devices_ = devices; |
| 1118 } | 1119 } |
| OLD | NEW |