diff options
author | Mathew Inwood <mathewi@google.com> | 2011-08-03 14:34:29 +0100 |
---|---|---|
committer | Mathew Inwood <mathewi@google.com> | 2011-08-03 18:01:05 +0100 |
commit | 1dd8e82b74b1055fcd572e820a724997550edd33 (patch) | |
tree | ebcac1886897b76a36ad5101341976de5ae1d79c /src/com | |
parent | 7cff891f31311139e215e3948198843bcafd6137 (diff) | |
download | packages_apps_Browser-1dd8e82b74b1055fcd572e820a724997550edd33.zip packages_apps_Browser-1dd8e82b74b1055fcd572e820a724997550edd33.tar.gz packages_apps_Browser-1dd8e82b74b1055fcd572e820a724997550edd33.tar.bz2 |
Remove preloaded URLs from back stack when preloading fails.
Bug: 5114365
Change-Id: Iaef0c062ac1ee2ea6e3cde8699d67a0cc4ff1a56
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/browser/PreloadedTabControl.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/com/android/browser/PreloadedTabControl.java b/src/com/android/browser/PreloadedTabControl.java index d2482a4..824c00b 100644 --- a/src/com/android/browser/PreloadedTabControl.java +++ b/src/com/android/browser/PreloadedTabControl.java @@ -82,8 +82,9 @@ public class PreloadedTabControl { if (!called) { if (LOGD_ENABLED) Log.d(LOGTAG, "Query not submitted; falling back"); loadUrl(fallbackUrl, fallbackHeaders); + // make sure that the failed, preloaded URL is cleared from the back stack + mTab.clearBackStackWhenItemAdded(fallbackUrl); } - mTab.getWebView().clearHistory(); }}); return true; } diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 6aa8683..a251212 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -90,6 +90,7 @@ class Tab implements PictureListener { // Log Tag private static final String LOGTAG = "Tab"; + private static final boolean LOGD_ENABLED = com.android.browser.Browser.LOGD_ENABLED; // Special case the logtag for messages for the Console to make it easier to // filter them and match the logtag used for these messages in older versions // of the browser. @@ -166,6 +167,11 @@ class Tab implements PictureListener { private Bitmap mCapture; private Handler mHandler; + /** + * See {@link #clearBackStackWhenItemAdded(String)}. + */ + private String mClearHistoryMatchUrl; + private static synchronized Bitmap getDefaultFavicon(Context context) { if (sDefaultFavicon == null) { sDefaultFavicon = BitmapFactory.decodeResource( @@ -1398,6 +1404,18 @@ class Tab implements PictureListener { if (isInVoiceSearchMode()) { item.setCustomData(mVoiceSearchData.mVoiceSearchIntent); } + if (mClearHistoryMatchUrl != null) { + if (LOGD_ENABLED) { + Log.d(LOGTAG, "onNewHistoryItem:\n\t" + item.getUrl() + "\n\t" + + mClearHistoryMatchUrl); + } + if (TextUtils.equals(item.getOriginalUrl(), mClearHistoryMatchUrl)) { + if (mMainView != null) { + mMainView.clearHistory(); + } + } + mClearHistoryMatchUrl = null; + } } @Override public void onIndexChanged(WebHistoryItem item, int index) { @@ -1416,6 +1434,7 @@ class Tab implements PictureListener { restoreState(state); setWebView(w); mHandler = new Handler() { + @Override public void handleMessage(Message m) { switch (m.what) { case MSG_CAPTURE: @@ -2029,6 +2048,17 @@ class Tab implements PictureListener { } } + /** + * Causes the tab back/forward stack to be cleared once, if the given URL is the next URL + * to be added to the stack. + * + * This is used to ensure that preloaded URLs that are not subsequently seen by the user do + * not appear in the back stack. + */ + public void clearBackStackWhenItemAdded(String urlToMatch) { + mClearHistoryMatchUrl = urlToMatch; + } + protected void persistThumbnail() { BackgroundHandler.execute(mSaveThumbnail); } |