OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/common/extensions/request_media_access_permission_helper.h" |
| 6 |
| 7 namespace extensions { |
| 8 |
| 9 // static |
| 10 void RequestMediaAccessPermissionHelper::AuthorizeRequest( |
| 11 const content::MediaStreamRequest* request, |
| 12 const content::MediaResponseCallback& callback, |
| 13 bool allow_audio, |
| 14 bool allow_video, |
| 15 bool allow_tab_media) { |
| 16 content::MediaStreamDevices devices; |
| 17 |
| 18 bool accepted_an_audio_device = false; |
| 19 bool accepted_a_video_device = false; |
| 20 for (content::MediaStreamDeviceMap::const_iterator it = |
| 21 request->devices.begin(); it != request->devices.end(); ++it) { |
| 22 if (!accepted_an_audio_device && |
| 23 content::IsAudioMediaType(it->first) && |
| 24 !it->second.empty() && |
| 25 ((it->first == content::MEDIA_DEVICE_AUDIO_CAPTURE && allow_audio) || |
| 26 (it->first == content::MEDIA_TAB_AUDIO_CAPTURE && allow_tab_media))) { |
| 27 devices.push_back(it->second.front()); |
| 28 accepted_an_audio_device = true; |
| 29 } else if (!accepted_a_video_device && |
| 30 content::IsVideoMediaType(it->first) && |
| 31 !it->second.empty() && |
| 32 ((it->first == content::MEDIA_DEVICE_VIDEO_CAPTURE && |
| 33 allow_video) || |
| 34 (it->first == content::MEDIA_TAB_VIDEO_CAPTURE && |
| 35 allow_tab_media))) { |
| 36 devices.push_back(it->second.front()); |
| 37 accepted_a_video_device = true; |
| 38 } |
| 39 } |
| 40 |
| 41 callback.Run(devices); |
| 42 } |
| 43 |
| 44 } // namespace extensions |
OLD | NEW |