OSDN Git Service

Do not destroy the backforward list when doing another voice search.
authorLeon Scroggins <scroggo@google.com>
Mon, 15 Mar 2010 22:19:14 +0000 (18:19 -0400)
committerLeon Scroggins <scroggo@google.com>
Wed, 17 Mar 2010 12:46:53 +0000 (08:46 -0400)
Fix for http://b/issue?id=2516327

Change-Id: I0daf8ba6e24be6682d849107914877fb0c31ec4f

src/com/android/browser/BrowserActivity.java
src/com/android/browser/TabControl.java

index 55e5177..4c8fc5c 100644 (file)
@@ -465,11 +465,7 @@ public class BrowserActivity extends Activity
                     // If the WebView has the same original url and is on that
                     // page, it can be reused.
                     boolean needsLoad =
-                            mTabControl.recreateWebView(appTab, urlData.mUrl)
-                            // If there is a voice intent in the UrlData, then
-                            // recreateWebView may return false, but we still
-                            // need to force a load.
-                            || urlData.mVoiceIntent != null;
+                            mTabControl.recreateWebView(appTab, urlData);
 
                     if (current != appTab) {
                         switchToTab(mTabControl.getTabIndex(appTab));
@@ -3934,7 +3930,7 @@ public class BrowserActivity extends Activity
      * A UrlData class to abstract how the content will be set to WebView.
      * This base class uses loadUrl to show the content.
      */
-    private static class UrlData {
+    /* package */ static class UrlData {
         final String mUrl;
         final Map<String, String> mHeaders;
         final Intent mVoiceIntent;
index e64f3fb..de32b03 100644 (file)
@@ -490,11 +490,18 @@ class TabControl {
 
     /**
      * Recreate the main WebView of the given tab. Returns true if the WebView
-     * was deleted.
+     * requires a load, whether it was due to the fact that it was deleted, or
+     * it is because it was a voice search.
      */
-    boolean recreateWebView(Tab t, String url) {
+    boolean recreateWebView(Tab t, BrowserActivity.UrlData urlData) {
+        final String url = urlData.mUrl;
         final WebView w = t.getWebView();
         if (w != null) {
+            if (urlData.mVoiceIntent != null) {
+                // In the case of a voice search, we do not want to destroy the
+                // back forward list, so that we can go back to the prior search
+                return true;
+            }
             if (url != null && url.equals(t.getOriginalUrl())) {
                 // The original url matches the current url. Just go back to the
                 // first history item so we can load it faster than if we