diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java index d0796eee7..712455b33 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java @@ -286,7 +286,7 @@ public void setHistoryDelegate(GeckoSession.HistoryDelegate aDelegate) { } public void addNavigationListener(GeckoSession.NavigationDelegate aListener) { - mNavigationListeners.add(aListener); + mNavigationListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -295,7 +295,7 @@ public void removeNavigationListener(GeckoSession.NavigationDelegate aListener) } public void addProgressListener(GeckoSession.ProgressDelegate aListener) { - mProgressListeners.add(aListener); + mProgressListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -304,7 +304,7 @@ public void removeProgressListener(GeckoSession.ProgressDelegate aListener) { } public void addContentListener(GeckoSession.ContentDelegate aListener) { - mContentListeners.add(aListener); + mContentListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -313,7 +313,7 @@ public void removeContentListener(GeckoSession.ContentDelegate aListener) { } public void addSessionChangeListener(SessionChangeListener aListener) { - mSessionChangeListeners.add(aListener); + mSessionChangeListeners.addIfAbsent(aListener); } public void removeSessionChangeListener(SessionChangeListener aListener) { @@ -321,7 +321,7 @@ public void removeSessionChangeListener(SessionChangeListener aListener) { } public void addTextInputListener(GeckoSession.TextInputDelegate aListener) { - mTextInputListeners.add(aListener); + mTextInputListeners.addIfAbsent(aListener); } public void removeTextInputListener(GeckoSession.TextInputDelegate aListener) { @@ -329,7 +329,7 @@ public void removeTextInputListener(GeckoSession.TextInputDelegate aListener) { } public void addVideoAvailabilityListener(VideoAvailabilityListener aListener) { - mVideoAvailabilityListeners.add(aListener); + mVideoAvailabilityListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -338,7 +338,7 @@ public void removeVideoAvailabilityListener(VideoAvailabilityListener aListener) } public void addSelectionActionListener(GeckoSession.SelectionActionDelegate aListener) { - mSelectionActionListeners.add(aListener); + mSelectionActionListeners.addIfAbsent(aListener); } public void removeSelectionActionListener(GeckoSession.ContentDelegate aListener) { @@ -346,7 +346,7 @@ public void removeSelectionActionListener(GeckoSession.ContentDelegate aListener } public void addBitmapChangedListener(BitmapChangedListener aListener) { - mBitmapChangedListeners.add(aListener); + mBitmapChangedListeners.addIfAbsent(aListener); } public void removeBitmapChangedListener(BitmapChangedListener aListener) { @@ -354,7 +354,7 @@ public void removeBitmapChangedListener(BitmapChangedListener aListener) { } public void addWebXRStateChangedListener(WebXRStateChangedListener aListener) { - mWebXRStateListeners.add(aListener); + mWebXRStateListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -363,7 +363,7 @@ public void removeWebXRStateChangedListener(WebXRStateChangedListener aListener) } public void addPopUpStateChangedListener(PopUpStateChangedListener aListener) { - mPopUpStateStateListeners.add(aListener); + mPopUpStateStateListeners.addIfAbsent(aListener); dumpState(aListener); } @@ -372,7 +372,7 @@ public void removePopUpStateChangedListener(PopUpStateChangedListener aListener) } public void addDrmStateChangedListener(DrmStateChangedListener aListener) { - mDrmStateStateListeners.add(aListener); + mDrmStateStateListeners.addIfAbsent(aListener); dumpState(aListener); } 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 31866cb51..4b933ec53 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 @@ -1158,12 +1158,17 @@ public void onCurrentSessionChange(GeckoSession aOldSession, GeckoSession aSessi @Override public void onStackSession(Session aSession) { + if (aSession == mSession) { + Log.e(LOGTAG, "Attempting to stack same session."); + return; + } // e.g. tab opened via window.open() aSession.updateLastUse(); Session current = mSession; setupListeners(aSession); setSession(aSession); SessionStore.get().setActiveSession(aSession); + aSession.setActive(true); current.captureBackgroundBitmap(getWindowWidth(), getWindowHeight()).thenAccept(aVoid -> current.setActive(false)); mWidgetManager.getWindows().showTabAddedNotification();