Bug 1533361 - Force about:home startup tab if the app was opened from the search widget; r=AndreiLazar
authorPetru Lingurar <petru.lingurar@softvision.ro>
Mon, 11 Mar 2019 13:18:06 +0000
changeset 521376 c97ec09c6d152ae6401554b1d55e39b928cc74dd
parent 521375 51fc0fd585a790cf89ed7a4e712f6805a110dc8c
child 521377 034dbb475f6dc7bb2f839a6ead75d4fd0abf8e2a
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersAndreiLazar
bugs1533361
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 1533361 - Force about:home startup tab if the app was opened from the search widget; r=AndreiLazar If the app was started from the search widget we need to always load about:home and not the homepage which the user may have set to be another address. Differential Revision: https://phabricator.services.mozilla.com/D22948
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -881,19 +881,17 @@ public class BrowserApp extends GeckoApp
 
     /**
      * This method is used in order to check if an intent came from {@link SearchWidgetProvider}
      * and handle it accordingly.
      * @param intent to be checked and handled
      * @return True if the intent could be handled
      */
     private boolean handleSearchWidgetIntent(Intent intent) {
-        SearchWidgetProvider.InputType input = (SearchWidgetProvider.InputType) (intent == null ?
-                safeStartingIntent.getUnsafe().getSerializableExtra(INPUT_TYPE_KEY) :
-                intent.getSerializableExtra(INPUT_TYPE_KEY));
+        SearchWidgetProvider.InputType input = getWidgetInputType(intent);
 
         if (input == null) {
             return false;
         }
 
         MmaDelegate.track(INTERACT_WITH_SEARCH_WIDGET_URL_AREA);
 
         switch (input) {
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -14,16 +14,17 @@ import org.mozilla.gecko.health.HealthRe
 import org.mozilla.gecko.health.SessionInformation;
 import org.mozilla.gecko.health.StubbedHealthRecorder;
 import org.mozilla.gecko.home.HomeConfig.PanelType;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuInflater;
 import org.mozilla.gecko.menu.MenuPanel;
 import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.notifications.NotificationHelper;
+import org.mozilla.gecko.search.SearchWidgetProvider;
 import org.mozilla.gecko.util.IntentUtils;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.permissions.Permissions;
 import org.mozilla.gecko.preferences.ClearOnShutdownPref;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.prompts.PromptService;
 import org.mozilla.gecko.restrictions.Restrictions;
@@ -1451,23 +1452,31 @@ public abstract class GeckoApp extends G
 
             alphaAnimator.start();
         }
     }
 
     /**
      * Loads the initial tab at Fennec startup. If we don't restore tabs, this
      * tab will be about:home, or the homepage if the user has set one.
+     * If the app was started from the search widget we need to always load about:home
+     * and not the homepage which the user may have set to be another address.
      * If we've temporarily disabled restoring to break out of a crash loop, we'll show
      * the Recent Tabs folder of the Combined History panel, so the user can manually
      * restore tabs as needed.
      * If we restore tabs, we don't need to create a new tab, unless launch intent specify action
      * to be #android.Intent.ACTION_VIEW, which is launched from widget to create a new tab.
      */
     protected void loadStartupTab(final int flags, String action) {
+        final SearchWidgetProvider.InputType input = getWidgetInputType(getIntent());
+        if (input != null) {
+            Tabs.getInstance().loadUrl("about:home", flags);
+            return;
+        }
+
         if (!mShouldRestore || Intent.ACTION_VIEW.equals(action)) {
             if (mLastSessionCrashed) {
                 // The Recent Tabs panel no longer exists, but BrowserApp will redirect us
                 // to the Recent Tabs folder of the Combined History panel.
                 Tabs.getInstance().loadUrl(AboutPages.getURLForBuiltinPanelType(PanelType.DEPRECATED_RECENT_TABS), flags);
             } else {
                 Tabs.getInstance().loadUrl(Tabs.getHomepageForStartupTab(this), flags);
             }
@@ -1487,16 +1496,24 @@ public abstract class GeckoApp extends G
         if (url == null) {
             loadStartupTab(flags, intent.getAction());
             return;
         }
 
         Tabs.getInstance().loadUrlWithIntentExtras(url, intent, flags);
     }
 
+    protected SearchWidgetProvider.InputType getWidgetInputType(final Intent intent) {
+        final Intent searchIntent = intent != null ? intent : getIntent();
+        if (searchIntent == null) {
+            return null;
+        }
+        return (SearchWidgetProvider.InputType) searchIntent.getSerializableExtra(SearchWidgetProvider.INPUT_TYPE_KEY);
+    }
+
     protected String getIntentURI(SafeIntent intent) {
         final String passedUri;
         final String uri = getURIFromIntent(intent);
 
         if (!TextUtils.isEmpty(uri)) {
             passedUri = uri;
         } else {
             passedUri = null;