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

Commit

Permalink
Tabs implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Oct 11, 2019
1 parent 58b59be commit 61d0aed
Show file tree
Hide file tree
Showing 46 changed files with 2,711 additions and 1,772 deletions.
40 changes: 17 additions & 23 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.PermissionDelegate;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.browser.engine.Session;
import org.mozilla.vrbrowser.browser.engine.SessionStore;
import org.mozilla.vrbrowser.browser.engine.SessionStack;
import org.mozilla.vrbrowser.crashreporting.CrashReporterService;
import org.mozilla.vrbrowser.crashreporting.GlobalExceptionHandler;
import org.mozilla.vrbrowser.geolocation.GeolocationWrapper;
Expand Down Expand Up @@ -449,7 +449,7 @@ void loadFromIntent(final Intent intent) {
uri = Uri.parse(intent.getExtras().getString("url"));
}

SessionStack activeStore = SessionStore.get().getActiveStore();
Session activeStore = SessionStore.get().getActiveSession();

Bundle extras = intent.getExtras();
if (extras != null && extras.containsKey("homepage")) {
Expand All @@ -466,15 +466,9 @@ void loadFromIntent(final Intent intent) {
}

if (activeStore != null) {
if (activeStore.getCurrentSession() == null) {
String url = (uri != null ? uri.toString() : null);
activeStore.newSessionWithUrl(url);
Log.d(LOGTAG, "Creating session and loading URI from intent: " + url);

} else if (uri != null) {
if (uri != null) {
Log.d(LOGTAG, "Loading URI from intent: " + uri.toString());
activeStore.loadUri(uri.toString());

} else {
mWindows.getFocusedWindow().loadHomeIfNotRestored();
}
Expand Down Expand Up @@ -676,8 +670,8 @@ void dispatchCreateWidget(final int aHandle, final SurfaceTexture aTexture, fina
Log.d(LOGTAG, "Widget: " + aHandle + " (" + aWidth + "x" + aHeight + ") received a null surface texture.");
} else {
Runnable aFirstDrawCallback = () -> {
if (!widget.getFirstDraw()) {
widget.setFirstDraw(true);
if (!widget.isComposited()) {
widget.setComposited(true);
updateWidget(widget);
}
};
Expand Down Expand Up @@ -705,8 +699,8 @@ void dispatchCreateWidgetLayer(final int aHandle, final Surface aSurface, final
if (aNativeCallback != 0) {
queueRunnable(() -> runCallbackNative(aNativeCallback));
}
if (aSurface != null && !widget.getFirstDraw()) {
widget.setFirstDraw(true);
if (aSurface != null && !widget.isComposited()) {
widget.setComposited(true);
updateWidget(widget);
}
};
Expand Down Expand Up @@ -773,12 +767,12 @@ void handleGesture(final int aType) {
boolean consumed = false;
if ((aType == GestureSwipeLeft) && (mLastGesture == GestureSwipeLeft)) {
Log.d(LOGTAG, "Go back!");
SessionStore.get().getActiveStore().goBack();
SessionStore.get().getActiveSession().goBack();

consumed = true;
} else if ((aType == GestureSwipeRight) && (mLastGesture == GestureSwipeRight)) {
Log.d(LOGTAG, "Go forward!");
SessionStore.get().getActiveStore().goForward();
SessionStore.get().getActiveSession().goForward();
consumed = true;
}
if (mLastRunnable != null) {
Expand Down Expand Up @@ -998,18 +992,18 @@ private void handlePoorPerformance() {
if (window == null) {
return;
}
final String originalUrl = window.getSessionStack().getCurrentUri();
final String originalUrl = window.getSession().getCurrentUri();
if (mPoorPerformanceWhiteList.contains(originalUrl)) {
return;
}
window.getSessionStack().loadHomePage();
window.getSession().loadHomePage();
final String[] buttons = {getString(R.string.ok_button), getString(R.string.performance_unblock_page)};
window.showButtonPrompt(getString(R.string.performance_title), getString(R.string.performance_message), buttons, new ConfirmPromptWidget.ConfirmPromptDelegate() {
@Override
public void confirm(int index) {
if (index == GeckoSession.PromptDelegate.ButtonPrompt.Type.NEGATIVE) {
mPoorPerformanceWhiteList.add(originalUrl);
window.getSessionStack().loadUri(originalUrl);
window.getSession().loadUri(originalUrl);
}
}

Expand Down Expand Up @@ -1129,7 +1123,7 @@ public void updateWidget(final Widget aWidget) {
public void removeWidget(final Widget aWidget) {
mWidgets.remove(aWidget.getHandle());
mWidgetContainer.removeView((View) aWidget);
aWidget.setFirstDraw(false);
aWidget.setComposited(false);
queueRunnable(() -> removeWidgetNative(aWidget.getHandle()));
if (aWidget == mActiveDialog) {
mActiveDialog = null;
Expand Down Expand Up @@ -1320,11 +1314,11 @@ public boolean isPermissionGranted(@NonNull String permission) {

@Override
public void requestPermission(String uri, @NonNull String permission, GeckoSession.PermissionDelegate.Callback aCallback) {
SessionStack activeStore = SessionStore.get().getActiveStore();
Session session = SessionStore.get().getActiveSession();
if (uri != null && !uri.isEmpty()) {
mPermissionDelegate.onAppPermissionRequest(activeStore.getCurrentSession(), uri, permission, aCallback);
mPermissionDelegate.onAppPermissionRequest(session.getGeckoSession(), uri, permission, aCallback);
} else {
mPermissionDelegate.onAndroidPermissionsRequest(activeStore.getCurrentSession(), new String[]{permission}, aCallback);
mPermissionDelegate.onAndroidPermissionsRequest(session.getGeckoSession(), new String[]{permission}, aCallback);
}
}

Expand Down Expand Up @@ -1380,7 +1374,7 @@ public void setCPULevel(int aCPULevel) {
public void openNewWindow(String uri) {
WindowWidget newWindow = mWindows.addWindow();
if (newWindow != null) {
newWindow.getSessionStack().newSessionWithUrl(uri);
newWindow.getSession().loadUri(uri);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.mozilla.geckoview.GeckoSession;

public interface SessionChangeListener {
default void onNewSession(GeckoSession aSession, int aId) {};
default void onRemoveSession(GeckoSession aSession, int aId) {};
default void onCurrentSessionChange(GeckoSession aSession, int aId) {};
default void onNewSession(GeckoSession aSession) {};
default void onRemoveSession(GeckoSession aSession) {};
default void onCurrentSessionChange(GeckoSession aOldSession, GeckoSession aSession) {};
}
Loading

0 comments on commit 61d0aed

Please sign in to comment.