| Index: chrome/common/extensions/request_media_access_permission_helper.cc
|
| diff --git a/chrome/common/extensions/request_media_access_permission_helper.cc b/chrome/common/extensions/request_media_access_permission_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c0c671d7b091c52a3d64ab828cd5a68b02577d20
|
| --- /dev/null
|
| +++ b/chrome/common/extensions/request_media_access_permission_helper.cc
|
| @@ -0,0 +1,44 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/common/extensions/request_media_access_permission_helper.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +// static
|
| +void RequestMediaAccessPermissionHelper::AuthorizeRequest(
|
| + const content::MediaStreamRequest* request,
|
| + const content::MediaResponseCallback& callback,
|
| + bool allow_audio,
|
| + bool allow_video,
|
| + bool allow_tab_media) {
|
| + content::MediaStreamDevices devices;
|
| +
|
| + bool accepted_an_audio_device = false;
|
| + bool accepted_a_video_device = false;
|
| + for (content::MediaStreamDeviceMap::const_iterator it =
|
| + request->devices.begin(); it != request->devices.end(); ++it) {
|
| + if (!accepted_an_audio_device &&
|
| + content::IsAudioMediaType(it->first) &&
|
| + !it->second.empty() &&
|
| + ((it->first == content::MEDIA_DEVICE_AUDIO_CAPTURE && allow_audio) ||
|
| + (it->first == content::MEDIA_TAB_AUDIO_CAPTURE && allow_tab_media))) {
|
| + devices.push_back(it->second.front());
|
| + accepted_an_audio_device = true;
|
| + } else if (!accepted_a_video_device &&
|
| + content::IsVideoMediaType(it->first) &&
|
| + !it->second.empty() &&
|
| + ((it->first == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
|
| + allow_video) ||
|
| + (it->first == content::MEDIA_TAB_VIDEO_CAPTURE &&
|
| + allow_tab_media))) {
|
| + devices.push_back(it->second.front());
|
| + accepted_a_video_device = true;
|
| + }
|
| + }
|
| +
|
| + callback.Run(devices);
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|