| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 bool video_requested_ = false; | 246 bool video_requested_ = false; |
| 247 bool audio_blocked_ = false; | 247 bool audio_blocked_ = false; |
| 248 bool video_blocked_ = false; | 248 bool video_blocked_ = false; |
| 249 | 249 |
| 250 content::MediaStreamRequestResult denial_reason_ = content::MEDIA_DEVICE_OK; | 250 content::MediaStreamRequestResult denial_reason_ = content::MEDIA_DEVICE_OK; |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 // Implementation of PermissionPromptDelegate which actually shows a permission | 253 // Implementation of PermissionPromptDelegate which actually shows a permission |
| 254 // prompt. | 254 // prompt. |
| 255 class MediaStreamDevicesController::PermissionPromptDelegateImpl | 255 class MediaStreamDevicesController::PermissionPromptDelegateImpl |
| 256 : public MediaStreamDevicesController::PermissionPromptDelegate { | 256 : public internal::PermissionPromptDelegate { |
| 257 public: | 257 public: |
| 258 void ShowPrompt( | 258 void ShowPrompt( |
| 259 bool user_gesture, | 259 bool user_gesture, |
| 260 content::WebContents* web_contents, | 260 content::WebContents* web_contents, |
| 261 std::unique_ptr<MediaStreamDevicesController> controller) override { | 261 std::unique_ptr<MediaStreamDevicesController> controller) override { |
| 262 #if defined(OS_ANDROID) | 262 #if defined(OS_ANDROID) |
| 263 PermissionUmaUtil::RecordPermissionPromptShown( | 263 PermissionUmaUtil::RecordPermissionPromptShown( |
| 264 controller->GetPermissionRequestType(), | 264 controller->GetPermissionRequestType(), |
| 265 PermissionUtil::GetGestureType(user_gesture)); | 265 PermissionUtil::GetGestureType(user_gesture)); |
| 266 if (PermissionDialogDelegate::ShouldShowDialog(user_gesture)) { | 266 if (PermissionDialogDelegate::ShouldShowDialog(user_gesture)) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 PermissionRequestType MediaStreamDevicesController::GetPermissionRequestType() | 397 PermissionRequestType MediaStreamDevicesController::GetPermissionRequestType() |
| 398 const { | 398 const { |
| 399 return PermissionRequestType::MEDIA_STREAM; | 399 return PermissionRequestType::MEDIA_STREAM; |
| 400 } | 400 } |
| 401 | 401 |
| 402 // static | 402 // static |
| 403 void MediaStreamDevicesController::RequestPermissionsWithDelegate( | 403 void MediaStreamDevicesController::RequestPermissionsWithDelegate( |
| 404 content::WebContents* web_contents, | 404 content::WebContents* web_contents, |
| 405 const content::MediaStreamRequest& request, | 405 const content::MediaStreamRequest& request, |
| 406 const content::MediaResponseCallback& callback, | 406 const content::MediaResponseCallback& callback, |
| 407 PermissionPromptDelegate* delegate) { | 407 internal::PermissionPromptDelegate* delegate) { |
| 408 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { | 408 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { |
| 409 MediaPermissionRequestLogger::LogRequest( | 409 MediaPermissionRequestLogger::LogRequest( |
| 410 web_contents, request.render_process_id, request.render_frame_id, | 410 web_contents, request.render_process_id, request.render_frame_id, |
| 411 content::IsOriginSecure(request.security_origin)); | 411 content::IsOriginSecure(request.security_origin)); |
| 412 } | 412 } |
| 413 | 413 |
| 414 MediaPermissionStatus initial_permission(request); | 414 MediaPermissionStatus initial_permission(request); |
| 415 if (initial_permission.audio_requested() && | 415 if (initial_permission.audio_requested() && |
| 416 !HasAvailableDevices(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 416 !HasAvailableDevices(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 417 request.requested_audio_device_id)) { | 417 request.requested_audio_device_id)) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 | 781 |
| 782 // Don't approve device requests if the tab was hidden. | 782 // Don't approve device requests if the tab was hidden. |
| 783 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 783 // 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? | 784 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 785 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 785 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 786 #endif | 786 #endif |
| 787 return true; | 787 return true; |
| 788 } | 788 } |
| OLD | NEW |