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

Commit

Permalink
Set prompt delegate when new stacked tab is created (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin authored and MortimerGoro committed Oct 29, 2019
1 parent 2147d0d commit 751a846
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.mozilla.vrbrowser.AppExecutors;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.VRBrowserApplication;
import org.mozilla.vrbrowser.browser.engine.Session;
import org.mozilla.vrbrowser.db.PopUpSite;
import org.mozilla.vrbrowser.ui.viewmodel.PopUpsViewModel;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
Expand All @@ -33,7 +34,7 @@
import java.util.NoSuchElementException;
import java.util.Optional;

public class PromptDelegate implements GeckoSession.PromptDelegate {
public class PromptDelegate implements GeckoSession.PromptDelegate, WindowWidget.WindowListener {

private PromptWidget mPrompt;
private PopUpBlockDialogWidget mPopUpPrompt;
Expand All @@ -57,12 +58,16 @@ public void attachToWindow(@NonNull WindowWidget window) {
detachFromWindow();

mAttachedWindow = window;
mAttachedWindow.addWindowListener(this);
mAttachedWindow.getSession().setPromptDelegate(this);
mViewModel.getAll().observeForever(mObserver);
}

public void detachFromWindow() {
mAttachedWindow = null;
if (mAttachedWindow != null) {
mAttachedWindow.removeWindowListener(this);
mAttachedWindow = null;
}
mViewModel.getAll().removeObserver(mObserver);
}

Expand Down Expand Up @@ -307,4 +312,11 @@ public void onDismiss() {
}
}

// WindowWidget.WindowListener

@Override
public void onSessionChanged(@NonNull Session aOldSession, @NonNull Session aSession) {
aOldSession.setPromptDelegate(null);
aSession.setPromptDelegate(this);
}
}

0 comments on commit 751a846

Please sign in to comment.