gecko-dev/dom/vr/VREventObserver.h
Kearwood "Kip" Gilbert b3787eec77 Bug 1603825 - Suppress the VR permission UI when no VR runtimes are detected r=daoshengmu,bzbarsky
This patch suppresses VR device access permission prompts for users that do not have any VR runtimes installed.

We could not depend on the existing VR device enumeration functions to suppress the permission prompts, as the
act of enumerating VR devices will result in some hardware physically powering on and software starting up (and staying running)
in the background.

This patch includes logic to spawn the VR process with an additional flag indicating that it should attempt only to detect the
runtimes, without proceeding to enumerate and activate hardware and software.

VRManager now includes an enum to more clearly organize it's state machine model, which now must ensure that the runtime detection
happens on-demand when the VR session support capabilities are first determined.

There is a new pref to disable the suppression of permission prompts for use within permission UI tests on machines without VR runtimes.
Renamed some variables and added comments to make code in nsGlobalWindowInner and Navigator clearer and better represent the updated logic -- to allow the separate detection of VR runtimes and VR session activation. Both the runtime detection and VR
session activity uses VREventObserver to send events to nsGlobalWindowInner.

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

--HG--
extra : moz-landing-system : lando
2020-01-03 22:47:26 +00:00

58 lines
1.9 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_VREventObserver_h
#define mozilla_dom_VREventObserver_h
#include "mozilla/dom/VRDisplayEventBinding.h"
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
#include "VRManagerChild.h"
class nsGlobalWindowInner;
namespace mozilla {
namespace dom {
class VREventObserver final : public gfx::VRManagerEventObserver {
public:
NS_INLINE_DECL_REFCOUNTING(VREventObserver, override)
explicit VREventObserver(nsGlobalWindowInner* aGlobalWindow);
void NotifyAfterLoad();
void NotifyVRDisplayMounted(uint32_t aDisplayID) override;
void NotifyVRDisplayUnmounted(uint32_t aDisplayID) override;
void NotifyVRDisplayNavigation(uint32_t aDisplayID);
void NotifyVRDisplayRequested(uint32_t aDisplayID);
void NotifyVRDisplayConnect(uint32_t aDisplayID) override;
void NotifyVRDisplayDisconnect(uint32_t aDisplayID) override;
void NotifyVRDisplayPresentChange(uint32_t aDisplayID) override;
void NotifyPresentationGenerationChanged(uint32_t aDisplayID) override;
void NotifyEnumerationCompleted() override;
void NotifyDetectRuntimesCompleted() override;
void DisconnectFromOwner();
void UpdateSpentTimeIn2DTelemetry(bool aUpdate);
void StartActivity();
void StopActivity();
bool GetStopActivityStatus() const override;
private:
~VREventObserver();
RefPtr<nsGlobalWindowInner> mWindow;
// For WebVR telemetry for tracking users who view content
// in the 2D view.
TimeStamp mSpendTimeIn2DView;
bool mIs2DView;
bool mHasReset;
bool mStopActivity;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_VREventObserver_h