Bug 1267467 - Strip about:reader when storing URIs in history r=margaret
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 10 May 2016 15:33:33 -0700
changeset 337684 2dc0440c0d6a3741a9d7791f9c0a180f78a91747
parent 337683 b1f926af38405c963cb7cc6db9e35ec099c7619a
child 337685 0d8baf8b4e768f4d403fab4c260997e173cde275
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1267467
milestone49.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 1267467 - Strip about:reader when storing URIs in history r=margaret MozReview-Commit-ID: JbUBMVNFdU9
mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
--- a/mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko;
 
 import java.lang.ref.SoftReference;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.Queue;
 import java.util.Set;
 
 import org.mozilla.gecko.db.BrowserDB;
+import org.mozilla.gecko.reader.ReaderModeUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.ContentResolver;
 import android.content.Context;
 import android.database.Cursor;
 import android.os.Handler;
 import android.os.SystemClock;
 import android.util.Log;
@@ -113,44 +114,51 @@ class GlobalHistory {
         }
         GeckoAppShell.notifyUriVisited(uri);
     }
 
     public void add(final Context context, final BrowserDB db, String uri) {
         ThreadUtils.assertOnBackgroundThread();
         final long start = SystemClock.uptimeMillis();
 
-        db.updateVisitedHistory(context.getContentResolver(), uri);
+        // stripAboutReaderUrl only removes about:reader if present, in all other cases the original string is returned
+        final String uriToStore = ReaderModeUtils.stripAboutReaderUrl(uri);
+
+        db.updateVisitedHistory(context.getContentResolver(), uriToStore);
 
         final long end = SystemClock.uptimeMillis();
         final long took = end - start;
         Telemetry.addToHistogram(TELEMETRY_HISTOGRAM_ADD, (int) Math.min(took, Integer.MAX_VALUE));
-        addToGeckoOnly(uri);
+        addToGeckoOnly(uriToStore);
     }
 
     @SuppressWarnings("static-method")
     public void update(final ContentResolver cr, final BrowserDB db, String uri, String title) {
         ThreadUtils.assertOnBackgroundThread();
         final long start = SystemClock.uptimeMillis();
 
-        db.updateHistoryTitle(cr, uri, title);
+        final String uriToStore = ReaderModeUtils.stripAboutReaderUrl(uri);
+
+        db.updateHistoryTitle(cr, uriToStore, title);
 
         final long end = SystemClock.uptimeMillis();
         final long took = end - start;
         Telemetry.addToHistogram(TELEMETRY_HISTOGRAM_UPDATE, (int) Math.min(took, Integer.MAX_VALUE));
     }
 
     public void checkUriVisited(final String uri) {
+        final String storedURI = ReaderModeUtils.stripAboutReaderUrl(uri);
+
         final NotifierRunnable runnable = new NotifierRunnable(GeckoAppShell.getContext());
         mHandler.post(new Runnable() {
             @Override
             public void run() {
                 // this runs on the same handler thread as the processing loop,
                 // so no synchronization needed
-                mPendingUris.add(uri);
+                mPendingUris.add(storedURI);
                 if (mProcessing) {
                     // there's already a runnable queued up or working away, so
                     // no need to post another
                     return;
                 }
                 mProcessing = true;
                 mHandler.postDelayed(runnable, BATCHING_DELAY_MS);
             }