From 5d68d5a24616d97b351d13e26e963cd707cfdd25 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 4 Mar 2013 16:09:37 -0800 Subject: [PATCH] CB-2198: Removing option to use our broken URL stack as a history as per deprecation policy. --- .../org/apache/cordova/CordovaWebView.java | 78 ++----------------- .../apache/cordova/CordovaWebViewClient.java | 29 +------ 2 files changed, 6 insertions(+), 101 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index a1f423b2..e61a215e 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -75,12 +75,8 @@ public class CordovaWebView extends WebView { @SuppressWarnings("unused") private CordovaChromeClient chromeClient; - //This is for the polyfill history private String url; String baseUrl; - private Stack urls = new Stack(); - - boolean useBrowserHistory = true; // Flag to track that a loadUrl timeout occurred int loadUrlTimeout = 0; @@ -370,7 +366,7 @@ public class CordovaWebView extends WebView { String initUrl = this.getProperty("url", null); // If first page of app, then set URL to load to be the one passed in - if (initUrl == null || (this.urls.size() > 0)) { + if (initUrl == null) { this.loadUrlIntoView(url); } // Otherwise use the URL specified in the activity's extras bundle @@ -391,7 +387,7 @@ public class CordovaWebView extends WebView { String initUrl = this.getProperty("url", null); // If first page of app, then set URL to load to be the one passed in - if (initUrl == null || (this.urls.size() > 0)) { + if (initUrl == null) { this.loadUrlIntoView(url, time); } // Otherwise use the URL specified in the activity's extras bundle @@ -419,10 +415,6 @@ public class CordovaWebView extends WebView { } this.pluginManager.init(); - - if (!this.useBrowserHistory) { - this.urls.push(url); - } } // Create a timeout timer for loadUrl @@ -494,7 +486,7 @@ public class CordovaWebView extends WebView { // If not first page of app, then load immediately // Add support for browser history if we use it. - if ((url.startsWith("javascript:")) || this.urls.size() > 0 || this.canGoBack()) { + if ((url.startsWith("javascript:")) || this.canGoBack()) { } // If first page, then show splashscreen @@ -542,25 +534,6 @@ public class CordovaWebView extends WebView { } } - /** - * Returns the top url on the stack without removing it from - * the stack. - */ - public String peekAtUrlStack() { - if (this.urls.size() > 0) { - return this.urls.peek(); - } - return ""; - } - - /** - * Add a url to the stack - * - * @param url - */ - public void pushUrl(String url) { - this.urls.push(url); - } /** * Go to previous page in history. (We manage our own history) @@ -571,37 +544,15 @@ public class CordovaWebView extends WebView { // Check webview first to see if there is a history // This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior) - if (super.canGoBack() && this.useBrowserHistory) { + if (super.canGoBack()) { printBackForwardList(); super.goBack(); return true; } - // If our managed history has prev url - else if (this.urls.size() > 1 && !this.useBrowserHistory) { - this.urls.pop(); // Pop current url - String url = this.urls.pop(); // Pop prev url that we want to load, since it will be added back by loadUrl() - this.loadUrl(url); - return true; - } - return false; } - /** - * Return true if there is a history item. - * - * @return - */ - public boolean canGoBack() { - if (super.canGoBack() && this.useBrowserHistory) { - return true; - } - else if (this.urls.size() > 1) { - return true; - } - return false; - } /** * Load the specified URL in the Cordova webview or a new browser instance. @@ -627,12 +578,6 @@ public class CordovaWebView extends WebView { // Make sure url is in whitelist if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || Config.isUrlWhiteListed(url)) { // TODO: What about params? - - // Clear out current url from history, since it will be replacing it - if (clearHistory) { - this.urls.clear(); - } - // Load new URL this.loadUrl(url); } @@ -669,13 +614,6 @@ public class CordovaWebView extends WebView { * */ private void loadConfiguration() { - // Config has already been loaded, and it stores these preferences on the Intent. - if("false".equals(this.getProperty("useBrowserHistory", "true"))) - { - //Switch back to the old browser history and state the six month policy - this.useBrowserHistory = false; - Log.w(TAG, "useBrowserHistory=false is deprecated as of Cordova 2.2.0 and will be removed six months after the 2.2.0 release. Please use the browser history and use history.back()."); - } if ("true".equals(this.getProperty("fullscreen", "false"))) { this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); @@ -729,13 +667,7 @@ public class CordovaWebView extends WebView { } else if(keyCode == KeyEvent.KEYCODE_BACK) { - //Because exit is fired on the keyDown and not the key up on Android 4.x - //we need to check for this. - //Also, I really wished "canGoBack" worked! - if(this.useBrowserHistory) - return !(this.startOfHistory()) || this.bound; - else - return this.urls.size() > 1 || this.bound; + return !(this.startOfHistory()) || this.bound; } else if(keyCode == KeyEvent.KEYCODE_MENU) { diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index 8b023ebd..209dd791 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -193,11 +193,7 @@ public class CordovaWebViewClient extends WebViewClient { // If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity. // Our app continues to run. When BACK is pressed, our app is redisplayed. if (url.startsWith("file://") || url.startsWith("data:") || url.indexOf(this.appView.baseUrl) == 0 || Config.isUrlWhiteListed(url)) { - //This will fix iFrames - if (appView.useBrowserHistory || url.startsWith("data:")) - return false; - else - this.appView.loadUrl(url); + return false; } // If not our application, let default viewer handle @@ -248,12 +244,6 @@ public class CordovaWebViewClient extends WebViewClient { */ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { - // Clear history so history.back() doesn't do anything. - // So we can reinit() native side CallbackServer & PluginManager. - if (!this.appView.useBrowserHistory) { - view.clearHistory(); - this.doClearHistory = true; - } // Flush stale messages. this.appView.jsMessageQueue.reset(); @@ -392,23 +382,6 @@ public class CordovaWebViewClient extends WebViewClient { } } - /** - * Notify the host application to update its visited links database. - * - * @param view The WebView that is initiating the callback. - * @param url The url being visited. - * @param isReload True if this url is being reloaded. - */ - @Override - public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { - /* - * If you do a document.location.href the url does not get pushed on the stack - * so we do a check here to see if the url should be pushed. - */ - if (!this.appView.peekAtUrlStack().equals(url)) { - this.appView.pushUrl(url); - } - } /** * Sets the authentication token.