Bug 790305 - Don't add history entries for redirects or error pages. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Wed, 24 Oct 2012 09:04:44 -0700
changeset 111393 8c8c0b8e97f8cb65ecc0ede8bca5038a2743f7e2
parent 111392 5da9c2f970b0970a4a68e3183838dc115e72f48e
child 111394 161dd84a24fc53105aae2a707cd952946d0704f6
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs790305
milestone19.0a1
Bug 790305 - Don't add history entries for redirects or error pages. r=mfinkle
mobile/android/base/Tab.java
toolkit/components/places/nsAndroidHistory.cpp
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -232,17 +232,16 @@ public class Tab {
         return mExternal;
     }
 
     public synchronized void updateURL(String url) {
         if (url != null && url.length() > 0) {
             mUrl = url;
             Log.d(LOGTAG, "Updated URL for tab with id: " + mId);
             updateBookmark();
-            updateHistory(mUrl, mTitle);
         }
     }
 
     public void setDocumentURI(String documentURI) {
         mDocumentURI = documentURI;
     }
 
     public String getDocumentURI() {
@@ -291,17 +290,17 @@ public class Tab {
         });
     }
 
     public void setState(int state) {
         mState = state;
 
         if (mState != Tab.STATE_LOADING)
             mEnteringReaderMode = false;
-        }
+    }
 
     public int getState() {
         return mState;
     }
 
     public void setZoomConstraints(ZoomConstraints constraints) {
         mZoomConstraints = constraints;
     }
@@ -494,17 +493,16 @@ public class Tab {
         return true;
     }
 
     void handleSessionHistoryMessage(String event, JSONObject message) throws JSONException {
         if (event.equals("New")) {
             final String url = message.getString("url");
             mHistoryIndex++;
             mHistorySize = mHistoryIndex + 1;
-            addHistory(url);
         } else if (event.equals("Back")) {
             if (!canDoBack()) {
                 Log.e(LOGTAG, "Received unexpected back notification");
                 return;
             }
             mHistoryIndex--;
         } else if (event.equals("Forward")) {
             if (!canDoForward()) {
--- a/toolkit/components/places/nsAndroidHistory.cpp
+++ b/toolkit/components/places/nsAndroidHistory.cpp
@@ -84,16 +84,22 @@ NS_IMETHODIMP
 nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlags)
 {
   if (!aURI)
     return NS_OK;
 
   if (!(aFlags & VisitFlags::TOP_LEVEL))
     return NS_OK;
 
+  if (aFlags & VisitFlags::REDIRECT_SOURCE)
+    return NS_OK;
+
+  if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
+    return NS_OK;
+
   AndroidBridge *bridge = AndroidBridge::Bridge();
   if (bridge) {
     nsAutoCString uri;
     nsresult rv = aURI->GetSpec(uri);
     if (NS_FAILED(rv)) return rv;
     NS_ConvertUTF8toUTF16 uriString(uri);
     bridge->MarkURIVisited(uriString);
   }