Bug 1244734 - Handle a null tab URL in enterEditingMode. r=liuche draft
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 01 Feb 2016 10:47:10 -0500
changeset 327735 9aadaf8d4995793890b436780a16a39421c16d55
parent 327548 71957edda717276df5062b504c77eecbe2dca757
child 513735 f7bfd1027fdd7c27d0b332cd0d25b6f901622b39
push id10277
push usermleibovic@mozilla.com
push dateMon, 01 Feb 2016 18:19:16 +0000
reviewersliuche
bugs1244734
milestone47.0a1
Bug 1244734 - Handle a null tab URL in enterEditingMode. r=liuche
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import android.Manifest;
 import android.os.AsyncTask;
+import android.support.annotation.NonNull;
 import org.mozilla.gecko.adjust.AdjustHelperInterface;
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.DynamicToolbar.PinReason;
 import org.mozilla.gecko.DynamicToolbar.VisibilityTransition;
 import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
 import org.mozilla.gecko.Tabs.TabEvents;
 import org.mozilla.gecko.animation.PropertyAnimator;
@@ -2217,46 +2218,43 @@ public class BrowserApp extends GeckoApp
      * the app starts. In this case, we simply fallback to an empty URL.
      */
     private void enterEditingMode() {
         if (hideFirstrunPager()) {
             Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL, TelemetryContract.Method.ACTIONBAR, "firstrun-pane");
         }
 
         String url = "";
+        String telemetryMsg = "urlbar-empty";
 
         final Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab != null) {
             final String userSearchTerm = tab.getUserRequested();
+            final String tabURL = tab.getURL();
 
             // Check to see if there's a user-entered search term,
             // which we save whenever the user performs a search.
-            final String telemetryMsg;
             if (!TextUtils.isEmpty(userSearchTerm)) {
                 url = userSearchTerm;
                 telemetryMsg = "urlbar-userentered";
-            } else {
-                url = tab.getURL();
-                telemetryMsg = url.isEmpty() ? "urlbar-empty" : "urlbar-url";
+            } else if (!TextUtils.isEmpty(tabURL)) {
+                url = tabURL;
+                telemetryMsg = "urlbar-url";
             }
-
-            Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.ACTIONBAR, telemetryMsg);
         }
+
         enterEditingMode(url);
+        Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.ACTIONBAR, telemetryMsg);
     }
 
     /**
      * Enters editing mode with the specified URL. If a null
      * url is given, the empty String will be used instead.
      */
-    private void enterEditingMode(String url) {
-        if (url == null) {
-            url = "";
-        }
-
+    private void enterEditingMode(@NonNull String url) {
         if (mBrowserToolbar.isEditing() || mBrowserToolbar.isAnimating()) {
             return;
         }
 
         final Tab selectedTab = Tabs.getInstance().getSelectedTab();
         final String panelId;
         if (selectedTab != null) {
             mTargetTabForEditingMode = selectedTab.getId();