diff --git a/framework/src/org/apache/cordova/CordovaWebViewEngine.java b/framework/src/org/apache/cordova/CordovaWebViewEngine.java index d996a1c0..b31c888a 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewEngine.java +++ b/framework/src/org/apache/cordova/CordovaWebViewEngine.java @@ -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); } } diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java index 3b5aecd9..ed9d9da1 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java +++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java @@ -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; + } } } diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java index 6aaac755..d1765024 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java @@ -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); } /**