Bug 1532613 - Enter editing mode after new "about:home" tab was added; r=AndreiLazar
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 08 Mar 2019 15:13:55 +0000
changeset 521251 0d7f08e68f75
parent 521250 f3eb6ce8dc44
child 521252 ed23415c6ea0
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersAndreiLazar
bugs1532613
milestone67.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 1532613 - Enter editing mode after new "about:home" tab was added; r=AndreiLazar We'll delay entering editing mode until we are sure the process for adding a new "about:home" tab completed. This allows avoiding certain race conditions with the previous state or with the tab counter animation. Differential Revision: https://phabricator.services.mozilla.com/D22701
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
@@ -183,16 +183,17 @@ import java.util.List;
 import java.util.Locale;
 import java.util.regex.Pattern;
 
 import static org.mozilla.gecko.Tabs.LOADURL_DELAY_LOAD;
 import static org.mozilla.gecko.Tabs.LOADURL_EXTERNAL;
 import static org.mozilla.gecko.Tabs.LOADURL_PINNED;
 import static org.mozilla.gecko.Tabs.LOADURL_START_EDITING;
 import static org.mozilla.gecko.Tabs.TabEvents.LOADED;
+import static org.mozilla.gecko.Tabs.TabEvents.THUMBNAIL;
 import static org.mozilla.gecko.mma.MmaDelegate.INTERACT_WITH_SEARCH_WIDGET_URL_AREA;
 import static org.mozilla.gecko.mma.MmaDelegate.NEW_TAB;
 import static org.mozilla.gecko.search.SearchWidgetProvider.INPUT_TYPE_KEY;
 import static org.mozilla.gecko.util.JavaUtil.getBundleSizeInBytes;
 
 public class BrowserApp extends GeckoApp
                         implements ActionModePresenter,
                                    AnchoredPopup.OnVisibilityChangeListener,
@@ -905,32 +906,29 @@ public class BrowserApp extends GeckoApp
             default:
                 // Can't handle this input type, where did it came from though?
                 Log.e(LOGTAG, "can't handle search action :: input == " + input);
                 return false;
         }
     }
 
     private synchronized void handleTabEditingMode(boolean isVoice) {
-        Tab tab = Tabs.getInstance().getLastTabForUrl("about:home");
-
-        if (tab == null) {
-            final Tabs.OnTabsChangedListener tabsChangedListener = new Tabs.OnTabsChangedListener() {
-                @Override
-                public void onTabChanged(Tab tab, TabEvents msg, String data) {
-                    if (tab != null && tab.getURL().equals("about:home") && LOADED.equals(msg)) {
-                        selectTabAndEnterEditingMode(tab.getId(), isVoice);
-                        Tabs.unregisterOnTabsChangedListener(this);
-                    }
+        final Tabs.OnTabsChangedListener tabsChangedListener = new Tabs.OnTabsChangedListener() {
+            @Override
+            public void onTabChanged(Tab tab, TabEvents msg, String data) {
+                // Listening for THUMBNAIL, while entailing a small delay
+                // allows for fully loading the "about:home" screen and finishing all related operations
+                // so that we can safely enter editing mode.
+                if (tab != null && tab.getURL().equals("about:home") && (THUMBNAIL.equals(msg))) {
+                    selectTabAndEnterEditingMode(tab.getId(), isVoice);
+                    Tabs.unregisterOnTabsChangedListener(this);
                 }
-            };
-            Tabs.registerOnTabsChangedListener(tabsChangedListener);
-        } else {
-            selectTabAndEnterEditingMode(tab.getId(), isVoice);
-        }
+            }
+        };
+        Tabs.registerOnTabsChangedListener(tabsChangedListener);
     }
 
     private void selectTabAndEnterEditingMode(int tabId, boolean isVoice) {
         Tabs.getInstance().selectTab(tabId);
         enterEditingMode();
         if (isVoice) {
             mBrowserToolbar.launchVoiceRecognizer();
         }