Bug 1272340 - ToolbarDisplayLayout: Handle about:reader URLs. r=margaret, a=sledru
authorSebastian Kaspari <s.kaspari@gmail.com>
Mon, 30 May 2016 14:29:53 +0200
changeset 333174 be0703a058c65df02b8937f5b93417301f208688
parent 333173 db6a952a98f8933de30705edb0068c6bcfc3f8c9
child 333175 3fd4a2fd817cb30237c037344049c4ab947aa00c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1272340
milestone48.0a2
Bug 1272340 - ToolbarDisplayLayout: Handle about:reader URLs. r=margaret, a=sledru This patch changes two things: * Check if the URL is http/https after stripping the about:reader URL. * Always call updateAndColorTitleFromFullURL() as fallback for URL formatting (like in previous versions)
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -263,21 +263,22 @@ public class ToolbarDisplayLayout extend
             final SpannableStringBuilder builder = new SpannableStringBuilder(title);
             builder.setSpan(mBlockedColorSpan, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
 
             setTitle(builder);
             setContentDescription(null);
             return;
         }
 
-        final boolean isHttpOrHttps = StringUtils.isHttpOrHttps(url);
         final String baseDomain = tab.getBaseDomain();
 
         String strippedURL = stripAboutReaderURL(url);
 
+        final boolean isHttpOrHttps = StringUtils.isHttpOrHttps(strippedURL);
+
         if (mPrefs.shouldTrimUrls()) {
             strippedURL = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(strippedURL));
         }
 
         // This value is not visible to screen readers but we rely on it when running UI tests. Screen
         // readers will instead focus BrowserToolbar and read the "base domain" from there. UI tests
         // will read the content description to obtain the full URL for performing assertions.
         setContentDescription(strippedURL);
@@ -285,22 +286,19 @@ public class ToolbarDisplayLayout extend
         final SiteIdentity siteIdentity = tab.getSiteIdentity();
         if (siteIdentity.hasOwner() && SwitchBoard.isInExperiment(mActivity, Experiments.URLBAR_SHOW_EV_CERT_OWNER)) {
             // Show Owner of EV certificate as title
             updateTitleFromSiteIdentity(siteIdentity);
         } else if (isHttpOrHttps && !HardwareUtils.isTablet() && !TextUtils.isEmpty(baseDomain)
                 && SwitchBoard.isInExperiment(mActivity, Experiments.URLBAR_SHOW_ORIGIN_ONLY)) {
             // Show just the base domain as title
             setTitle(baseDomain);
-        } else if (isHttpOrHttps) {
+        } else {
             // Display full URL with base domain highlighted as title
             updateAndColorTitleFromFullURL(strippedURL, baseDomain, tab.isPrivate());
-        } else {
-            // Not http(s): Just show the full URL as title
-            setTitle(url);
         }
     }
 
     private void updateTitleFromSiteIdentity(SiteIdentity siteIdentity) {
         final String title;
 
         if (siteIdentity.hasCountry()) {
             title = String.format("%s (%s)", siteIdentity.getOwner(), siteIdentity.getCountry());