diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 45c18e94d..7f9f2b4e4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -431,7 +431,7 @@ void loadFromIntent(final Intent intent) { activeStore.loadUri(uri.toString()); } else { - mWindows.getFocusedWindow().loadHome(); + mWindows.getFocusedWindow().loadHomeIfNotRestored(); } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java index 35944eb03..896ebe37b 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java @@ -54,6 +54,9 @@ public boolean isServoEnabled() { return isServoEnabled; } + public void setServoEnabled(boolean enabled) { + isServoEnabled = enabled; + } public static class Builder { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java index bd04d659d..d73e2d071 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java @@ -268,21 +268,19 @@ public void restore(SessionStore store, int currentSessionId) { mRegion = store.mRegion; mUsePrivateMode = store.mUsePrivateMode; - SessionSettings settings = new SessionSettings.Builder() - .withDefaultSettings(mContext) - .build(); - - GeckoSessionSettings geckoSettings = new GeckoSessionSettings.Builder() - .useMultiprocess(settings.isMultiprocessEnabled()) - .usePrivateMode(mUsePrivateMode) - .useTrackingProtection(settings.isTrackingProtectionEnabled()) - .build(); - HashMap oldNewSessionId = new HashMap<>(); for (Map.Entry entry : store.mSessions.entrySet()) { SessionState state = entry.getValue(); - if (settings.isServoEnabled()) { + GeckoSessionSettings geckoSettings = new GeckoSessionSettings.Builder() + .useMultiprocess(state.mSettings.isMultiprocessEnabled()) + .usePrivateMode(mUsePrivateMode) + .userAgentMode(state.mSettings.getUserAgentMode()) + .suspendMediaWhenInactive(state.mSettings.isSuspendMediaWhenInactiveEnabled()) + .useTrackingProtection(state.mSettings.isTrackingProtectionEnabled()) + .build(); + + if (state.mSettings.isServoEnabled()) { if (isServoAvailable()) { state.mSession = createServoSession(mContext); } else { @@ -298,8 +296,6 @@ public void restore(SessionStore store, int currentSessionId) { int newSessionId = state.mSession.hashCode(); oldNewSessionId.put(entry.getKey(), newSessionId); - state.mSession.getSettings().setSuspendMediaWhenInactive(settings.isSuspendMediaWhenInactiveEnabled()); - state.mSession.getSettings().setUserAgentMode(settings.getUserAgentMode()); state.mSession.setNavigationDelegate(this); state.mSession.setProgressDelegate(this); state.mSession.setPromptDelegate(this); @@ -763,6 +759,10 @@ public boolean isPrivateMode() { // Session Settings protected void setServo(final boolean enabled) { + SessionState state = mSessions.get(mCurrentSession.hashCode()); + if (state != null) { + state.mSettings.setServoEnabled(enabled); + } if (!enabled && mCurrentSession != null && isInstanceOfServoSession(mCurrentSession)) { String uri = getCurrentUri(); int id = createSession(); @@ -777,8 +777,12 @@ public int getUaMode() { public void setUaMode(int mode) { if (mCurrentSession != null) { - mCurrentSession.getSettings().setUserAgentMode(mode); - mCurrentSession.reload(); + SessionState state = mSessions.get(mCurrentSession.hashCode()); + if (state != null && state.mSettings.getUserAgentMode() != mode) { + state.mSettings.setUserAgentMode(mode); + mCurrentSession.getSettings().setUserAgentMode(mode); + mCurrentSession.reload(); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 20ce38769..178b12e8d 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -155,7 +155,7 @@ private void initialize(Context aContext) { mUAModeButton = findViewById(R.id.uaModeButton); mUAModeButton.setTag(R.string.view_id_tag, R.id.uaModeButton); mUAModeButton.setOnClickListener(mUAModeListener); - setUAMode(SettingsStore.getInstance(aContext).getUaMode()); + setUAMode(mSessionStore.getUaMode()); mURLLeftContainer = findViewById(R.id.urlLeftContainer); mInsecureIcon = findViewById(R.id.insecureIcon); @@ -183,6 +183,7 @@ private void initialize(Context aContext) { public void setSessionStore(SessionStore sessionStore) { mSessionStore = sessionStore; + setUAMode(mSessionStore.getUaMode()); } public void onPause() { @@ -501,13 +502,13 @@ public void setClickable(boolean clickable) { view.requestFocusFromTouch(); int uaMode = mSessionStore.getUaMode(); - if (uaMode == GeckoSessionSettings.USER_AGENT_MODE_VR) { - setUAMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); - mSessionStore.setUaMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); - - }else { + if (uaMode == GeckoSessionSettings.USER_AGENT_MODE_DESKTOP) { setUAMode(GeckoSessionSettings.USER_AGENT_MODE_VR); mSessionStore.setUaMode(GeckoSessionSettings.USER_AGENT_MODE_VR); + + }else { + setUAMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); + mSessionStore.setUaMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); } TelemetryWrapper.voiceInputEvent(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 0449a0ebb..aac63a6ff 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -84,6 +84,7 @@ public class WindowWidget extends UIWidget implements SessionChangeListener, private ArrayList mBookmarksListeners; private Windows.WindowPlacement mWindowPlacement = Windows.WindowPlacement.FRONT; private float mMaxWindowScale = 3; + private boolean mIsRestored = false; public WindowWidget(Context aContext, int windowId, boolean privateMode) { super(aContext); @@ -178,6 +179,11 @@ public void close() { SessionManager.get().destroySessionStore(mWindowId); } + public void loadHomeIfNotRestored() { + if (!mIsRestored) + loadHome(); + } + public void loadHome() { if (mSessionStore.isPrivateMode()) { InternalPages.PageResources pageResources = InternalPages.PageResources.create(R.raw.private_mode, R.raw.private_style); @@ -187,6 +193,10 @@ public void loadHome() { } } + protected void setRestored(boolean restored) { + mIsRestored = restored; + } + private void setView(View view) { pauseCompositor(); mView = view; diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index ffe6a3307..2934cacb4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -209,6 +209,7 @@ private WindowWidget addWindow(WindowState aState) { newWindow.getPlacement().width = aState.textureWidth; newWindow.getPlacement().height = aState.textureHeight; newWindow.getPlacement().worldWidth = aState.worldWidth; + newWindow.setRestored(true); placeWindow(newWindow, aState.placement); mWidgetManager.addWidget(newWindow);