Bug 1244734 - Handle a null tab URL in enterEditingMode. r=liuche
--- 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();