| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/media/media_devices_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 MediaDevicesDispatcherHost::MediaDevicesDispatcherHost( | 59 MediaDevicesDispatcherHost::MediaDevicesDispatcherHost( |
| 60 int render_process_id, | 60 int render_process_id, |
| 61 int routing_id, | 61 int routing_id, |
| 62 const std::string& device_id_salt, | 62 const std::string& device_id_salt, |
| 63 MediaStreamManager* media_stream_manager) | 63 MediaStreamManager* media_stream_manager) |
| 64 : render_process_id_(render_process_id), | 64 : render_process_id_(render_process_id), |
| 65 routing_id_(routing_id), | 65 routing_id_(routing_id), |
| 66 device_id_salt_(device_id_salt), | 66 device_id_salt_(device_id_salt), |
| 67 group_id_salt_(ResourceContext::CreateRandomMediaDeviceIDSalt()), | 67 group_id_salt_(ResourceContext::CreateRandomMediaDeviceIDSalt()), |
| 68 media_stream_manager_(media_stream_manager), | 68 media_stream_manager_(media_stream_manager), |
| 69 permission_checker_(base::MakeUnique<MediaDevicesPermissionChecker>()), |
| 69 weak_factory_(this) { | 70 weak_factory_(this) { |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 71 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 71 } | 72 } |
| 72 | 73 |
| 73 MediaDevicesDispatcherHost::~MediaDevicesDispatcherHost() { | 74 MediaDevicesDispatcherHost::~MediaDevicesDispatcherHost() { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 75 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void MediaDevicesDispatcherHost::EnumerateDevices( | 78 void MediaDevicesDispatcherHost::EnumerateDevices( |
| 78 bool request_audio_input, | 79 bool request_audio_input, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 93 bad_message::ReceivedBadMessage(render_process_id_, | 94 bad_message::ReceivedBadMessage(render_process_id_, |
| 94 bad_message::MDDH_UNAUTHORIZED_ORIGIN); | 95 bad_message::MDDH_UNAUTHORIZED_ORIGIN); |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 | 98 |
| 98 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; | 99 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; |
| 99 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_INPUT] = request_audio_input; | 100 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_INPUT] = request_audio_input; |
| 100 devices_to_enumerate[MEDIA_DEVICE_TYPE_VIDEO_INPUT] = request_video_input; | 101 devices_to_enumerate[MEDIA_DEVICE_TYPE_VIDEO_INPUT] = request_video_input; |
| 101 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = request_audio_output; | 102 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = request_audio_output; |
| 102 | 103 |
| 103 permission_checker_.CheckPermissions( | 104 permission_checker_->CheckPermissions( |
| 104 devices_to_enumerate, render_process_id_, routing_id_, security_origin, | 105 devices_to_enumerate, render_process_id_, routing_id_, security_origin, |
| 105 base::Bind(&MediaDevicesDispatcherHost::DoEnumerateDevices, | 106 base::Bind(&MediaDevicesDispatcherHost::DoEnumerateDevices, |
| 106 weak_factory_.GetWeakPtr(), devices_to_enumerate, | 107 weak_factory_.GetWeakPtr(), devices_to_enumerate, |
| 107 security_origin, client_callback)); | 108 security_origin, client_callback)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void MediaDevicesDispatcherHost::SetPermissionChecker( | 111 void MediaDevicesDispatcherHost::SetPermissionChecker( |
| 111 const MediaDevicesPermissionChecker& permission_checker) { | 112 std::unique_ptr<MediaDevicesPermissionChecker> permission_checker) { |
| 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 113 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 113 permission_checker_ = permission_checker; | 114 DCHECK(permission_checker); |
| 115 permission_checker_ = std::move(permission_checker); |
| 114 } | 116 } |
| 115 | 117 |
| 116 void MediaDevicesDispatcherHost::DoEnumerateDevices( | 118 void MediaDevicesDispatcherHost::DoEnumerateDevices( |
| 117 const MediaDevicesManager::BoolDeviceTypes& requested_types, | 119 const MediaDevicesManager::BoolDeviceTypes& requested_types, |
| 118 const url::Origin& security_origin, | 120 const url::Origin& security_origin, |
| 119 const EnumerateDevicesCallback& client_callback, | 121 const EnumerateDevicesCallback& client_callback, |
| 120 const MediaDevicesManager::BoolDeviceTypes& has_permissions) { | 122 const MediaDevicesManager::BoolDeviceTypes& has_permissions) { |
| 121 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 123 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 122 media_stream_manager_->media_devices_manager()->EnumerateDevices( | 124 media_stream_manager_->media_devices_manager()->EnumerateDevices( |
| 123 requested_types, | 125 requested_types, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 141 for (const auto& device_info : enumeration[i]) { | 143 for (const auto& device_info : enumeration[i]) { |
| 142 result[i].push_back(TranslateDeviceInfo(has_permissions[i], | 144 result[i].push_back(TranslateDeviceInfo(has_permissions[i], |
| 143 device_id_salt_, group_id_salt_, | 145 device_id_salt_, group_id_salt_, |
| 144 security_origin, device_info)); | 146 security_origin, device_info)); |
| 145 } | 147 } |
| 146 } | 148 } |
| 147 client_callback.Run(result); | 149 client_callback.Run(result); |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace content | 152 } // namespace content |
| OLD | NEW |