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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { | 67 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { |
68 // For tab media requests, we need to make sure the request came from the | 68 // For tab media requests, we need to make sure the request came from the |
69 // extension API, so we check the registry here. | 69 // extension API, so we check the registry here. |
70 content::MediaStreamDeviceMap::const_iterator tab_video = | 70 content::MediaStreamDeviceMap::const_iterator tab_video = |
71 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); | 71 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); |
72 content::MediaStreamDeviceMap::const_iterator tab_audio = | 72 content::MediaStreamDeviceMap::const_iterator tab_audio = |
73 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); | 73 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); |
74 if (tab_video != request_.devices.end() || | 74 if (tab_video != request_.devices.end() || |
75 tab_audio != request_.devices.end()) { | 75 tab_audio != request_.devices.end()) { |
76 std::string audio_device_id; | |
77 std::string video_device_id; | |
78 | |
79 if ((tab_audio != request_.devices.end()) && !tab_audio->second.empty()) | |
80 audio_device_id = tab_audio->second[0].device_id; | |
81 if ((tab_video != request_.devices.end()) && !tab_video->second.empty()) | |
82 video_device_id = tab_video->second[0].device_id; | |
83 | |
84 DCHECK(!audio_device_id.empty() || !video_device_id.empty()); | |
85 extensions::TabCaptureRegistry* registry = | 76 extensions::TabCaptureRegistry* registry = |
86 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); | 77 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); |
87 if (!registry->VerifyRequest(!video_device_id.empty() ? | 78 |
88 video_device_id : audio_device_id)) { | 79 if (!registry->VerifyRequest(request_.render_process_id, |
| 80 request_.render_view_id)) { |
89 Deny(); | 81 Deny(); |
90 } else { | 82 } else { |
91 Accept(audio_device_id, video_device_id, false); | 83 content::MediaStreamDevices devices; |
| 84 |
| 85 if (tab_video != request_.devices.end()) { |
| 86 devices.push_back(content::MediaStreamDevice( |
| 87 content::MEDIA_TAB_VIDEO_CAPTURE, "", "")); |
| 88 } |
| 89 if (tab_audio != request_.devices.end()) { |
| 90 devices.push_back(content::MediaStreamDevice( |
| 91 content::MEDIA_TAB_AUDIO_CAPTURE, "", "")); |
| 92 } |
| 93 |
| 94 callback_.Run(devices); |
92 } | 95 } |
93 | 96 |
94 return true; | 97 return true; |
95 } | 98 } |
96 | 99 |
97 // Deny the request if the security origin is empty, this happens with | 100 // Deny the request if the security origin is empty, this happens with |
98 // file access without |--allow-file-access-from-files| flag. | 101 // file access without |--allow-file-access-from-files| flag. |
99 if (request_.security_origin.is_empty()) { | 102 if (request_.security_origin.is_empty()) { |
100 Deny(); | 103 Deny(); |
101 return true; | 104 return true; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 for (content::MediaStreamDevices::const_iterator device_it = | 356 for (content::MediaStreamDevices::const_iterator device_it = |
354 it->second.begin(); | 357 it->second.begin(); |
355 device_it != it->second.end(); ++device_it) { | 358 device_it != it->second.end(); ++device_it) { |
356 const content::MediaStreamDevice& candidate = *device_it; | 359 const content::MediaStreamDevice& candidate = *device_it; |
357 if (candidate.device_id == device_id) | 360 if (candidate.device_id == device_id) |
358 return &candidate; | 361 return &candidate; |
359 } | 362 } |
360 } | 363 } |
361 return NULL; | 364 return NULL; |
362 } | 365 } |
OLD | NEW |