Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
index 5095591ba779b8a8d11fd83c476028c02176f23f..670c4013f8ec4132eb7b11f0ef26f6ee71ed6cec 100644 |
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
@@ -5,6 +5,7 @@ |
#include "modules/vr/VRDisplay.h" |
#include "core/dom/DOMException.h" |
+#include "core/dom/DocumentUserGestureToken.h" |
#include "core/dom/FrameRequestCallback.h" |
#include "core/dom/Fullscreen.h" |
#include "core/dom/ScriptedAnimationController.h" |
@@ -335,18 +336,6 @@ ScriptPromise VRDisplay::requestPresent(ScriptState* scriptState, |
return promise; |
} |
- if (!m_capabilities->hasExternalDisplay()) { |
- // TODO: Need a proper VR compositor, but for the moment on mobile |
- // we'll just make the canvas fullscreen so that VrShell can pick it |
- // up through the standard (high latency) compositing path. |
- Fullscreen::requestFullscreen(*m_layer.source(), |
- Fullscreen::UnprefixedRequest); |
- |
- // Check to see if the canvas is still the current fullscreen |
- // element once per second. |
- m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); |
- } |
- |
if (firstPresent) { |
bool secureContext = scriptState->getExecutionContext()->isSecureContext(); |
if (!m_display) { |
@@ -409,6 +398,8 @@ ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState) { |
} |
void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) { |
+ Document* doc = m_navigatorVR->document(); |
+ std::unique_ptr<UserGestureIndicator> gestureIndicator; |
if (m_capabilities->hasExternalDisplay()) { |
forceExitPresent(); |
DOMException* exception = DOMException::create( |
@@ -418,9 +409,25 @@ void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) { |
ReportPresentationResult( |
PresentationResult::PresentationNotSupportedByDisplay); |
return; |
+ } else { |
+ // TODO: Need a proper VR compositor, but for the moment on mobile |
+ // we'll just make the canvas fullscreen so that VrShell can pick it |
+ // up through the standard (high latency) compositing path. |
+ if (doc) { |
+ // Since the callback for requestPresent is asynchronous, we've lost our |
+ // UserGestureToken, and need to create a new one to enter fullscreen. |
+ gestureIndicator = |
+ wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( |
+ doc, UserGestureToken::Status::PossiblyExistingGesture))); |
+ } |
+ Fullscreen::requestFullscreen(*m_layer.source(), |
+ Fullscreen::UnprefixedRequest); |
+ |
+ // Check to see if the canvas is still the current fullscreen |
+ // element once per second. |
+ m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); |
} |
- Document* doc = m_navigatorVR->document(); |
if (doc) { |
Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess", |
WebURL(doc->url())); |