Bug 709845 - Update history's URL after redirect. r=dougt a=dougt
authorChris Peterson <cpeterson@mozilla.com>
Thu, 12 Jan 2012 12:22:48 -0800
changeset 84752 d27ddb7ad0322f1a2bb866092532bd2f3b764e40
parent 84751 6da5a83a4a5c18dbaedf9bb2518020dc0e60c9b7
child 84753 339d1d51af7a14302fdd49e1e6f94ca6387de91e
push id21873
push usermlamouri@mozilla.com
push dateWed, 18 Jan 2012 10:29:07 +0000
treeherdermozilla-central@7538f4d4697c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt, dougt
bugs709845
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 709845 - Update history's URL after redirect. r=dougt a=dougt
mobile/android/base/Tab.java
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -78,17 +78,17 @@ public class Tab {
     private boolean mBookmark;
     private HashMap<String, DoorHanger> mDoorHangers;
     private long mFaviconLoadId;
     private CheckBookmarkTask mCheckBookmarkTask;
     private String mDocumentURI;
     private String mContentType;
 
     static class HistoryEntry {
-        public final String mUri;   // must never be null
+        public String mUri;         // must never be null
         public String mTitle;       // must never be null
 
         public HistoryEntry(String uri, String title) {
             mUri = uri;
             mTitle = title;
         }
     }
 
@@ -197,16 +197,17 @@ public class Tab {
         return mExternal;
     }
 
     public void updateURL(String url) {
         if (url != null && url.length() > 0) {
             mUrl = url;
             Log.i(LOGTAG, "Updated url: " + url + " for tab with id: " + mId);
             updateBookmark();
+            updateHistoryEntry(mUrl, mTitle);
         }
     }
 
     public void setDocumentURI(String documentURI) {
         mDocumentURI = documentURI;
     }
 
     public String getDocumentURI() {
@@ -220,23 +221,27 @@ public class Tab {
     public String getContentType() {
         return mContentType;
     }
 
     public void updateTitle(String title) {
         mTitle = (title == null ? "" : title);
 
         Log.i(LOGTAG, "Updated title: " + mTitle + " for tab with id: " + mId);
+        updateHistoryEntry(mUrl, mTitle);
+    }
 
+    private void updateHistoryEntry(final String uri, final String title) {
         final HistoryEntry he = getLastHistoryEntry();
         if (he != null) {
-            he.mTitle = mTitle;
+            he.mUri = uri;
+            he.mTitle = title;
             GeckoAppShell.getHandler().post(new Runnable() {
                 public void run() {
-                    GlobalHistory.getInstance().update(he.mUri, he.mTitle);
+                    GlobalHistory.getInstance().update(uri, title);
                 }
             });
         } else {
             Log.e(LOGTAG, "Requested title update on empty history stack");
         }
     }
 
     public void setLoading(boolean loading) {