Bug 1318663 - Don't skip load start tab during tab restore if incoming action of intent is VIEW with non-external URL. r=sebastian draft
authormaliu <max@mxli.us>
Tue, 29 Nov 2016 02:25:29 +0800
changeset 444737 f16e1aba4af6c22cafb30c9cb2105ba2988a8d02
parent 444478 05328d3102efd4d5fc0696489734d7771d24459f
child 538370 f4a5e69711fe21c3aecc63800d7f4fb8c7114419
push id37344
push userbmo:max@mxli.us
push dateMon, 28 Nov 2016 18:31:28 +0000
reviewerssebastian
bugs1318663
milestone53.0a1
Bug 1318663 - Don't skip load start tab during tab restore if incoming action of intent is VIEW with non-external URL. r=sebastian MozReview-Commit-ID: 4DAYikBnzz2
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1483,20 +1483,21 @@ public abstract class GeckoApp
     }
 
     /**
      * 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 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.
+     * 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) {
-        if (!mShouldRestore) {
+    protected void loadStartupTab(final int flags, String action) {
+        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 {
                 final String homepage = getHomepage();
                 Tabs.getInstance().loadUrl(!TextUtils.isEmpty(homepage) ? homepage : AboutPages.HOME, flags);
             }
@@ -1509,17 +1510,17 @@ public abstract class GeckoApp
      *
      * @param url    External URL to load.
      * @param intent External intent whose extras modify the request
      * @param flags  Flags used to load the load
      */
     protected void loadStartupTab(final String url, final SafeIntent intent, final int flags) {
         // Invalid url
         if (url == null) {
-            loadStartupTab(flags);
+            loadStartupTab(flags, intent.getAction());
             return;
         }
 
         Tabs.getInstance().loadUrlWithIntentExtras(url, intent, flags);
     }
 
     public String getHomepage() {
         return null;
@@ -1591,17 +1592,17 @@ public abstract class GeckoApp
                     if (isFirstTab) {
                         flags |= Tabs.LOADURL_FIRST_AFTER_ACTIVITY_UNHIDDEN;
                     }
                     loadStartupTab(passedUri, intent, flags);
                 }
             });
         } else {
             if (!mIsRestoringActivity) {
-                loadStartupTab(Tabs.LOADURL_NEW_TAB);
+                loadStartupTab(Tabs.LOADURL_NEW_TAB, action);
             }
 
             Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);
 
             processTabQueue();
         }
 
         recordStartupActionTelemetry(passedUri, action);