Bug 1280539 - don't open topsites into reader view if stored as offline reader-view page. r=sebastian, a=gchang
authorAndrzej Hunt <ahunt@mozilla.com>
Mon, 27 Jun 2016 22:23:08 +0200
changeset 339754 54a76ec78ed88c8b75d0cf7b12fbd23314e94ae2
parent 339753 c83de296c78d277a35e67cdc950162ee8e75bf39
child 339755 b7b3534b69ec3287a2fb615d576c89ab3eb7b517
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)
reviewerssebastian, gchang
bugs1280539
milestone49.0a2
Bug 1280539 - don't open topsites into reader view if stored as offline reader-view page. r=sebastian, a=gchang By default, i.e. for most lists in the homepanels, we want to open the offline reader-view version of a page if the page is stored as an offline reader-view bookmark (TwoLinePageRow shows the bookmark and offline status for pages, not only in bookmarks, but also in the list of top sites, awesomescreen results, and history). The only exception is the topsites grid, where we don't offer any indication of the bookmark or offline status of a page. For now the expectation is that topsites open the normal version of a page, so we need to bypass the usual flow for that case. (It's possible the UI around this would change in future, but with the current UI this is probably the most obvious / least frustrating behaviour.) MozReview-Commit-ID: BMpGG4KQ62w
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/home/HomePager.java
mobile/android/base/java/org/mozilla/gecko/home/TopSitesPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -3830,17 +3830,26 @@ public class BrowserApp extends GeckoApp
     // HomePager.OnUrlOpenListener
     @Override
     public void onUrlOpen(String url, EnumSet<OnUrlOpenListener.Flags> flags) {
         if (flags.contains(OnUrlOpenListener.Flags.OPEN_WITH_INTENT)) {
             Intent intent = new Intent(Intent.ACTION_VIEW);
             intent.setData(Uri.parse(url));
             startActivity(intent);
         } else {
-            final String pageURL = SavedReaderViewHelper.getReaderURLIfCached(getContext(), url);
+            // By default this listener is used for lists where the offline reader-view icon
+            // is shown - hence we need to redirect to the reader-view page by default.
+            // However there are some cases where we might not want to use this, e.g.
+            // for topsites where we do not indicate that a page is an offline reader-view bookmark too.
+            final String pageURL;
+            if (!flags.contains(OnUrlOpenListener.Flags.NO_READER_VIEW)) {
+                pageURL = SavedReaderViewHelper.getReaderURLIfCached(getContext(), url);
+            } else {
+                pageURL = url;
+            }
 
             if (!maybeSwitchToTab(pageURL, flags)) {
                 openUrlAndStopEditing(pageURL);
                 clearSelectedTabApplicationId();
             }
         }
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomePager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomePager.java
@@ -73,17 +73,22 @@ public class HomePager extends ViewPager
     public static final String LIST_TAG_TOP_SITES = "top_sites";
     public static final String LIST_TAG_RECENT_TABS = "recent_tabs";
     public static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
     public static final String LIST_TAG_REMOTE_TABS = "remote_tabs";
 
     public interface OnUrlOpenListener {
         public enum Flags {
             ALLOW_SWITCH_TO_TAB,
-            OPEN_WITH_INTENT
+            OPEN_WITH_INTENT,
+            /**
+             * Ensure that the raw URL is opened. If not set, then the reader view version of the page
+             * might be opened if the URL is stored as an offline reader-view bookmark.
+             */
+            NO_READER_VIEW
         }
 
         public void onUrlOpen(String url, EnumSet<Flags> flags);
     }
 
     /**
      * Interface for requesting a new tab be opened in the background.
      * <p>
--- a/mobile/android/base/java/org/mozilla/gecko/home/TopSitesPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TopSitesPanel.java
@@ -217,17 +217,17 @@ public class TopSitesPanel extends HomeF
 
                         String extra = Integer.toString(position);
                         if (type == TopSites.TYPE_PINNED) {
                             extra += "-pinned";
                         }
 
                         Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, extra);
 
-                        mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
+                        mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.NO_READER_VIEW));
                     }
                 } else {
                     if (mEditPinnedSiteListener != null) {
                         mEditPinnedSiteListener.onEditPinnedSite(position, "");
                     }
                 }
             }
         });