Bug 1389220 - Prevent navigator.activeVRDisplays from activating VR hardware and runtimes r=daoshengmu

MozReview-Commit-ID: JYMiGyT0iVY

--HG--
extra : rebase_source : 4bbf0879c1b7234f59e4b503f9dfbd80aad47f76
This commit is contained in:
Kearwood "Kip" Gilbert 2017-09-20 15:39:35 -07:00
Родитель a91ab5dddf
Коммит 017d4c4b91
1 изменённых файлов: 8 добавлений и 3 удалений

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

@ -1493,14 +1493,19 @@ Navigator::GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const
{
/**
* Get only the active VR displays.
* Callers do not wish to VRDisplay::RefreshVRDisplays, as the enumeration may
* activate hardware that is not yet intended to be used.
* GetActiveVRDisplays should only enumerate displays that
* are already active without causing any other hardware to be
* activated.
* We must not call nsGlobalWindow::NotifyVREventListenerAdded here,
* as that would cause enumeration and activation of other VR hardware.
* Activating VR hardware is intrusive to the end user, as it may
* involve physically powering on devices that the user did not
* intend to use.
*/
if (!mWindow || !mWindow->GetDocShell()) {
return;
}
nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
win->NotifyVREventListenerAdded();
nsTArray<RefPtr<VRDisplay>> displays;
if (win->UpdateVRDisplays(displays)) {
for (auto display : displays) {