Bug 868342 - (Part 1) Fix NPE in BrowserToolbar.setTitle. r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 08 May 2013 15:53:24 -0400
changeset 142235 1c8df5e637a21782acfec5fc13d333b3eb489780
parent 142234 b61e721b78af92e7900112d59b8cb7490139cc8e
child 142236 a23eea95bf64672dcab5fedfad76339028c9593b
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs868342
milestone23.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 868342 - (Part 1) Fix NPE in BrowserToolbar.setTitle. r=wesj
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -882,43 +882,45 @@ public class BrowserToolbar implements T
             mShadow.setVisibility(visible ? View.VISIBLE : View.GONE);
         }
     }
 
     private void setTitle(String title) {
         Tab tab = Tabs.getInstance().getSelectedTab();
         CharSequence displayTitle = title;
 
-        // Keep the title unchanged if the tab is entering reader mode
-        if (tab != null && tab.isEnteringReaderMode())
-            return;
+        if (tab != null) {
+            // Keep the title unchanged if the tab is entering reader mode
+            if (tab.isEnteringReaderMode()) {
+                return;
+            }
 
-        // Setting a null title will ensure we just see the "Enter Search or Address"
-        // placeholder text. Because "about:home" and "about:privatebrowsing" don't
-        // have titles, their display titles will always match their URLs.
-        if (tab != null && ("about:home".equals(title) ||
-                            "about:privatebrowsing".equals(title))) {
-            displayTitle = null;
-        }
+            // Setting a null title will ensure we just see the "Enter Search or Address"
+            // placeholder text. Because "about:home" and "about:privatebrowsing" don't
+            // have titles, their display titles will always match their URLs.
+            if ("about:home".equals(title) || "about:privatebrowsing".equals(title)) {
+                displayTitle = null;
+            }
 
-        if (mShowUrl && displayTitle != null) {
-            title = StringUtils.stripScheme(tab.getURL());
-            title = StringUtils.stripCommonSubdomains(title);
-            displayTitle = title;
+            if (mShowUrl && displayTitle != null) {
+                title = StringUtils.stripScheme(tab.getURL());
+                title = StringUtils.stripCommonSubdomains(title);
+                displayTitle = title;
 
-            // highlight the domain name if we find one
-            String baseDomain = tab.getBaseDomain();
-            if (!TextUtils.isEmpty(baseDomain)) {
-                SpannableStringBuilder builder = new SpannableStringBuilder(title);
-                int index = title.indexOf(baseDomain);
-                if (index > -1) {
-                    builder.setSpan(mUrlColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-                    builder.setSpan(tab.isPrivate() ? mPrivateDomainColor : mDomainColor, index, index+baseDomain.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+                // highlight the domain name if we find one
+                String baseDomain = tab.getBaseDomain();
+                if (!TextUtils.isEmpty(baseDomain)) {
+                    SpannableStringBuilder builder = new SpannableStringBuilder(title);
+                    int index = title.indexOf(baseDomain);
+                    if (index > -1) {
+                        builder.setSpan(mUrlColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+                        builder.setSpan(tab.isPrivate() ? mPrivateDomainColor : mDomainColor, index, index+baseDomain.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
 
-                    displayTitle = builder;
+                        displayTitle = builder;
+                    }
                 }
             }
         }
 
         mTitle.setText(displayTitle);
         mLayout.setContentDescription(title != null ? title : mTitle.getHint());
     }