Bug 871639 - Incorrect title when leaving editing mode while on about:home. r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 17 May 2013 14:24:10 -0700
changeset 143301 72ad7246f0413c327705454745e823ea88d1f85b
parent 143300 5d9bbd9db49f894bafce2d4f62a55b014e321eef
child 143302 173cbbdc2e8b96e9497f35731c449ae04b70c0ec
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs871639
milestone24.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 871639 - Incorrect title when leaving editing mode while on about:home. r=wesj
mobile/android/base/BrowserApp.java
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1149,17 +1149,17 @@ abstract public class BrowserApp extends
         return true;
     }
 
     void commitEditingMode(EditingTarget target) {
         if (!mBrowserToolbar.isEditing()) {
             return;
         }
 
-        final String url = mBrowserToolbar.stopEditing();
+        final String url = mBrowserToolbar.commitEdit();
         animateHideHomePager();
 
         int flags = Tabs.LOADURL_USER_ENTERED;
         if (target == EditingTarget.NEW_TAB) {
             flags |= Tabs.LOADURL_NEW_TAB;
         }
 
         if (!TextUtils.isEmpty(url)) {
@@ -1167,17 +1167,17 @@ abstract public class BrowserApp extends
         }
     }
 
     boolean dismissEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return false;
         }
 
-        final String url = mBrowserToolbar.stopEditing();
+        mBrowserToolbar.cancelEdit();
         animateHideHomePager();
 
         return true;
     }
 
     void filterEditingMode(String searchTerm, AutocompleteHandler handler) {
         // FIXME: implement actual awesomebar search
     }
@@ -1727,17 +1727,17 @@ abstract public class BrowserApp extends
         mBrowserToolbar.setProgressVisibility(true);
 
         int flags = Tabs.LOADURL_NONE;
         if (mBrowserToolbar.getEditingTarget() == EditingTarget.NEW_TAB) {
             flags |= Tabs.LOADURL_NEW_TAB;
         }
 
         Tabs.getInstance().loadUrl(url, flags);
-        mBrowserToolbar.stopEditing();
+        mBrowserToolbar.cancelEdit();
     }
 
     @Override
     public void onAboutHomeLoadComplete() {
         mAboutHomeStartupTimer.stop();
     }
 
     @Override
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -1239,29 +1239,44 @@ public class BrowserToolbar implements T
                 mAnimatingEntry = false;
             }
         });
 
         mAnimatingEntry = true;
         contentAnimator.start();
     }
 
-    public String stopEditing() {
+    /**
+     * Exits edit mode without updating the toolbar title.
+     *
+     * @return the url that was entered
+     */
+    public String cancelEdit() {
+        return stopEditing();
+    }
+
+    /**
+     * Exits edit mode, updating the toolbar title with the url that was just entered.
+     *
+     * @return the url that was entered
+     */
+    public String commitEdit() {
+        final String url = stopEditing();
+        if (!TextUtils.isEmpty(url)) {
+            setTitle(url);
+        }
+        return url;
+    }
+
+    private String stopEditing() {
         final String url = mUrlEditText.getText().toString();
-
         if (!isEditing()) {
             return url;
         }
 
-        // Update the title with the url that was just entered. Don't update the title if
-        // the AwesomeBar activity was cancelled, or if the user entered an empty string.
-        if (url != null && url.length() > 0) {
-            setTitle(url);
-        }
-
         hideUrlEditContainer();
 
         if (HardwareUtils.isTablet()) {
             mLayout.setSelected(false);
             updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
             return url;
         }