Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Update to the latest GV version (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Oct 23, 2018
1 parent d91e456 commit 6bbf7ab
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;

Expand Down Expand Up @@ -836,31 +839,28 @@ public void onCanGoForward(GeckoSession aSession, boolean aCanGoForward) {
}
}

@Nullable
public GeckoResult<Boolean> onLoadRequest(@NonNull GeckoSession aSession,
@NonNull String aUri,
@TargetWindow int target,
@LoadRequestFlags int flags) {

final GeckoResult<Boolean> result = new GeckoResult<>();
if (aUri.equalsIgnoreCase(PRIVATE_BROWSING_URI)) {
@Override
public @Nullable GeckoResult<AllowOrDeny> onLoadRequest(@NonNull GeckoSession aSession, @NonNull LoadRequest aRequest) {
final GeckoResult<AllowOrDeny> result = new GeckoResult<>();
if (PRIVATE_BROWSING_URI.equalsIgnoreCase(aRequest.uri)) {
switchPrivateMode();
result.complete(true);
result.complete(AllowOrDeny.ALLOW);

} else {
final ValueHolder<Integer> count = new ValueHolder(new Integer(0));
final ValueHolder<Boolean> listenersResult = new ValueHolder(new Boolean(false));
AtomicInteger count = new AtomicInteger(0);
AtomicBoolean allowed = new AtomicBoolean(false);
for (GeckoSession.NavigationDelegate listener: mNavigationListeners) {
GeckoResult<Boolean> listenerResult = listener.onLoadRequest(aSession, aUri, target, flags);
listenerResult.then(new GeckoResult.OnValueListener<Boolean, Object>() {
GeckoResult<AllowOrDeny> listenerResult = listener.onLoadRequest(aSession, aRequest);
listenerResult.then(new GeckoResult.OnValueListener<AllowOrDeny, Object>() {
@Nullable
@Override
public GeckoResult<Object> onValue(@Nullable Boolean value) {
listenersResult.setValue(listenersResult.getValue().booleanValue() | value);
if (count.getValue() == mNavigationListeners.size() - 1) {
result.complete(listenersResult.getValue());
public GeckoResult<Object> 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;
}
Expand Down Expand Up @@ -1183,7 +1183,7 @@ public void onFilePrompt(GeckoSession session, String title, int type, String[]
}

@Override
public GeckoResult<Boolean> onPopupRequest(final GeckoSession session, final String targetUri) {
return GeckoResult.fromValue(false);
public GeckoResult<AllowOrDeny> onPopupRequest(final GeckoSession session, final String targetUri) {
return GeckoResult.fromValue(AllowOrDeny.DENY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -389,7 +391,7 @@ public void onFilePrompt(GeckoSession session, String title, int type, String[]
}

@Override
public GeckoResult<Boolean> onPopupRequest(final GeckoSession session, final String targetUri) {
return GeckoResult.fromValue(true);
public GeckoResult<AllowOrDeny> onPopupRequest(final GeckoSession session, final String targetUri) {
return GeckoResult.fromValue(AllowOrDeny.ALLOW);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -444,42 +446,38 @@ public void onCanGoForward(GeckoSession aSession, boolean canGoForward) {
}

@Override
public GeckoResult<Boolean> onLoadRequest(GeckoSession aSession, final String aUri, int target, int flags) {
public @Nullable GeckoResult<AllowOrDeny> onLoadRequest(GeckoSession aSession, @NonNull LoadRequest aRequest) {
if (mURLBar != null) {
Log.d(LOGTAG, "Got onLoadUri");
mURLBar.setURL(aUri);
mURLBar.setURL(aRequest.uri);
}

final GeckoResult<Boolean> 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<AllowOrDeny> 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;
Expand Down
38 changes: 21 additions & 17 deletions app/src/main/cpp/moz_external_vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -123,51 +125,51 @@ 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
* are capable of 6DoF tracking but for which requestPresent is not meaningful.
* 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
* other content on the device, this should be un-set. When
* 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
Expand Down Expand Up @@ -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').
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6bbf7ab

Please sign in to comment.