Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class InAppBrowser extends CordovaPlugin {
private String footerColor = "";
private String beforeload = "";
private String[] allowedSchemes;
private InAppBrowserClient currentClient;

/**
* Executes the request and returns PluginResult.
Expand Down Expand Up @@ -262,7 +263,12 @@ else if (action.equals("loadAfterBeforeload")) {
@SuppressLint("NewApi")
@Override
public void run() {
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
currentClient.waitForBeforeload = false;
inAppWebView.setWebViewClient(currentClient);
} else {
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
}
inAppWebView.loadUrl(url);
}
});
Expand Down Expand Up @@ -948,8 +954,8 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
}

});
WebViewClient client = new InAppBrowserClient(thatWebView, edittext, beforeload);
inAppWebView.setWebViewClient(client);
currentClient = new InAppBrowserClient(thatWebView, edittext, beforeload);
inAppWebView.setWebViewClient(currentClient);
WebSettings settings = inAppWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
Expand Down Expand Up @@ -1184,7 +1190,9 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
boolean useBeforeload = false;
String errorMessage = null;

if(beforeload.equals("yes")
if (beforeload.equals("yes") && method == null) {
useBeforeload = true;
}else if(beforeload.equals("yes")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean method can be null?

Copy link
Contributor Author

@nounder nounder Mar 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, For Android 6 and below shouldOverrideUrlLoading(WebView webView, String url) is called which calls shouldOverrideUrlLoading(String url, String method) with null as 2nd argument due to lack of possibility of deducing HTTP method from bare URL.

//TODO handle POST requests then this condition can be removed:
&& !method.equals("POST"))
{
Expand Down