Issue #991 Part 2: Basilisk

This commit is contained in:
Ascrod 2019-04-08 19:58:00 -04:00 • committed by Roy Tam
commit 5d978c380c
13 changed files with 30 additions and 126 deletions

View file

@ -275,7 +275,6 @@ var gSyncUI = {
openPreferences("paneSync"); openPreferences("paneSync");
}, },
// Helpers // Helpers
_updateLastSyncTime: function SUI__updateLastSyncTime() { _updateLastSyncTime: function SUI__updateLastSyncTime() {
if (!gBrowser) if (!gBrowser)

View file

@ -2594,15 +2594,9 @@ var gMenuButtonUpdateBadge = {
cancelObserverRegistered: false, cancelObserverRegistered: false,
init: function () { init: function () {
try { this.enabled = Services.prefs.getBoolPref("app.update.badge", false);
this.enabled = Services.prefs.getBoolPref("app.update.badge");
} catch (e) {}
if (this.enabled) { if (this.enabled) {
try { this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime", 345600); // 4 days
this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime");
} catch (e) {
this.badgeWaitTime = 345600; // 4 days
}
Services.obs.addObserver(this, "update-staged", false); Services.obs.addObserver(this, "update-staged", false);
Services.obs.addObserver(this, "update-downloaded", false); Services.obs.addObserver(this, "update-downloaded", false);
} }

View file

@ -4151,11 +4151,7 @@
return true; return true;
if (this._logInit) if (this._logInit)
return this._shouldLog; return this._shouldLog;
let result = false; let result = Services.prefs.getBoolPref("browser.tabs.remote.logSwitchTiming", false);
try {
result = Services.prefs.getBoolPref("browser.tabs.remote.logSwitchTiming");
} catch (ex) {
}
this._shouldLog = result; this._shouldLog = result;
this._logInit = true; this._logInit = true;
return this._shouldLog; return this._shouldLog;
@ -5225,11 +5221,7 @@
window.addEventListener("resize", this, false); window.addEventListener("resize", this, false);
window.addEventListener("load", this, false); window.addEventListener("load", this, false);
try { this._tabAnimationLoggingEnabled = Services.prefs.getBoolPref("browser.tabs.animationLogging.enabled", false);
this._tabAnimationLoggingEnabled = Services.prefs.getBoolPref("browser.tabs.animationLogging.enabled");
} catch (ex) {
this._tabAnimationLoggingEnabled = false;
}
this._browserNewtabpageEnabled = Services.prefs.getBoolPref("browser.newtabpage.enabled"); this._browserNewtabpageEnabled = Services.prefs.getBoolPref("browser.newtabpage.enabled");
]]> ]]>
</constructor> </constructor>

View file

@ -158,10 +158,7 @@ var gUIStateBeforeReset = {
XPCOMUtils.defineLazyGetter(this, "log", () => { XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {}; let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope); Cu.import("resource://gre/modules/Console.jsm", scope);
let debug; let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
try {
debug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
} catch (ex) {}
let consoleOptions = { let consoleOptions = {
maxLogLevel: debug ? "all" : "log", maxLogLevel: debug ? "all" : "log",
prefix: "CustomizableUI", prefix: "CustomizableUI",
@ -1924,16 +1921,10 @@ var CustomizableUIInternal = {
// state immediately when a browser window opens, which is important for // state immediately when a browser window opens, which is important for
// other consumers of this API. // other consumers of this API.
loadSavedState: function() { loadSavedState: function() {
let state = null; let state = Services.prefs.getCharPref(kPrefCustomizationState, "");
try {
state = Services.prefs.getCharPref(kPrefCustomizationState);
} catch (e) {
log.debug("No saved state found");
// This will fail if nothing has been customized, so silently fall back to
// the defaults.
}
if (!state) { if (!state) {
log.debug("No saved state found");
// Nothing has been customized, so silently fall back to the defaults.
return; return;
} }
try { try {
@ -2218,10 +2209,7 @@ var CustomizableUIInternal = {
this.notifyListeners("onWidgetAdded", widget.id, widget.currentArea, this.notifyListeners("onWidgetAdded", widget.id, widget.currentArea,
widget.currentPosition); widget.currentPosition);
} else if (widgetMightNeedAutoAdding) { } else if (widgetMightNeedAutoAdding) {
let autoAdd = true; let autoAdd = Services.prefs.getBoolPref(kPrefCustomizationAutoAdd, true);
try {
autoAdd = Services.prefs.getBoolPref(kPrefCustomizationAutoAdd);
} catch (e) {}
// If the widget doesn't have an existing placement, and it hasn't been // If the widget doesn't have an existing placement, and it hasn't been
// seen before, then add it to its default area so it can be used. // seen before, then add it to its default area so it can be used.

View file

@ -40,10 +40,7 @@ const kWidePanelItemClass = "panel-wide-item";
XPCOMUtils.defineLazyGetter(this, "log", () => { XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {}; let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope); Cu.import("resource://gre/modules/Console.jsm", scope);
let debug; let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
try {
debug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
} catch (ex) {}
let consoleOptions = { let consoleOptions = {
maxLogLevel: debug ? "all" : "log", maxLogLevel: debug ? "all" : "log",
prefix: "CustomizableWidgets", prefix: "CustomizableWidgets",

View file

@ -40,9 +40,7 @@ let gDebug;
XPCOMUtils.defineLazyGetter(this, "log", () => { XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {}; let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope); Cu.import("resource://gre/modules/Console.jsm", scope);
try { gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
} catch (ex) {}
let consoleOptions = { let consoleOptions = {
maxLogLevel: gDebug ? "all" : "log", maxLogLevel: gDebug ? "all" : "log",
prefix: "CustomizeMode", prefix: "CustomizeMode",
@ -1503,10 +1501,7 @@ CustomizeMode.prototype = {
if (!AppConstants.CAN_DRAW_IN_TITLEBAR) { if (!AppConstants.CAN_DRAW_IN_TITLEBAR) {
return; return;
} }
let drawInTitlebar = true; let drawInTitlebar = Services.prefs.getBoolPref(kDrawInTitlebarPref, true);
try {
drawInTitlebar = Services.prefs.getBoolPref(kDrawInTitlebarPref);
} catch (ex) { }
let button = this.document.getElementById("customization-titlebar-visibility-button"); let button = this.document.getElementById("customization-titlebar-visibility-button");
// Drawing in the titlebar means 'hiding' the titlebar: // Drawing in the titlebar means 'hiding' the titlebar:
if (drawInTitlebar) { if (drawInTitlebar) {

View file

@ -22,10 +22,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
this.DistributionCustomizer = function DistributionCustomizer() { this.DistributionCustomizer = function DistributionCustomizer() {
// For parallel xpcshell testing purposes allow loading the distribution.ini // For parallel xpcshell testing purposes allow loading the distribution.ini
// file from the profile folder through an hidden pref. // file from the profile folder through an hidden pref.
let loadFromProfile = false; loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile", false);
try {
loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile");
} catch (ex) {}
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]. let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties); getService(Ci.nsIProperties);
try { try {
@ -60,13 +57,7 @@ DistributionCustomizer.prototype = {
}, },
get _locale() { get _locale() {
let locale; let locale = this._prefs.getCharPref("general.useragent.locale", "en-US");
try {
locale = this._prefs.getCharPref("general.useragent.locale");
}
catch (e) {
locale = "en-US";
}
this.__defineGetter__("_locale", () => locale); this.__defineGetter__("_locale", () => locale);
return this._locale; return this._locale;
}, },
@ -291,11 +282,7 @@ DistributionCustomizer.prototype = {
this._ini.getString("Global", "id") + ".bookmarksProcessed"; this._ini.getString("Global", "id") + ".bookmarksProcessed";
} }
let bmProcessed = false; let bmProcessed = this._prefs.getBoolPref(bmProcessedPref, false);
try {
bmProcessed = this._prefs.getBoolPref(bmProcessedPref);
}
catch (e) {}
if (!bmProcessed) { if (!bmProcessed) {
if (sections["BookmarksMenu"]) if (sections["BookmarksMenu"])

View file

@ -19,12 +19,7 @@ function LOG(str) {
let prefB = Cc["@mozilla.org/preferences-service;1"]. let prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch); getService(Ci.nsIPrefBranch);
let shouldLog = false; let shouldLog = prefB.getBoolPref("feeds.log", false);
try {
shouldLog = prefB.getBoolPref("feeds.log");
}
catch (ex) {
}
if (shouldLog) if (shouldLog)
dump("*** Feeds: " + str + "\n"); dump("*** Feeds: " + str + "\n");

View file

@ -187,13 +187,8 @@ const Utils = {
// check if it is in the black list // check if it is in the black list
let pb = Services.prefs; let pb = Services.prefs;
let allowed; let allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol,
try { pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default"));
allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol);
}
catch (e) {
allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default");
}
if (!allowed) { if (!allowed) {
throw this.getSecurityError( throw this.getSecurityError(
`Not allowed to register a protocol handler for ${aProtocol}`, `Not allowed to register a protocol handler for ${aProtocol}`,

View file

@ -100,20 +100,14 @@ const OVERRIDE_NEW_BUILD_ID = 3;
* OVERRIDE_NONE otherwise. * OVERRIDE_NONE otherwise.
*/ */
function needHomepageOverride(prefb) { function needHomepageOverride(prefb) {
var savedmstone = null; var savedmstone = prefb.getCharPref("browser.startup.homepage_override.mstone", "");
try {
savedmstone = prefb.getCharPref("browser.startup.homepage_override.mstone");
} catch (e) {}
if (savedmstone == "ignore") if (savedmstone == "ignore")
return OVERRIDE_NONE; return OVERRIDE_NONE;
var mstone = Services.appinfo.platformVersion; var mstone = Services.appinfo.platformVersion;
var savedBuildID = null; var savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID", "");
try {
savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID");
} catch (e) {}
var buildID = Services.appinfo.platformBuildID; var buildID = Services.appinfo.platformBuildID;
@ -489,10 +483,7 @@ nsBrowserContentHandler.prototype = {
// URL if we do end up showing an overridePage. This makes it possible // URL if we do end up showing an overridePage. This makes it possible
// to have the overridePage's content vary depending on the version we're // to have the overridePage's content vary depending on the version we're
// upgrading from. // upgrading from.
let old_mstone = "unknown"; let old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone", "unknown");
try {
old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
} catch (ex) {}
override = needHomepageOverride(prefb); override = needHomepageOverride(prefb);
if (override != OVERRIDE_NONE) { if (override != OVERRIDE_NONE) {
switch (override) { switch (override) {

View file

@ -961,10 +961,7 @@ BrowserGlue.prototype = {
// Offer to reset a user's profile if it hasn't been used for 60 days. // Offer to reset a user's profile if it hasn't been used for 60 days.
const OFFER_PROFILE_RESET_INTERVAL_MS = 60 * 24 * 60 * 60 * 1000; const OFFER_PROFILE_RESET_INTERVAL_MS = 60 * 24 * 60 * 60 * 1000;
let lastUse = Services.appinfo.replacedLockTime; let lastUse = Services.appinfo.replacedLockTime;
let disableResetPrompt = false; let disableResetPrompt = Services.prefs.getBoolPref("browser.disableResetPrompt", false);
try {
disableResetPrompt = Services.prefs.getBoolPref("browser.disableResetPrompt");
} catch (e) {}
if (!disableResetPrompt && lastUse && if (!disableResetPrompt && lastUse &&
Date.now() - lastUse >= OFFER_PROFILE_RESET_INTERVAL_MS) { Date.now() - lastUse >= OFFER_PROFILE_RESET_INTERVAL_MS) {
@ -1505,10 +1502,7 @@ BrowserGlue.prototype = {
} catch (ex) {} } catch (ex) {}
// Support legacy bookmarks.html format for apps that depend on that format. // Support legacy bookmarks.html format for apps that depend on that format.
let autoExportHTML = false; let autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML", false); // Do not export.
try {
autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
} catch (ex) {} // Do not export.
if (autoExportHTML) { if (autoExportHTML) {
// Sqlite.jsm and Places shutdown happen at profile-before-change, thus, // Sqlite.jsm and Places shutdown happen at profile-before-change, thus,
// to be on the safe side, this should run earlier. // to be on the safe side, this should run earlier.
@ -1578,10 +1572,7 @@ BrowserGlue.prototype = {
// An import operation is about to run. // An import operation is about to run.
// Don't try to recreate smart bookmarks if autoExportHTML is true or // Don't try to recreate smart bookmarks if autoExportHTML is true or
// smart bookmarks are disabled. // smart bookmarks are disabled.
let smartBookmarksVersion = 0; let smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion", 0);
try {
smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
} catch (ex) {}
if (!autoExportHTML && smartBookmarksVersion != -1) if (!autoExportHTML && smartBookmarksVersion != -1)
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0); Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
@ -1932,10 +1923,7 @@ BrowserGlue.prototype = {
// Refactor urlbar suggestion preferences to make it extendable and // Refactor urlbar suggestion preferences to make it extendable and
// allow new suggestion types (e.g: search suggestions). // allow new suggestion types (e.g: search suggestions).
let types = ["history", "bookmark", "openpage"]; let types = ["history", "bookmark", "openpage"];
let defaultBehavior = 0; let defaultBehavior = Services.prefs.getIntPref("browser.urlbar.default.behavior", 0);
try {
defaultBehavior = Services.prefs.getIntPref("browser.urlbar.default.behavior");
} catch (ex) {}
try { try {
let autocompleteEnabled = Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"); let autocompleteEnabled = Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled");
if (!autocompleteEnabled) { if (!autocompleteEnabled) {
@ -1988,12 +1976,8 @@ BrowserGlue.prototype = {
if (currentUIVersion < 30) { if (currentUIVersion < 30) {
// Convert old devedition theme pref to lightweight theme storage // Convert old devedition theme pref to lightweight theme storage
let lightweightThemeSelected = false; let lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID", false);
let selectedThemeID = null; let selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID", "");
try {
lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID");
selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID");
} catch (e) {}
let defaultThemeSelected = false; let defaultThemeSelected = false;
try { try {
@ -2143,10 +2127,7 @@ BrowserGlue.prototype = {
const MAX_RESULTS = 10; const MAX_RESULTS = 10;
// Get current smart bookmarks version. If not set, create them. // Get current smart bookmarks version. If not set, create them.
let smartBookmarksCurrentVersion = 0; let smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF, 0);
try {
smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF);
} catch (ex) {}
// If version is current, or smart bookmarks are disabled, bail out. // If version is current, or smart bookmarks are disabled, bail out.
if (smartBookmarksCurrentVersion == -1 || if (smartBookmarksCurrentVersion == -1 ||

View file

@ -254,13 +254,7 @@ var RemoteTabViewer = {
_refetchTabs: function(force) { _refetchTabs: function(force) {
if (!force) { if (!force) {
// Don't bother refetching tabs if we already did so recently // Don't bother refetching tabs if we already did so recently
let lastFetch = 0; lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch", 0);
try {
lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch");
}
catch (e) {
/* Just use the default value of 0 */
}
let now = Math.floor(Date.now() / 1000); let now = Math.floor(Date.now() / 1000);
if (now - lastFetch < 30) { if (now - lastFetch < 30) {

View file

@ -189,11 +189,7 @@ var DirectoryLinksProvider = {
* @return the selected locale or "en-US" if none is selected * @return the selected locale or "en-US" if none is selected
*/ */
get locale() { get locale() {
let matchOS; let matchOS = Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE, false);
try {
matchOS = Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE);
}
catch (e) {}
if (matchOS) { if (matchOS) {
return Services.locale.getLocaleComponentForUserAgent(); return Services.locale.getLocaleComponentForUserAgent();