mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-7747 When both allow-navigation and allow-external are set, navigate instead of opening external
Also: Move shouldOverrideUrlLoading logic into CordovaWebViewEngine.Client
This commit is contained in:
parent
f764448ccc
commit
679069729c
@ -77,5 +77,6 @@ public interface CordovaWebViewEngine {
|
|||||||
void onReceivedError(int errorCode, String description, String failingUrl);
|
void onReceivedError(int errorCode, String description, String failingUrl);
|
||||||
void onPageFinishedLoading(String url);
|
void onPageFinishedLoading(String url);
|
||||||
void onScrollChanged(int l, int t, int oldl, int oldt);
|
void onScrollChanged(int l, int t, int oldl, int oldt);
|
||||||
|
boolean onNavigationAttempt(String url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,5 +581,20 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, getView());
|
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, getView());
|
||||||
pluginManager.postMessage("onScrollChanged", myEvent);
|
pluginManager.postMessage("onScrollChanged", myEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationAttempt(String url) {
|
||||||
|
// Give plugins the chance to handle the url
|
||||||
|
if (pluginManager.onOverrideUrlLoading(url)) {
|
||||||
|
return true;
|
||||||
|
} else if (pluginManager.shouldAllowNavigation(url)) {
|
||||||
|
return false;
|
||||||
|
} else if (pluginManager.shouldOpenExternalUrl(url)) {
|
||||||
|
showWebPage(url, true, false, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,19 +76,7 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
// Give plugins the chance to handle the url
|
return parentEngine.client.onNavigationAttempt(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