From 6bbf7ab3ac24ef51f81ce1679acc263e98970426 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 23 Oct 2018 23:51:44 +0200 Subject: [PATCH] Update to the latest GV version (#658) --- .../vrbrowser/browser/SessionStore.java | 40 +++++++------- .../vrbrowser/ui/widgets/BrowserWidget.java | 6 ++- .../ui/widgets/NavigationBarWidget.java | 52 +++++++++---------- app/src/main/cpp/moz_external_vr.h | 38 ++++++++------ build.gradle | 2 +- 5 files changed, 71 insertions(+), 67 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SessionStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SessionStore.java index 7b70563be..992bc6314 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SessionStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SessionStore.java @@ -17,6 +17,7 @@ import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoProfile; +import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoRuntimeSettings; @@ -42,6 +43,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import static org.mozilla.vrbrowser.utils.ServoUtils.*; @@ -836,31 +839,28 @@ public void onCanGoForward(GeckoSession aSession, boolean aCanGoForward) { } } - @Nullable - public GeckoResult onLoadRequest(@NonNull GeckoSession aSession, - @NonNull String aUri, - @TargetWindow int target, - @LoadRequestFlags int flags) { - - final GeckoResult result = new GeckoResult<>(); - if (aUri.equalsIgnoreCase(PRIVATE_BROWSING_URI)) { + @Override + public @Nullable GeckoResult onLoadRequest(@NonNull GeckoSession aSession, @NonNull LoadRequest aRequest) { + final GeckoResult result = new GeckoResult<>(); + if (PRIVATE_BROWSING_URI.equalsIgnoreCase(aRequest.uri)) { switchPrivateMode(); - result.complete(true); + result.complete(AllowOrDeny.ALLOW); } else { - final ValueHolder count = new ValueHolder(new Integer(0)); - final ValueHolder listenersResult = new ValueHolder(new Boolean(false)); + AtomicInteger count = new AtomicInteger(0); + AtomicBoolean allowed = new AtomicBoolean(false); for (GeckoSession.NavigationDelegate listener: mNavigationListeners) { - GeckoResult listenerResult = listener.onLoadRequest(aSession, aUri, target, flags); - listenerResult.then(new GeckoResult.OnValueListener() { + GeckoResult listenerResult = listener.onLoadRequest(aSession, aRequest); + listenerResult.then(new GeckoResult.OnValueListener() { @Nullable @Override - public GeckoResult onValue(@Nullable Boolean value) { - listenersResult.setValue(listenersResult.getValue().booleanValue() | value); - if (count.getValue() == mNavigationListeners.size() - 1) { - result.complete(listenersResult.getValue()); + public GeckoResult onValue(@Nullable AllowOrDeny value) { + if (AllowOrDeny.ALLOW.equals(value)) { + allowed.set(true); + } + if (count.getAndIncrement() == mNavigationListeners.size() - 1) { + result.complete(allowed.get() ? AllowOrDeny.ALLOW : AllowOrDeny.DENY); } - count.setValue(count.getValue().intValue() + 1); return null; } @@ -1183,7 +1183,7 @@ public void onFilePrompt(GeckoSession session, String title, int type, String[] } @Override - public GeckoResult onPopupRequest(final GeckoSession session, final String targetUri) { - return GeckoResult.fromValue(false); + public GeckoResult onPopupRequest(final GeckoSession session, final String targetUri) { + return GeckoResult.fromValue(AllowOrDeny.DENY); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java index b4b896324..9cbc48306 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java @@ -15,6 +15,8 @@ import android.view.View; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; + +import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.GeckoDisplay; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; @@ -389,7 +391,7 @@ public void onFilePrompt(GeckoSession session, String title, int type, String[] } @Override - public GeckoResult onPopupRequest(final GeckoSession session, final String targetUri) { - return GeckoResult.fromValue(true); + public GeckoResult onPopupRequest(final GeckoSession session, final String targetUri) { + return GeckoResult.fromValue(AllowOrDeny.ALLOW); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index 90480466d..262d87ed9 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -10,12 +10,14 @@ import android.net.Uri; import android.preference.PreferenceManager; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSessionSettings; @@ -444,42 +446,38 @@ public void onCanGoForward(GeckoSession aSession, boolean canGoForward) { } @Override - public GeckoResult onLoadRequest(GeckoSession aSession, final String aUri, int target, int flags) { + public @Nullable GeckoResult onLoadRequest(GeckoSession aSession, @NonNull LoadRequest aRequest) { if (mURLBar != null) { Log.d(LOGTAG, "Got onLoadUri"); - mURLBar.setURL(aUri); + mURLBar.setURL(aRequest.uri); } - final GeckoResult result = new GeckoResult<>(); - if (aUri != null) { - Uri uri = Uri.parse(aUri); - if (uri.getScheme().equals("file")) { - if (!mWidgetManager.isPermissionGranted(android.Manifest.permission.READ_EXTERNAL_STORAGE)) { - mWidgetManager.requestPermission( - aUri, - android.Manifest.permission.READ_EXTERNAL_STORAGE, - new GeckoSession.PermissionDelegate.Callback() { - @Override - public void grant() { - result.complete(false); - } - - @Override - public void reject() { - result.complete(false); - } - }); - - } else { - result.complete(false); - } + final GeckoResult result = new GeckoResult<>(); + + Uri uri = Uri.parse(aRequest.uri); + if (uri.getScheme().equals("file")) { + if (!mWidgetManager.isPermissionGranted(android.Manifest.permission.READ_EXTERNAL_STORAGE)) { + mWidgetManager.requestPermission( + aRequest.uri, + android.Manifest.permission.READ_EXTERNAL_STORAGE, + new GeckoSession.PermissionDelegate.Callback() { + @Override + public void grant() { + result.complete(AllowOrDeny.ALLOW); + } + + @Override + public void reject() { + result.complete(AllowOrDeny.DENY); + } + }); } else { - result.complete(false); + result.complete(AllowOrDeny.DENY); } } else { - result.complete(false); + result.complete(AllowOrDeny.ALLOW); } return result; diff --git a/app/src/main/cpp/moz_external_vr.h b/app/src/main/cpp/moz_external_vr.h index 35d8bb987..ca0e69622 100644 --- a/app/src/main/cpp/moz_external_vr.h +++ b/app/src/main/cpp/moz_external_vr.h @@ -35,7 +35,7 @@ namespace dom { #endif // MOZILLA_INTERNAL_API namespace gfx { -static const int32_t kVRExternalVersion = 4; +static const int32_t kVRExternalVersion = 5; // We assign VR presentations to groups with a bitmask. // Currently, we will only display either content or chrome. @@ -58,6 +58,8 @@ static const int kVRHapticsMaxCount = 32; #if defined(__ANDROID__) typedef uint64_t VRLayerTextureHandle; +#elif defined(XP_MACOSX) +typedef uint32_t VRLayerTextureHandle; #else typedef void* VRLayerTextureHandle; #endif @@ -95,25 +97,25 @@ enum class ControllerCapabilityFlags : uint16_t { /** * Cap_Position is set if the Gamepad is capable of tracking its position. */ - Cap_Position = 1 << 1, + Cap_Position = 1 << 1, /** * Cap_Orientation is set if the Gamepad is capable of tracking its orientation. */ - Cap_Orientation = 1 << 2, + Cap_Orientation = 1 << 2, /** * Cap_AngularAcceleration is set if the Gamepad is capable of tracking its * angular acceleration. */ - Cap_AngularAcceleration = 1 << 3, + Cap_AngularAcceleration = 1 << 3, /** * Cap_LinearAcceleration is set if the Gamepad is capable of tracking its * linear acceleration. */ - Cap_LinearAcceleration = 1 << 4, + Cap_LinearAcceleration = 1 << 4, /** * Cap_All used for validity checking during IPC serialization */ - Cap_All = (1 << 5) - 1 + Cap_All = (1 << 5) - 1 }; #endif // ifndef MOZILLA_INTERNAL_API @@ -123,11 +125,11 @@ enum class VRDisplayCapabilityFlags : uint16_t { /** * Cap_Position is set if the VRDisplay is capable of tracking its position. */ - Cap_Position = 1 << 1, + Cap_Position = 1 << 1, /** * Cap_Orientation is set if the VRDisplay is capable of tracking its orientation. */ - Cap_Orientation = 1 << 2, + Cap_Orientation = 1 << 2, /** * Cap_Present is set if the VRDisplay is capable of presenting content to an * HMD or similar device. Can be used to indicate "magic window" devices that @@ -135,7 +137,7 @@ enum class VRDisplayCapabilityFlags : uint16_t { * If false then calls to requestPresent should always fail, and * getEyeParameters should return null. */ - Cap_Present = 1 << 3, + Cap_Present = 1 << 3, /** * Cap_External is set if the VRDisplay is separate from the device's * primary display. If presenting VR content will obscure @@ -143,31 +145,31 @@ enum class VRDisplayCapabilityFlags : uint16_t { * un-set, the application should not attempt to mirror VR content * or update non-VR UI because that content will not be visible. */ - Cap_External = 1 << 4, + Cap_External = 1 << 4, /** * Cap_AngularAcceleration is set if the VRDisplay is capable of tracking its * angular acceleration. */ - Cap_AngularAcceleration = 1 << 5, + Cap_AngularAcceleration = 1 << 5, /** * Cap_LinearAcceleration is set if the VRDisplay is capable of tracking its * linear acceleration. */ - Cap_LinearAcceleration = 1 << 6, + Cap_LinearAcceleration = 1 << 6, /** * Cap_StageParameters is set if the VRDisplay is capable of room scale VR * and can report the StageParameters to describe the space. */ - Cap_StageParameters = 1 << 7, + Cap_StageParameters = 1 << 7, /** * Cap_MountDetection is set if the VRDisplay is capable of sensing when the * user is wearing the device. */ - Cap_MountDetection = 1 << 8, + Cap_MountDetection = 1 << 8, /** * Cap_All used for validity checking during IPC serialization */ - Cap_All = (1 << 9) - 1 + Cap_All = (1 << 9) - 1 }; #ifdef MOZILLA_INTERNAL_API @@ -267,9 +269,11 @@ struct VRDisplayState NumEyes }; -#if defined(__ANDROID__) + // When true, indicates that the VR service has shut down bool shutdown; -#endif // defined(__ANDROID__) + // Minimum number of milliseconds to wait before attempting + // to start the VR service again + uint32_t mMinRestartInterval; char mDisplayName[kVRDisplayNameMaxLen]; // eight byte character code identifier // LSB first, so "ABCDEFGH" -> ('H'<<56) + ('G'<<48) + ('F'<<40) + ('E'<<32) + ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). diff --git a/build.gradle b/build.gradle index 1e263e5d2..4b69537a1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { ext.geckoNightly = [ // GeckoView versions can be found here: // https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/ - version: '64.0.20181004100221' + version: '65.0.20181023100123' ] repositories {