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

Side by Side Diff: chrome/common/extensions/request_media_access_permission_helper.cc

Issue 11198044: Make tab capture media stream requests verify that the request came from extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix || and keep webcam/mic disabled in extensions 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
(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,
Aaron Boodman 2012/10/24 01:29:38 I think it would be better to pass in Extension* i
justinlin 2012/10/24 02:04:54 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698