Bug 1318663 - Don't skip load start tab during tab restore if incoming action of intent is VIEW with non-external URL. r=JanH,sebastian
authormaliu <max@mxli.us>
Tue, 29 Nov 2016 02:25:29 +0800
changeset 324575 be6f5b8a484e90088ec40f4ae18a5e009e1979ec
parent 324574 6b4ddaf6c2762ba93489f69a28b781abd8e702eb
child 324576 1a5839f86e7936d208929eb2e929f99421ebc871
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersJanH, sebastian
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=JanH,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);