| 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_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/content_settings/content_settings_provider.h" | 8 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { | 82 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { |
| 83 // For tab media requests, we need to make sure the request came from the | 83 // For tab media requests, we need to make sure the request came from the |
| 84 // extension API, so we check the registry here. | 84 // extension API, so we check the registry here. |
| 85 content::MediaStreamDeviceMap::const_iterator tab_video = | 85 content::MediaStreamDeviceMap::const_iterator tab_video = |
| 86 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); | 86 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); |
| 87 content::MediaStreamDeviceMap::const_iterator tab_audio = | 87 content::MediaStreamDeviceMap::const_iterator tab_audio = |
| 88 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); | 88 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); |
| 89 if (tab_video != request_.devices.end() || | 89 if (tab_video != request_.devices.end() || |
| 90 tab_audio != request_.devices.end()) { | 90 tab_audio != request_.devices.end()) { |
| 91 std::string audio_device_id; | |
| 92 std::string video_device_id; | |
| 93 | |
| 94 if ((tab_audio != request_.devices.end()) && !tab_audio->second.empty()) | |
| 95 audio_device_id = tab_audio->second[0].device_id; | |
| 96 if ((tab_video != request_.devices.end()) && !tab_video->second.empty()) | |
| 97 video_device_id = tab_video->second[0].device_id; | |
| 98 | |
| 99 DCHECK(!audio_device_id.empty() || !video_device_id.empty()); | |
| 100 extensions::TabCaptureRegistry* registry = | 91 extensions::TabCaptureRegistry* registry = |
| 101 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); | 92 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); |
| 102 if (!registry->VerifyRequest(!video_device_id.empty() ? | 93 |
| 103 video_device_id : audio_device_id)) { | 94 if (!registry->VerifyRequest(request_.render_process_id, |
| 95 request_.render_view_id)) { |
| 104 Deny(); | 96 Deny(); |
| 105 } else { | 97 } else { |
| 106 Accept(audio_device_id, video_device_id, false); | 98 content::MediaStreamDevices devices; |
| 99 |
| 100 if (tab_video != request_.devices.end()) { |
| 101 devices.push_back(content::MediaStreamDevice( |
| 102 content::MEDIA_TAB_VIDEO_CAPTURE, "", "")); |
| 103 } |
| 104 if (tab_audio != request_.devices.end()) { |
| 105 devices.push_back(content::MediaStreamDevice( |
| 106 content::MEDIA_TAB_AUDIO_CAPTURE, "", "")); |
| 107 } |
| 108 |
| 109 callback_.Run(devices); |
| 107 } | 110 } |
| 108 | 111 |
| 109 return true; | 112 return true; |
| 110 } | 113 } |
| 111 | 114 |
| 112 // Deny the request if the security origin is empty, this happens with | 115 // Deny the request if the security origin is empty, this happens with |
| 113 // file access without |--allow-file-access-from-files| flag. | 116 // file access without |--allow-file-access-from-files| flag. |
| 114 if (request_.security_origin.is_empty()) { | 117 if (request_.security_origin.is_empty()) { |
| 115 Deny(); | 118 Deny(); |
| 116 return true; | 119 return true; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 for (content::MediaStreamDevices::const_iterator device_it = | 385 for (content::MediaStreamDevices::const_iterator device_it = |
| 383 it->second.begin(); | 386 it->second.begin(); |
| 384 device_it != it->second.end(); ++device_it) { | 387 device_it != it->second.end(); ++device_it) { |
| 385 const content::MediaStreamDevice& candidate = *device_it; | 388 const content::MediaStreamDevice& candidate = *device_it; |
| 386 if (candidate.device_id == device_id) | 389 if (candidate.device_id == device_id) |
| 387 return &candidate; | 390 return &candidate; |
| 388 } | 391 } |
| 389 } | 392 } |
| 390 return NULL; | 393 return NULL; |
| 391 } | 394 } |
| OLD | NEW |