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

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

Issue 12180015: Revert 180370 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | 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/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/public/common/media_stream_request.h" 25 #include "content/public/common/media_stream_request.h"
26 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
27 #include "media/audio/audio_manager_base.h" 27 #include "media/audio/audio_manager_base.h"
28 #include "media/audio/audio_util.h" 28 #include "media/audio/audio_util.h"
29 #include "media/base/channel_layout.h" 29 #include "media/base/channel_layout.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "base/win/scoped_com_initializer.h" 32 #include "base/win/scoped_com_initializer.h"
33 #endif 33 #endif
34 34
35 namespace {
36 const char kExtensionScheme[] = "chrome-extension";
37 } // namespace
38
35 namespace content { 39 namespace content {
36 40
37 // Creates a random label used to identify requests. 41 // Creates a random label used to identify requests.
38 static std::string RandomLabel() { 42 static std::string RandomLabel() {
39 // An earlier PeerConnection spec, 43 // An earlier PeerConnection spec,
40 // http://dev.w3.org/2011/webrtc/editor/webrtc.html, specified the 44 // http://dev.w3.org/2011/webrtc/editor/webrtc.html, specified the
41 // MediaStream::label alphabet as containing 36 characters from 45 // MediaStream::label alphabet as containing 36 characters from
42 // range: U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, 46 // range: U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E,
43 // U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E. 47 // U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E.
44 // Here we use a safe subset. 48 // Here we use a safe subset.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 238
235 std::string MediaStreamManager::GenerateStreamForDevice( 239 std::string MediaStreamManager::GenerateStreamForDevice(
236 MediaStreamRequester* requester, int render_process_id, int render_view_id, 240 MediaStreamRequester* requester, int render_process_id, int render_view_id,
237 const StreamOptions& options, const std::string& device_id, 241 const StreamOptions& options, const std::string& device_id,
238 const GURL& security_origin) { 242 const GURL& security_origin) {
239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
240 244
241 int target_render_process_id = -1; 245 int target_render_process_id = -1;
242 int target_render_view_id = -1; 246 int target_render_view_id = -1;
243 247
244 // We will post the request to the render view that is the target of the 248 // We will post the request to the target render view, not the source (i.e.
245 // capture. 249 // source is an extension, and target is the tab we want to capture).
246 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget( 250 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget(
247 device_id, &target_render_process_id, &target_render_view_id); 251 device_id, &target_render_process_id, &target_render_view_id);
248 252
249 if (!has_valid_device_id || 253 if (!has_valid_device_id ||
254 !security_origin.SchemeIs(kExtensionScheme) ||
250 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE && 255 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
251 options.audio_type != MEDIA_NO_SERVICE) || 256 options.audio_type != MEDIA_NO_SERVICE) ||
252 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE && 257 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE &&
253 options.video_type != MEDIA_NO_SERVICE)) { 258 options.video_type != MEDIA_NO_SERVICE)) {
254 LOG(ERROR) << "Invalid request."; 259 LOG(ERROR) << "Invalid request or used tab capture outside extension API.";
255 return std::string(); 260 return std::string();
256 } 261 }
257 262
258 // Create a new request based on options. 263 // Create a new request based on options.
259 DeviceRequest* request = new DeviceRequest(requester, options, 264 DeviceRequest* request = new DeviceRequest(requester, options,
260 MEDIA_GENERATE_STREAM, 265 MEDIA_GENERATE_STREAM,
261 target_render_process_id, 266 target_render_process_id,
262 target_render_view_id, 267 target_render_view_id,
263 security_origin); 268 security_origin);
264 const std::string& label = AddRequest(request); 269 const std::string& label = AddRequest(request);
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 } 1118 }
1114 1119
1115 // Always do enumeration even though some enumeration is in progress, 1120 // Always do enumeration even though some enumeration is in progress,
1116 // because those enumeration commands could be sent before these devices 1121 // because those enumeration commands could be sent before these devices
1117 // change. 1122 // change.
1118 ++active_enumeration_ref_count_[stream_type]; 1123 ++active_enumeration_ref_count_[stream_type];
1119 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 1124 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
1120 } 1125 }
1121 1126
1122 } // namespace content 1127 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698