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_device_settings.h" | 5 #include "content/browser/renderer_host/media/media_stream_device_settings.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" | 12 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" |
13 #include "content/browser/renderer_host/render_view_host_delegate.h" | |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | |
13 #include "content/common/media/media_stream_options.h" | 15 #include "content/common/media/media_stream_options.h" |
14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
16 #include "content/public/common/media_stream_request.h" | 18 #include "content/public/common/media_stream_request.h" |
17 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
18 | 20 |
19 using content::BrowserThread; | 21 using content::BrowserThread; |
20 using content::MediaStreamDevice; | 22 using content::MediaStreamDevice; |
21 using content::MediaStreamRequest; | 23 using content::MediaStreamRequest; |
22 | 24 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 for (DeviceMap::iterator it = request->devices_full.begin(); | 317 for (DeviceMap::iterator it = request->devices_full.begin(); |
316 it != request->devices_full.end(); ++it) { | 318 it != request->devices_full.end(); ++it) { |
317 request->devices[it->first].clear(); | 319 request->devices[it->first].clear(); |
318 for (StreamDeviceInfoArray::iterator device = it->second.begin(); | 320 for (StreamDeviceInfoArray::iterator device = it->second.begin(); |
319 device != it->second.end(); ++device) { | 321 device != it->second.end(); ++device) { |
320 request->devices[it->first].push_back(MediaStreamDevice( | 322 request->devices[it->first].push_back(MediaStreamDevice( |
321 it->first, device->device_id, device->name)); | 323 it->first, device->device_id, device->name)); |
322 } | 324 } |
323 } | 325 } |
324 | 326 |
325 // Send the permission request to the content client. | |
326 scoped_refptr<ResponseCallbackHelper> helper = | 327 scoped_refptr<ResponseCallbackHelper> helper = |
327 new ResponseCallbackHelper(AsWeakPtr()); | 328 new ResponseCallbackHelper(AsWeakPtr()); |
328 content::MediaResponseCallback callback = | 329 content::MediaResponseCallback callback = |
329 base::Bind(&ResponseCallbackHelper::PostResponse, | 330 base::Bind(&ResponseCallbackHelper::PostResponse, |
330 helper.get(), label); | 331 helper.get(), label); |
332 | |
331 BrowserThread::PostTask( | 333 BrowserThread::PostTask( |
332 BrowserThread::UI, FROM_HERE, | 334 BrowserThread::UI, FROM_HERE, |
333 base::Bind( | 335 base::Bind(&MediaStreamDeviceSettings::DoRequest, |
334 &content::ContentBrowserClient::RequestMediaAccessPermission, | 336 base::Unretained(this), request, callback)); |
335 base::Unretained(content::GetContentClient()->browser()), | 337 } |
336 request, callback)); | |
337 | 338 |
339 void MediaStreamDeviceSettings::DoRequest( | |
jochen (gone - plz use gerrit)
2012/06/09 07:55:21
could this be a helper function in an anon namespa
Evan Stade
2012/06/12 00:00:46
indeed I suppose it could
| |
340 const MediaStreamDeviceSettingsRequest* request, | |
341 const content::MediaResponseCallback& callback) { | |
342 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
343 | |
344 // Send the permission request to the web contents. | |
345 content::RenderViewHostImpl* host = | |
346 content::RenderViewHostImpl::FromID(request->render_process_id, | |
347 request->render_view_id); | |
348 | |
349 // Tab may have gone away. | |
350 if (!host || !host->GetDelegate()) | |
351 callback.Run(content::MediaStreamDevices()); | |
352 | |
353 host->GetDelegate()->RequestMediaAccessPermission(request, callback); | |
338 } | 354 } |
339 | 355 |
340 } // namespace media_stream | 356 } // namespace media_stream |
OLD | NEW |