| 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_stream_devices_controller.h" | 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 PermissionRequestManager* permission_request_manager = | 274 PermissionRequestManager* permission_request_manager = |
| 275 PermissionRequestManager::FromWebContents(web_contents); | 275 PermissionRequestManager::FromWebContents(web_contents); |
| 276 if (permission_request_manager) | 276 if (permission_request_manager) |
| 277 permission_request_manager->AddRequest(controller.release()); | 277 permission_request_manager->AddRequest(controller.release()); |
| 278 #endif | 278 #endif |
| 279 } | 279 } |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 // static | 282 // static |
| 283 void MediaStreamDevicesController::RequestPermissions( | 283 void MediaStreamDevicesController::RequestPermissions( |
| 284 content::WebContents* web_contents, | |
| 285 const content::MediaStreamRequest& request, | 284 const content::MediaStreamRequest& request, |
| 286 const content::MediaResponseCallback& callback) { | 285 const content::MediaResponseCallback& callback) { |
| 287 PermissionPromptDelegateImpl delegate; | 286 PermissionPromptDelegateImpl delegate; |
| 288 RequestPermissionsWithDelegate(web_contents, request, callback, &delegate); | 287 RequestPermissionsWithDelegate(request, callback, &delegate); |
| 289 } | 288 } |
| 290 | 289 |
| 291 // static | 290 // static |
| 292 void MediaStreamDevicesController::RegisterProfilePrefs( | 291 void MediaStreamDevicesController::RegisterProfilePrefs( |
| 293 user_prefs::PrefRegistrySyncable* prefs) { | 292 user_prefs::PrefRegistrySyncable* prefs) { |
| 294 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, true); | 293 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, true); |
| 295 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, true); | 294 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, true); |
| 296 prefs->RegisterListPref(prefs::kVideoCaptureAllowedUrls); | 295 prefs->RegisterListPref(prefs::kVideoCaptureAllowedUrls); |
| 297 prefs->RegisterListPref(prefs::kAudioCaptureAllowedUrls); | 296 prefs->RegisterListPref(prefs::kAudioCaptureAllowedUrls); |
| 298 } | 297 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 delete this; | 393 delete this; |
| 395 } | 394 } |
| 396 | 395 |
| 397 PermissionRequestType MediaStreamDevicesController::GetPermissionRequestType() | 396 PermissionRequestType MediaStreamDevicesController::GetPermissionRequestType() |
| 398 const { | 397 const { |
| 399 return PermissionRequestType::MEDIA_STREAM; | 398 return PermissionRequestType::MEDIA_STREAM; |
| 400 } | 399 } |
| 401 | 400 |
| 402 // static | 401 // static |
| 403 void MediaStreamDevicesController::RequestPermissionsWithDelegate( | 402 void MediaStreamDevicesController::RequestPermissionsWithDelegate( |
| 404 content::WebContents* web_contents, | |
| 405 const content::MediaStreamRequest& request, | 403 const content::MediaStreamRequest& request, |
| 406 const content::MediaResponseCallback& callback, | 404 const content::MediaResponseCallback& callback, |
| 407 internal::PermissionPromptDelegate* delegate) { | 405 internal::PermissionPromptDelegate* delegate) { |
| 406 content::WebContents* web_contents = |
| 407 content::WebContents::FromRenderFrameHost( |
| 408 content::RenderFrameHost::FromID(request.render_process_id, |
| 409 request.render_frame_id)); |
| 408 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { | 410 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { |
| 409 MediaPermissionRequestLogger::LogRequest( | 411 MediaPermissionRequestLogger::LogRequest( |
| 410 web_contents, request.render_process_id, request.render_frame_id, | 412 web_contents, request.render_process_id, request.render_frame_id, |
| 411 content::IsOriginSecure(request.security_origin)); | 413 content::IsOriginSecure(request.security_origin)); |
| 412 } | 414 } |
| 413 | 415 |
| 414 MediaPermissionStatus initial_permission(request); | 416 MediaPermissionStatus initial_permission(request); |
| 415 if (initial_permission.audio_requested() && | 417 if (initial_permission.audio_requested() && |
| 416 !HasAvailableDevices(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 418 !HasAvailableDevices(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 417 request.requested_audio_device_id)) { | 419 request.requested_audio_device_id)) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 } | 781 } |
| 780 } | 782 } |
| 781 | 783 |
| 782 // Don't approve device requests if the tab was hidden. | 784 // Don't approve device requests if the tab was hidden. |
| 783 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 785 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 784 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 786 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 785 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 787 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 786 #endif | 788 #endif |
| 787 return true; | 789 return true; |
| 788 } | 790 } |
| OLD | NEW |