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

Commit

Permalink
Clear private browsing tabs when private browsing is cleared. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Nov 5, 2019
1 parent 5cff5e3 commit 882e585
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;


public class SessionStore implements GeckoSession.PermissionDelegate {

Expand Down Expand Up @@ -133,15 +132,29 @@ public Session createSession(SessionState aRestoreState) {
return session;
}

private void shutdownSession(@NonNull Session aSession) {
aSession.setPermissionDelegate(null);
aSession.removeNavigationListener(mServices);
aSession.shutdown();
}

public void destroySession(Session aSession) {
mSessions.remove(aSession);
if (aSession != null) {
aSession.setPermissionDelegate(null);
aSession.removeNavigationListener(mServices);
aSession.shutdown();
shutdownSession(aSession);
}
}

public void destroyPrivateSessions() {
mSessions.removeIf(session -> {
if (!session.isPrivateMode()) {
return false;
}
shutdownSession(session);
return true;
});
}

public @Nullable Session getSession(String aId) {
return mSessions.stream().filter(session -> session.getId().equals(aId)).findFirst().orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ public void closeWindow(@NonNull WindowWidget aWindow) {

boolean empty = getCurrentWindows().isEmpty();
if (empty && isInPrivateMode()) {
// Clear private tabs
SessionStore.get().destroyPrivateSessions();
// Exit private mode if the only window is closed.
exitPrivateMode();
} else if (empty) {
Expand Down

0 comments on commit 882e585

Please sign in to comment.