Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 11273033: Implement Chrome Extension TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lazy init registry Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/tab_capture/permissions/test.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 262 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
263 base::Bind(&MediaStreamManager::CancelRequest, 263 base::Bind(&MediaStreamManager::CancelRequest,
264 base::Unretained(this), *label)); 264 base::Unretained(this), *label));
265 return; 265 return;
266 } 266 }
267 267
268 // TODO(miu): We should ask the device manager whether a device with id 268 // TODO(miu): We should ask the device manager whether a device with id
269 // |device_id| actually exists. Note that no such MediaStreamProvider API for 269 // |device_id| actually exists. Note that no such MediaStreamProvider API for
270 // this currently exists. Also, we don't have a user-friendly device name for 270 // this currently exists. Also, we don't have a user-friendly device name for
271 // the infobar UI. 271 // the infobar UI.
272 StreamDeviceInfoArray devices;
273 if (content::IsAudioMediaType(options.audio_type)) { 272 if (content::IsAudioMediaType(options.audio_type)) {
274 // TODO(justinlin): Updating the state to requested and pending are no-ops 273 // TODO(justinlin): Updating the state to requested and pending are no-ops
275 // in terms of the media manager, but these are the state changes we want to 274 // in terms of the media manager, but these are the state changes we want to
276 // support in terms of extensions (which is registered as an observer). 275 // support in terms of extensions (which is registered as an observer).
277 request.setState(options.audio_type, 276 request.setState(options.audio_type,
278 content::MEDIA_REQUEST_STATE_REQUESTED); 277 content::MEDIA_REQUEST_STATE_REQUESTED);
279 request.setState(options.audio_type, 278 request.setState(options.audio_type,
280 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); 279 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL);
281 devices.push_back( 280 ui_controller_->AddAvailableDevicesToRequest(
282 StreamDeviceInfo(options.audio_type, device_id, device_id, false)); 281 *label, options.audio_type, StreamDeviceInfoArray(
282 1, StreamDeviceInfo(options.audio_type, device_id, device_id,
283 false)));
283 } 284 }
284 if (content::IsVideoMediaType(options.video_type)) { 285 if (content::IsVideoMediaType(options.video_type)) {
285 request.setState(options.video_type, 286 request.setState(options.video_type,
286 content::MEDIA_REQUEST_STATE_REQUESTED); 287 content::MEDIA_REQUEST_STATE_REQUESTED);
287 request.setState(options.video_type, 288 request.setState(options.video_type,
288 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL); 289 content::MEDIA_REQUEST_STATE_PENDING_APPROVAL);
289 devices.push_back( 290 ui_controller_->AddAvailableDevicesToRequest(
290 StreamDeviceInfo(options.video_type, device_id, device_id, false)); 291 *label, options.video_type, StreamDeviceInfoArray(
292 1, StreamDeviceInfo(options.video_type, device_id, device_id,
293 false)));
291 } 294 }
292
293 // Bypass the user authorization dropdown for tab capture.
294 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
295 base::Bind(&MediaStreamManager::DevicesAccepted,
296 base::Unretained(this), *label, devices));
297 } 295 }
298 296
299 void MediaStreamManager::CancelRequest(const std::string& label) { 297 void MediaStreamManager::CancelRequest(const std::string& label) {
300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
301 299
302 DeviceRequests::iterator it = requests_.find(label); 300 DeviceRequests::iterator it = requests_.find(label);
303 if (it != requests_.end()) { 301 if (it != requests_.end()) {
304 // The request isn't complete, notify the UI immediately. 302 // The request isn't complete, notify the UI immediately.
305 ui_controller_->CancelUIRequest(label); 303 ui_controller_->CancelUIRequest(label);
306 304
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 it != requests_.end(); ++it) { 1040 it != requests_.end(); ++it) {
1043 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && 1041 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES &&
1044 Requested(it->second.options, stream_type)) { 1042 Requested(it->second.options, stream_type)) {
1045 return true; 1043 return true;
1046 } 1044 }
1047 } 1045 }
1048 return false; 1046 return false;
1049 } 1047 }
1050 1048
1051 } // namespace media_stream 1049 } // namespace media_stream
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tab_capture/permissions/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698