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

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

Issue 11038021: Implement Chrome Extension TabCapture API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort Created 8 years, 2 months 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
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/command_line.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/rand_util.h" 13 #include "base/rand_util.h"
13 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 14 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
14 #include "content/browser/renderer_host/media/media_stream_device_settings.h" 15 #include "content/browser/renderer_host/media/media_stream_device_settings.h"
15 #include "content/browser/renderer_host/media/media_stream_requester.h" 16 #include "content/browser/renderer_host/media/media_stream_requester.h"
16 #include "content/browser/renderer_host/media/video_capture_manager.h" 17 #include "content/browser/renderer_host/media/video_capture_manager.h"
17 #include "content/common/media/media_stream_options.h" 18 #include "content/common/media/media_stream_options.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/browser/media_observer.h" 21 #include "content/public/browser/media_observer.h"
21 #include "content/public/browser/media_request_state.h" 22 #include "content/public/browser/media_request_state.h"
23 #include "content/public/common/content_switches.h"
22 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
23 25
24 #if defined(OS_WIN) 26 #if defined(OS_WIN)
25 #include "base/win/scoped_com_initializer.h" 27 #include "base/win/scoped_com_initializer.h"
26 #endif 28 #endif
27 29
28 using content::BrowserThread; 30 using content::BrowserThread;
29 using content::MediaStreamRequest; 31 using content::MediaStreamRequest;
30 32
31 namespace { 33 namespace {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 DeviceRequest& request = requests_[*label]; 239 DeviceRequest& request = requests_[*label];
238 request.requested_device_id = device_id; 240 request.requested_device_id = device_id;
239 241
240 // Get user confirmation to use the capture device. 242 // Get user confirmation to use the capture device.
241 device_settings_->RequestCaptureDeviceUsage(*label, 243 device_settings_->RequestCaptureDeviceUsage(*label,
242 render_process_id, 244 render_process_id,
243 render_view_id, 245 render_view_id,
244 options, 246 options,
245 security_origin); 247 security_origin);
246 248
247 if (!security_origin.SchemeIs(kExtensionScheme) || 249 if (!CommandLine::ForCurrentProcess()->HasSwitch(
Aaron Boodman 2012/10/18 22:51:35 I think this check should be done in RequestMediaA
justinlin 2012/10/19 00:03:33 While I agree that might be nicer, I think it's be
Aaron Boodman 2012/10/19 00:37:20 The way that FeatureSwitch works, you can do --tab
justinlin 2012/10/19 00:47:26 Sorry should have explained. The way I set it up i
250 switches::kEnableTabCapture) ||
251 !security_origin.SchemeIs(kExtensionScheme) ||
248 (options.audio_type != content::MEDIA_TAB_AUDIO_CAPTURE && 252 (options.audio_type != content::MEDIA_TAB_AUDIO_CAPTURE &&
249 options.audio_type != content::MEDIA_NO_SERVICE) || 253 options.audio_type != content::MEDIA_NO_SERVICE) ||
250 (options.video_type != content::MEDIA_TAB_VIDEO_CAPTURE && 254 (options.video_type != content::MEDIA_TAB_VIDEO_CAPTURE &&
251 options.video_type != content::MEDIA_NO_SERVICE)) { 255 options.video_type != content::MEDIA_NO_SERVICE)) {
252 LOG(ERROR) << "Invalid request or used tab capture outside extension API."; 256 LOG(ERROR) << "Invalid request or used tab capture outside extension API.";
253 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 257 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
254 base::Bind(&MediaStreamManager::CancelGenerateStream, 258 base::Bind(&MediaStreamManager::CancelGenerateStream,
255 base::Unretained(this), *label)); 259 base::Unretained(this), *label));
256 return; 260 return;
257 } 261 }
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 it != requests_.end(); ++it) { 973 it != requests_.end(); ++it) {
970 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && 974 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES &&
971 Requested(it->second.options, stream_type)) { 975 Requested(it->second.options, stream_type)) {
972 return true; 976 return true;
973 } 977 }
974 } 978 }
975 return false; 979 return false;
976 } 980 }
977 981
978 } // namespace media_stream 982 } // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698