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:
Andrew Grieve 2015-03-13 11:31:16 -04:00
parent f764448ccc
commit 679069729c
3 changed files with 17 additions and 13 deletions

View File

@ -77,5 +77,6 @@ public interface CordovaWebViewEngine {
void onReceivedError(int errorCode, String description, String failingUrl);
void onPageFinishedLoading(String url);
void onScrollChanged(int l, int t, int oldl, int oldt);
boolean onNavigationAttempt(String url);
}
}

View File

@ -581,5 +581,20 @@ public class CordovaWebViewImpl implements CordovaWebView {
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, getView());
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;
}
}
}

View File

@ -76,19 +76,7 @@ public class SystemWebViewClient extends WebViewClient {
*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String 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;
return parentEngine.client.onNavigationAttempt(url);
}
/**