forked from github/cordova-android
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 {
|
public interface Client {
|
||||||
Boolean onDispatchKeyEvent(KeyEvent event);
|
Boolean onDispatchKeyEvent(KeyEvent event);
|
||||||
boolean shouldOverrideUrlLoading(String url);
|
|
||||||
void clearLoadTimeoutTimer();
|
void clearLoadTimeoutTimer();
|
||||||
void onPageStarted(String newUrl);
|
void onPageStarted(String newUrl);
|
||||||
void onReceivedError(int errorCode, String description, String failingUrl);
|
void onReceivedError(int errorCode, String description, String failingUrl);
|
||||||
|
@ -587,37 +587,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
return null;
|
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
|
@Override
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt) {
|
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
|
// TODO: scrolling is perf-sensitive, so we'd probably be better to no use postMessage
|
||||||
|
@ -76,7 +76,19 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user