Bug 1363321 - Part 1 - Always copy crash restore settings to Java on startup. r?jchen draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 10 May 2017 20:20:50 +0200
changeset 575619 7b9f92a892c1677839f7ec17fa1d0052e68c6ced
parent 575614 a117fd795f9fd86e0332c37c93000677d8211fcb
child 575620 c800c7e67ea44df0fbcde06bd0a72dfadb5e5ed6
child 575892 da9bff6d39a0ba304b6b03cbf7cd824634987233
child 575893 0dd99c8cfbdc937f8ac0ff72390c832e2179d96d
push id58132
push usermozilla@buttercookie.de
push dateWed, 10 May 2017 19:04:56 +0000
reviewersjchen
bugs1363321
milestone55.0a1
Bug 1363321 - Part 1 - Always copy crash restore settings to Java on startup. r?jchen Those settings need to be stored in our shared preferences since they're needed before Gecko is available, however in order to allow them to be easily configured, we also expose them in about:config and sync them to the shared prefs via a change listener. This however means that changes in the *default* value of those prefs won't be picked up. Therefore we now simply unconditionally copy the setting state into the shared preferences on startup and omit the change listener instead, as they're exposed in about:config only and there is in fact no pressing need for changes there to immediately take effect. MozReview-Commit-ID: 7c950F1nkdj
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -116,24 +116,20 @@ SessionStore.prototype = {
 
     this._updateMaxTabsUndo();
     Services.prefs.addObserver(PREFS_MAX_TABS_UNDO, () => {
       this._updateMaxTabsUndo();
     });
 
     // Copy changes in Gecko settings to their Java counterparts,
     // so the startup code can access them
-    Services.prefs.addObserver(PREFS_RESTORE_FROM_CRASH, function() {
-      SharedPreferences.forApp().setBoolPref(PREFS_RESTORE_FROM_CRASH,
-        Services.prefs.getBoolPref(PREFS_RESTORE_FROM_CRASH));
-    });
-    Services.prefs.addObserver(PREFS_MAX_CRASH_RESUMES, function() {
-      SharedPreferences.forApp().setIntPref(PREFS_MAX_CRASH_RESUMES,
-        Services.prefs.getIntPref(PREFS_MAX_CRASH_RESUMES));
-    });
+    SharedPreferences.forApp().setBoolPref(PREFS_RESTORE_FROM_CRASH,
+      Services.prefs.getBoolPref(PREFS_RESTORE_FROM_CRASH));
+    SharedPreferences.forApp().setIntPref(PREFS_MAX_CRASH_RESUMES,
+      Services.prefs.getIntPref(PREFS_MAX_CRASH_RESUMES));
   },
 
   _updateMaxTabsUndo: function ss_updateMaxTabsUndo() {
     this._maxTabsUndo = Services.prefs.getIntPref(PREFS_MAX_TABS_UNDO);
     if (this._maxTabsUndo == 0) {
       this._forgetClosedTabs();
     }
   },