From 53cf8e265ccc0961c1638e11b25547015c70b15a Mon Sep 17 00:00:00 2001 From: Jan Henning Date: Fri, 3 Mar 2017 19:05:49 +0100 Subject: [PATCH] Bug 743662 - Restore session once when addons require a restart. r=sebastian MozReview-Commit-ID: C5Q9cYnxnhj --HG-- extra : rebase_source : 3f50c6a4a207e7950dd9eeaaf089fbeac078d627 --- mobile/android/app/mobile.js | 1 - .../base/java/org/mozilla/gecko/GeckoApp.java | 12 +++++++++++- .../mozilla/gecko/preferences/GeckoPreferences.java | 1 + mobile/android/chrome/content/browser.js | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index a591c5c9bcca..e59ebeaaa027 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -137,7 +137,6 @@ pref("browser.sessionhistory.contentViewerTimeout", 360); pref("browser.sessionhistory.bfcacheIgnoreMemoryPressure", false); /* session store */ -pref("browser.sessionstore.resume_session_once", false); pref("browser.sessionstore.resume_from_crash", true); pref("browser.sessionstore.interval", 10000); // milliseconds pref("browser.sessionstore.backupInterval", 120000); // milliseconds -> 2 minutes diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java index 47924bfc063d..09b7fe64f365 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java @@ -1891,7 +1891,9 @@ public abstract class GeckoApp boolean shouldRestore = false; final int versionCode = getVersionCode(); - if (mLastSessionCrashed) { + if (getSessionRestoreResumeOnce(prefs)) { + shouldRestore = true; + } else if (mLastSessionCrashed) { if (incrementCrashCount(prefs) <= getSessionStoreMaxCrashResumes(prefs) && getSessionRestoreAfterCrashPreference(prefs)) { shouldRestore = true; @@ -1914,6 +1916,14 @@ public abstract class GeckoApp return shouldRestore; } + private boolean getSessionRestoreResumeOnce(SharedPreferences prefs) { + boolean resumeOnce = prefs.getBoolean(GeckoPreferences.PREFS_RESTORE_SESSION_ONCE, false); + if (resumeOnce) { + prefs.edit().putBoolean(GeckoPreferences.PREFS_RESTORE_SESSION_ONCE, false).apply(); + } + return resumeOnce; + } + private int incrementCrashCount(SharedPreferences prefs) { final int crashCount = getSuccessiveCrashesCount(prefs) + 1; prefs.edit().putInt(PREFS_CRASHED_COUNT, crashCount).apply(); diff --git a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java index 216a96885050..6b8ac04dd29d 100644 --- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java +++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java @@ -184,6 +184,7 @@ public class GeckoPreferences public static final String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3"; public static final String PREFS_RESTORE_SESSION_FROM_CRASH = "browser.sessionstore.resume_from_crash"; public static final String PREFS_RESTORE_SESSION_MAX_CRASH_RESUMES = "browser.sessionstore.max_resumed_crashes"; + public static final String PREFS_RESTORE_SESSION_ONCE = "browser.sessionstore.resume_session_once"; public static final String PREFS_TAB_QUEUE = NON_PREF_PREFIX + "tab_queue"; public static final String PREFS_TAB_QUEUE_LAST_SITE = NON_PREF_PREFIX + "last_site"; public static final String PREFS_TAB_QUEUE_LAST_TIME = NON_PREF_PREFIX + "last_time"; diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 086dd13e828e..b8537aeabd4f 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -5540,6 +5540,7 @@ var XPInstallObserver = { // If nothing aborted, quit the app if (cancelQuit.data == false) { Services.obs.notifyObservers(null, "quit-application-proceeding", null); + SharedPreferences.forApp().setBoolPref("browser.sessionstore.resume_session_once", true); let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit); }