X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FPinnedMismatchDialog.java;h=72fc85aeeee2752e1968bbf638166449f9b81e27;hp=fbf1f90fb143385b97842f671b79014229a7fc7c;hb=1a9be53186a8a4f16017c6dcc1f2f1e85289358e;hpb=5e95167477f5b2dc9bd4b99261038b6fe60beab3 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java index fbf1f90f..72fc85ae 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java @@ -60,7 +60,6 @@ import androidx.viewpager.widget.PagerAdapter; public class PinnedMismatchDialog extends DialogFragment { // Declare the class variables. - private PinnedMismatchListener pinnedMismatchListener; private NestedScrollWebView nestedScrollWebView; private String currentSslIssuedToCName; private String currentSslIssuedToOName; @@ -71,22 +70,6 @@ public class PinnedMismatchDialog extends DialogFragment { private Date currentSslStartDate; private Date currentSslEndDate; - // The public interface is used to send information back to the parent activity. - public interface PinnedMismatchListener { - void onPinnedMismatchBack(); - - void onPinnedMismatchProceed(); - } - - // Check to make sure that the parent activity implements the listener. - public void onAttach(Context context) { - // Run the default commands. - super.onAttach(context); - - // Get a handle for `PinnedSslCertificateMismatchListener` from the launching context. - pinnedMismatchListener = (PinnedMismatchListener) context; - } - public static PinnedMismatchDialog displayDialog(long webViewFragmentId) { // Create an arguments bundle. Bundle argumentsBundle = new Bundle(); @@ -225,16 +208,27 @@ public class PinnedMismatchDialog extends DialogFragment { } }); - // Setup the negative button. + // Setup the back button. dialogBuilder.setNegativeButton(R.string.back, (DialogInterface dialog, int which) -> { - // Call the `onSslMismatchBack` public interface to send the `WebView` back one page. - pinnedMismatchListener.onPinnedMismatchBack(); + if (nestedScrollWebView.canGoBack()) { // There is a back page in the history. + // Reset the current domain name so that navigation works if third-party requests are blocked. + nestedScrollWebView.resetCurrentDomainName(); + + // Set navigating history so that the domain settings are applied when the new URL is loaded. + nestedScrollWebView.setNavigatingHistory(true); + + // Go back. + nestedScrollWebView.goBack(); + } else { // There are no pages to go back to. + // Load a blank page + nestedScrollWebView.loadUrl(""); + } }); - // Setup the positive button. + // Setup the proceed button. dialogBuilder.setPositiveButton(R.string.proceed, (DialogInterface dialog, int which) -> { - // Call the `onSslMismatchProceed` public interface. - pinnedMismatchListener.onPinnedMismatchProceed(); + // Do not check the pinned information for this domain again until the domain changes. + nestedScrollWebView.setIgnorePinnedDomainInformation(true); }); // Set the title.