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
--- 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);