| 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 "content/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 279 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 280 base::Bind(&MediaStreamManager::CancelRequest, | 280 base::Bind(&MediaStreamManager::CancelRequest, |
| 281 base::Unretained(this), *label)); | 281 base::Unretained(this), *label)); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 // TODO(miu): We should ask the device manager whether a device with id | 285 // TODO(miu): We should ask the device manager whether a device with id |
| 286 // |device_id| actually exists. Note that no such MediaStreamProvider API for | 286 // |device_id| actually exists. Note that no such MediaStreamProvider API for |
| 287 // this currently exists. Also, we don't have a user-friendly device name for | 287 // this currently exists. Also, we don't have a user-friendly device name for |
| 288 // the infobar UI. | 288 // the infobar UI. |
| 289 StreamDeviceInfoArray devices; | |
| 290 if (content::IsAudioMediaType(options.audio_type)) { | 289 if (content::IsAudioMediaType(options.audio_type)) { |
| 291 // TODO(justinlin): Updating the state to requested and pending are no-ops | 290 // TODO(justinlin): Updating the state to requested and pending are no-ops |
| 292 // in terms of the media manager, but these are the state changes we want to | 291 // in terms of the media manager, but these are the state changes we want to |
| 293 // support in terms of extensions (which is registered as an observer). | 292 // support in terms of extensions (which is registered as an observer). |
| 294 request.setState(options.audio_type, | 293 request.setState(options.audio_type, |
| 295 content::MEDIA_REQUEST_STATE_REQUESTED); | 294 content::MEDIA_REQUEST_STATE_REQUESTED); |
| 296 request.setState(options.audio_type, | 295 request.setState(options.audio_type, |
| 297 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 296 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
| 298 devices.push_back( | 297 ui_controller_->AddAvailableDevicesToRequest( |
| 299 StreamDeviceInfo(options.audio_type, device_id, device_id, false)); | 298 *label, options.audio_type, StreamDeviceInfoArray( |
| 299 1, StreamDeviceInfo(options.audio_type, device_id, device_id, |
| 300 false))); |
| 300 } | 301 } |
| 301 if (content::IsVideoMediaType(options.video_type)) { | 302 if (content::IsVideoMediaType(options.video_type)) { |
| 302 request.setState(options.video_type, | 303 request.setState(options.video_type, |
| 303 content::MEDIA_REQUEST_STATE_REQUESTED); | 304 content::MEDIA_REQUEST_STATE_REQUESTED); |
| 304 request.setState(options.video_type, | 305 request.setState(options.video_type, |
| 305 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 306 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
| 306 devices.push_back( | 307 ui_controller_->AddAvailableDevicesToRequest( |
| 307 StreamDeviceInfo(options.video_type, device_id, device_id, false)); | 308 *label, options.video_type, StreamDeviceInfoArray( |
| 309 1, StreamDeviceInfo(options.video_type, device_id, device_id, |
| 310 false))); |
| 308 } | 311 } |
| 309 | |
| 310 // Bypass the user authorization dropdown for tab capture. | |
| 311 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
| 312 base::Bind(&MediaStreamManager::DevicesAccepted, | |
| 313 base::Unretained(this), *label, devices)); | |
| 314 } | 312 } |
| 315 | 313 |
| 316 void MediaStreamManager::CancelRequest(const std::string& label) { | 314 void MediaStreamManager::CancelRequest(const std::string& label) { |
| 317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 318 | 316 |
| 319 DeviceRequests::iterator it = requests_.find(label); | 317 DeviceRequests::iterator it = requests_.find(label); |
| 320 if (it != requests_.end()) { | 318 if (it != requests_.end()) { |
| 321 // The request isn't complete, notify the UI immediately. | 319 // The request isn't complete, notify the UI immediately. |
| 322 ui_controller_->CancelUIRequest(label); | 320 ui_controller_->CancelUIRequest(label); |
| 323 | 321 |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 it != requests_.end(); ++it) { | 1054 it != requests_.end(); ++it) { |
| 1057 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && | 1055 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && |
| 1058 Requested(it->second.options, stream_type)) { | 1056 Requested(it->second.options, stream_type)) { |
| 1059 return true; | 1057 return true; |
| 1060 } | 1058 } |
| 1061 } | 1059 } |
| 1062 return false; | 1060 return false; |
| 1063 } | 1061 } |
| 1064 | 1062 |
| 1065 } // namespace media_stream | 1063 } // namespace media_stream |
| OLD | NEW |