From c206ac03350b6eb8fe38d1c87503e288ed8c558f Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 19 Sep 2012 13:47:09 -0700 Subject: [PATCH] Fixing CB-1504 --- .../src/org/apache/cordova/CordovaWebView.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index ddae1dda..9c05e449 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -50,6 +50,8 @@ import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; import android.view.WindowManager; +import android.webkit.WebBackForwardList; +import android.webkit.WebHistoryItem; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebSettings.LayoutAlgorithm; @@ -572,12 +574,13 @@ 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()) { + printBackForwardList(); super.goBack(); return true; } // If our managed history has prev url - if (this.urls.size() > 1) { + 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); @@ -937,4 +940,17 @@ public class CordovaWebView extends WebView { settings.setAllowUniversalAccessFromFileURLs(true); } } + + + + public void printBackForwardList() { + WebBackForwardList currentList = this.copyBackForwardList(); + int currentSize = currentList.getSize(); + for(int i = 0; i < currentSize; ++i) + { + WebHistoryItem item = currentList.getItemAtIndex(i); + String url = item.getUrl(); + LOG.d(TAG, "The URL at index: " + Integer.toString(i) + "is " + url ); + } + } }