Bug 1548087 - Move IsActivelyCapturingOrHasAPermission out of devices iteration. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D43395

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Nguyen 2019-09-05 17:04:48 +00:00
Родитель 7d54759c16
Коммит b21cdcbc87
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -142,6 +142,10 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
}
auto windowId = window->WindowID();
nsTArray<RefPtr<MediaDeviceInfo>> infos;
bool allowLabel =
aDevices->Length() == 0 ||
MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId);
for (auto& device : *aDevices) {
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
device->mKind == dom::MediaDeviceKind::Videoinput ||
@ -149,8 +153,7 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
// Include name only if page currently has a gUM stream active
// or persistent permissions (audio or video) have been granted
nsString label;
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId) ||
if (allowLabel ||
Preferences::GetBool("media.navigator.permission.disabled",
false)) {
label = device->mName;