Bug 1297117 - Replace unnecessary usage of getUrlFromAboutReader with stripAboutReaderUrl r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 02 Sep 2016 12:32:07 -0700
changeset 409421 b92415d6aedc3f931762243b71f82999be50455d
parent 409420 46e86751a3429cd64ae06d3029008a20cff67d64
child 409422 770479e18c32b6571b87b0974fa72720ae42d9f5
push id28461
push userahunt@mozilla.com
push dateFri, 02 Sep 2016 19:39:30 +0000
reviewerssebastian
bugs1297117
milestone51.0a1
Bug 1297117 - Replace unnecessary usage of getUrlFromAboutReader with stripAboutReaderUrl r?sebastian In some of these cases we're duplicating the work of stripAboutReaderUrl. In the other cases there is no effective difference, however switching to stripAboutReaderUrl allows us to make getUrlFromAboutReader private, which should help prevent future errors. MozReview-Commit-ID: BLeQkve2XIs
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -3360,20 +3360,17 @@ public class BrowserApp extends GeckoApp
                     }
                     return false;
                 }
             });
         }
 
         String url = tab.getURL();
         if (AboutPages.isAboutReader(url)) {
-            String urlFromReader = ReaderModeUtils.getUrlFromAboutReader(url);
-            if (urlFromReader != null) {
-                url = urlFromReader;
-            }
+            url = ReaderModeUtils.stripAboutReaderUrl(url);
         }
 
         // Disable share menuitem for about:, chrome:, file:, and resource: URIs
         final boolean shareVisible = Restrictions.isAllowed(this, Restrictable.SHARE);
         share.setVisible(shareVisible);
         final boolean shareEnabled = StringUtils.isShareableUrl(url) && shareVisible;
         share.setEnabled(shareEnabled);
         MenuUtils.safeSetEnabled(aMenu, R.id.downloads, Restrictions.isAllowed(this, Restrictable.DOWNLOAD));
@@ -3542,19 +3539,17 @@ public class BrowserApp extends GeckoApp
             return true;
         }
 
         if (itemId == R.id.share) {
             tab = Tabs.getInstance().getSelectedTab();
             if (tab != null) {
                 String url = tab.getURL();
                 if (url != null) {
-                    if (AboutPages.isAboutReader(url)) {
-                        url = ReaderModeUtils.getUrlFromAboutReader(url);
-                    }
+                    url = ReaderModeUtils.stripAboutReaderUrl(url);
 
                     // Context: Sharing via chrome list (no explicit session is active)
                     Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.LIST, "menu");
 
                     IntentHelper.openUriExternal(url, "text/plain", "", "", Intent.ACTION_SEND, tab.getDisplayTitle(), false);
                 }
             }
             return true;
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -743,25 +743,25 @@ public class Tabs implements GeckoEventL
      *         tab.
      */
     public Tab getFirstReaderTabForUrl(String url, boolean isPrivate) {
         if (url == null) {
             return null;
         }
 
         if (AboutPages.isAboutReader(url)) {
-            url = ReaderModeUtils.getUrlFromAboutReader(url);
+            url = ReaderModeUtils.stripAboutReaderUrl(url);
         }
         for (Tab tab : mOrder) {
             if (isPrivate != tab.isPrivate()) {
                 continue;
             }
             String tabUrl = tab.getURL();
             if (AboutPages.isAboutReader(tabUrl)) {
-                tabUrl = ReaderModeUtils.getUrlFromAboutReader(tabUrl);
+                tabUrl = ReaderModeUtils.stripAboutReaderUrl(tabUrl);
                 if (url.equals(tabUrl)) {
                     return tab;
                 }
             }
         }
 
         return null;
     }