mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
CB-8510 Remove shouldOverrideUrlLoading
from CordovaWebViewEngine.Client
.
It's logic that's pretty webview-specific, so it doesn't make sense to share.
This commit is contained in:
parent
747d2c97cd
commit
a6da46a00e
@ -72,7 +72,6 @@ public interface CordovaWebViewEngine {
|
||||
*/
|
||||
public interface Client {
|
||||
Boolean onDispatchKeyEvent(KeyEvent event);
|
||||
boolean shouldOverrideUrlLoading(String url);
|
||||
void clearLoadTimeoutTimer();
|
||||
void onPageStarted(String newUrl);
|
||||
void onReceivedError(int errorCode, String description, String failingUrl);
|
||||
|
@ -587,37 +587,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(String url) {
|
||||
// Give plugins the chance to handle the url
|
||||
if (pluginManager.shouldAllowNavigation(url)) {
|
||||
// Allow internal navigation
|
||||
return false;
|
||||
} else if (pluginManager.shouldOpenExternalUrl(url)) {
|
||||
// Do nothing other than what the plugins wanted.
|
||||
// If any returned false, then the request was either blocked
|
||||
// completely, or handled out-of-band by the plugin. If they all
|
||||
// returned true, then we should open the URL here.
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setComponent(null);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
|
||||
intent.setSelector(null);
|
||||
}
|
||||
getContext().startActivity(intent);
|
||||
return true;
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
Log.e(TAG, "Error loading url " + url, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
LOG.w(TAG, "Blocked navigation because URL was not whitelisted: " + url);
|
||||
// Block by default
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
// TODO: scrolling is perf-sensitive, so we'd probably be better to no use postMessage
|
||||
|
@ -76,9 +76,21 @@ public class SystemWebViewClient extends WebViewClient {
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
return parentEngine.client.shouldOverrideUrlLoading(url);
|
||||
// Give plugins the chance to handle the url
|
||||
if (parentEngine.pluginManager.onOverrideUrlLoading(url)) {
|
||||
return true;
|
||||
} else if (parentEngine.pluginManager.shouldOpenExternalUrl(url)) {
|
||||
parentEngine.getCordovaWebView().showWebPage(url, true, false, null);
|
||||
return true;
|
||||
} else if (!parentEngine.pluginManager.shouldAllowNavigation(url)) {
|
||||
// This blocks iframe navigations as well.
|
||||
LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On received http auth request.
|
||||
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
|
||||
|
Loading…
Reference in New Issue
Block a user