mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1078085 - Simplify preference checking code in the newtab preloader r=gijs
This commit is contained in:
parent
c30ec7b70c
commit
973f75a6c8
@ -7,8 +7,6 @@
|
||||
const PREF_INTRO_SHOWN = "browser.newtabpage.introShown";
|
||||
|
||||
let gIntro = {
|
||||
_introShown: Services.prefs.getBoolPref(PREF_INTRO_SHOWN),
|
||||
|
||||
_nodeIDSuffixes: [
|
||||
"panel",
|
||||
"what",
|
||||
@ -26,7 +24,7 @@ let gIntro = {
|
||||
},
|
||||
|
||||
showIfNecessary: function() {
|
||||
if (!this._introShown) {
|
||||
if (!Services.prefs.getBoolPref(PREF_INTRO_SHOWN)) {
|
||||
Services.prefs.setBoolPref(PREF_INTRO_SHOWN, true);
|
||||
this.showPanel();
|
||||
}
|
||||
|
@ -507,7 +507,6 @@ BrowserGlue.prototype = {
|
||||
NewTabUtils.init();
|
||||
DirectoryLinksProvider.init();
|
||||
NewTabUtils.links.addProvider(DirectoryLinksProvider);
|
||||
BrowserNewTabPreloader.init();
|
||||
#ifdef NIGHTLY_BUILD
|
||||
if (Services.prefs.getBoolPref("dom.identity.enabled")) {
|
||||
SignInToWebsiteUX.init();
|
||||
|
@ -18,7 +18,9 @@ const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const XUL_PAGE = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window%20id='win'/>";
|
||||
const NEWTAB_URL = "about:newtab";
|
||||
const PREF_BRANCH = "browser.newtab.";
|
||||
|
||||
const PREF_NEWTAB_URL = "browser.newtab.url";
|
||||
const PREF_NEWTAB_PRELOAD = "browser.newtab.preload";
|
||||
|
||||
// The interval between swapping in a preload docShell and kicking off the
|
||||
// next preload in the background.
|
||||
@ -34,6 +36,11 @@ const TOPIC_XUL_WINDOW_CLOSED = "xul-window-destroyed";
|
||||
|
||||
const BROWSER_CONTENT_SCRIPT = "chrome://browser/content/content.js";
|
||||
|
||||
function isPreloadingEnabled() {
|
||||
return Services.prefs.getBoolPref(PREF_NEWTAB_PRELOAD) &&
|
||||
!Services.prefs.prefHasUserValue(PREF_NEWTAB_URL);
|
||||
}
|
||||
|
||||
function createTimer(obj, delay) {
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
timer.init(obj, delay, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
@ -48,18 +55,13 @@ function clearTimer(timer) {
|
||||
}
|
||||
|
||||
this.BrowserNewTabPreloader = {
|
||||
init: function Preloader_init() {
|
||||
Preferences.init();
|
||||
},
|
||||
|
||||
uninit: function Preloader_uninit() {
|
||||
HostFrame.destroy();
|
||||
Preferences.uninit();
|
||||
HiddenBrowsers.uninit();
|
||||
},
|
||||
|
||||
newTab: function Preloader_newTab(aTab) {
|
||||
if (!Preferences.enabled) {
|
||||
if (!isPreloadingEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -81,41 +83,6 @@ this.BrowserNewTabPreloader = {
|
||||
|
||||
Object.freeze(BrowserNewTabPreloader);
|
||||
|
||||
let Preferences = {
|
||||
_enabled: null,
|
||||
_branch: null,
|
||||
|
||||
get enabled() {
|
||||
if (this._enabled === null) {
|
||||
this._enabled = this._branch.getBoolPref("preload") &&
|
||||
!this._branch.prefHasUserValue("url");
|
||||
}
|
||||
|
||||
return this._enabled;
|
||||
},
|
||||
|
||||
init: function Preferences_init() {
|
||||
this._branch = Services.prefs.getBranch(PREF_BRANCH);
|
||||
this._branch.addObserver("", this, false);
|
||||
},
|
||||
|
||||
uninit: function Preferences_uninit() {
|
||||
if (this._branch) {
|
||||
this._branch.removeObserver("", this);
|
||||
this._branch = null;
|
||||
}
|
||||
},
|
||||
|
||||
observe: function Preferences_observe() {
|
||||
let prevEnabled = this._enabled;
|
||||
this._enabled = null;
|
||||
|
||||
if (prevEnabled && !this.enabled) {
|
||||
HiddenBrowsers.uninit();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let HiddenBrowsers = {
|
||||
_browsers: null,
|
||||
_updateTimer: null,
|
||||
|
Loading…
Reference in New Issue
Block a user