diff --git a/framework/src/org/apache/cordova/CordovaWebViewEngine.java b/framework/src/org/apache/cordova/CordovaWebViewEngine.java index 8b62b1f3..d996a1c0 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewEngine.java +++ b/framework/src/org/apache/cordova/CordovaWebViewEngine.java @@ -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); diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java index 744bd444..303f4e86 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java +++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java @@ -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 diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java index 69dc2f22..6aaac755 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java @@ -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