--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -13,17 +13,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
var gAdvancedPane = {
_inited: false,
/**
* Brings the appropriate tab to the front and initializes various bits of UI.
*/
- init: function()
+ init()
{
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gAdvancedPane));
}
this._inited = true;
@@ -115,17 +115,17 @@ var gAdvancedPane = {
}, true);
}
},
/**
* Stores the identity of the current tab in preferences so that the selected
* tab can be persisted between openings of the preferences window.
*/
- tabSelectionChanged: function()
+ tabSelectionChanged()
{
if (!this._inited)
return;
var advancedPrefs = document.getElementById("advancedPrefs");
var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
// tabSelectionChanged gets called twice due to the selectedIndex being set
// by both the selectedItem and selectedPanel callstacks. This guard is used
@@ -177,137 +177,137 @@ var gAdvancedPane = {
*/
_storedSpellCheck: 0,
/**
* Returns true if any spellchecking is enabled and false otherwise, caching
* the current value to enable proper pref restoration if the checkbox is
* never changed.
*/
- readCheckSpelling: function()
+ readCheckSpelling()
{
var pref = document.getElementById("layout.spellcheckDefault");
this._storedSpellCheck = pref.value;
return (pref.value != 0);
},
/**
* Returns the value of the spellchecking preference represented by UI,
* preserving the preference's "hidden" value if the preference is
* unchanged and represents a value not strictly allowed in UI.
*/
- writeCheckSpelling: function()
+ writeCheckSpelling()
{
var checkbox = document.getElementById("checkSpelling");
if (checkbox.checked) {
if (this._storedSpellCheck == 2) {
return 2;
}
return 1;
}
return 0;
},
/**
* security.OCSP.enabled is an integer value for legacy reasons.
* A value of 1 means OCSP is enabled. Any other value means it is disabled.
*/
- readEnableOCSP: function()
+ readEnableOCSP()
{
var preference = document.getElementById("security.OCSP.enabled");
// This is the case if the preference is the default value.
if (preference.value === undefined) {
return true;
}
return preference.value == 1;
},
/**
* See documentation for readEnableOCSP.
*/
- writeEnableOCSP: function()
+ writeEnableOCSP()
{
var checkbox = document.getElementById("enableOCSP");
return checkbox.checked ? 1 : 0;
},
/**
* When the user toggles the layers.acceleration.disabled pref,
* sync its new value to the gfx.direct2d.disabled pref too.
*/
- updateHardwareAcceleration: function()
+ updateHardwareAcceleration()
{
if (AppConstants.platform = "win") {
var fromPref = document.getElementById("layers.acceleration.disabled");
var toPref = document.getElementById("gfx.direct2d.disabled");
toPref.value = fromPref.value;
}
},
// DATA CHOICES TAB
/**
* Set up or hide the Learn More links for various data collection options
*/
- _setupLearnMoreLink: function(pref, element) {
+ _setupLearnMoreLink(pref, element) {
// set up the Learn More link with the correct URL
let url = Services.prefs.getCharPref(pref);
let el = document.getElementById(element);
if (url) {
el.setAttribute("href", url);
} else {
el.setAttribute("hidden", "true");
}
},
/**
*
*/
- initSubmitCrashes: function()
+ initSubmitCrashes()
{
this._setupLearnMoreLink("toolkit.crashreporter.infoURL",
"crashReporterLearnMore");
},
/**
* The preference/checkbox is configured in XUL.
*
* In all cases, set up the Learn More link sanely.
*/
- initTelemetry: function()
+ initTelemetry()
{
if (AppConstants.MOZ_TELEMETRY_REPORTING) {
this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
}
},
/**
* Set the status of the telemetry controls based on the input argument.
* @param {Boolean} aEnabled False disables the controls, true enables them.
*/
- setTelemetrySectionEnabled: function(aEnabled)
+ setTelemetrySectionEnabled(aEnabled)
{
if (AppConstants.MOZ_TELEMETRY_REPORTING) {
// If FHR is disabled, additional data sharing should be disabled as well.
let disabled = !aEnabled;
document.getElementById("submitTelemetryBox").disabled = disabled;
if (disabled) {
// If we disable FHR, untick the telemetry checkbox.
Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
}
document.getElementById("telemetryDataDesc").disabled = disabled;
}
},
/**
* Initialize the health report service reference and checkbox.
*/
- initSubmitHealthReport: function() {
+ initSubmitHealthReport() {
if (AppConstants.MOZ_TELEMETRY_REPORTING) {
this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
let checkbox = document.getElementById("submitHealthReportBox");
if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
checkbox.setAttribute("disabled", "true");
return;
@@ -316,17 +316,17 @@ var gAdvancedPane = {
checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
this.setTelemetrySectionEnabled(checkbox.checked);
}
},
/**
* Update the health report preference with state from checkbox.
*/
- updateSubmitHealthReport: function() {
+ updateSubmitHealthReport() {
if (AppConstants.MOZ_TELEMETRY_REPORTING) {
let checkbox = document.getElementById("submitHealthReportBox");
Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
this.setTelemetrySectionEnabled(checkbox.checked);
}
},
updateOnScreenKeyboardVisibility() {
@@ -346,46 +346,46 @@ var gAdvancedPane = {
* browser.cache.disk.capacity
* - the size of the browser cache in KB
* - Only used if browser.cache.disk.smart_size.enabled is disabled
*/
/**
* Displays a dialog in which proxy settings may be changed.
*/
- showConnections: function()
+ showConnections()
{
gSubDialog.open("chrome://browser/content/preferences/connection.xul");
},
- showSiteDataSettings: function() {
+ showSiteDataSettings() {
gSubDialog.open("chrome://browser/content/preferences/siteDataSettings.xul");
},
- updateTotalSiteDataSize: function() {
+ updateTotalSiteDataSize() {
SiteDataManager.getTotalUsage()
.then(usage => {
let size = DownloadUtils.convertByteUnits(usage);
let prefStrBundle = document.getElementById("bundlePreferences");
let totalSiteDataSizeLabel = document.getElementById("totalSiteDataSize");
totalSiteDataSizeLabel.textContent = prefStrBundle.getFormattedString("totalSiteDataSize", size);
let siteDataGroup = document.getElementById("siteDataGroup");
siteDataGroup.hidden = false;
});
},
// Retrieves the amount of space currently used by disk cache
- updateActualCacheSize: function()
+ updateActualCacheSize()
{
var actualSizeLabel = document.getElementById("actualDiskCacheSize");
var prefStrBundle = document.getElementById("bundlePreferences");
// Needs to root the observer since cache service keeps only a weak reference.
this.observer = {
- onNetworkCacheDiskConsumption: function(consumption) {
+ onNetworkCacheDiskConsumption(consumption) {
var size = DownloadUtils.convertByteUnits(consumption);
// The XBL binding for the string bundle may have been destroyed if
// the page was closed before this callback was executed.
if (!prefStrBundle.getFormattedString) {
return;
}
actualSizeLabel.value = prefStrBundle.getFormattedString("actualDiskCacheSize", size);
},
@@ -402,20 +402,20 @@ var gAdvancedPane = {
var cacheService =
Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
cacheService.asyncGetDiskConsumption(this.observer);
} catch (e) {}
},
// Retrieves the amount of space currently used by offline cache
- updateActualAppCacheSize: function()
+ updateActualAppCacheSize()
{
var visitor = {
- onCacheStorageInfo: function(aEntryCount, aConsumption, aCapacity, aDiskDirectory)
+ onCacheStorageInfo(aEntryCount, aConsumption, aCapacity, aDiskDirectory)
{
var actualSizeLabel = document.getElementById("actualAppCacheSize");
var sizeStrings = DownloadUtils.convertByteUnits(aConsumption);
var prefStrBundle = document.getElementById("bundlePreferences");
// The XBL binding for the string bundle may have been destroyed if
// the page was closed before this callback was executed.
if (!prefStrBundle.getFormattedString) {
return;
@@ -429,24 +429,24 @@ var gAdvancedPane = {
var cacheService =
Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
var storage = cacheService.appCacheStorage(LoadContextInfo.default, null);
storage.asyncVisitStorage(visitor, false);
} catch (e) {}
},
- updateCacheSizeUI: function(smartSizeEnabled)
+ updateCacheSizeUI(smartSizeEnabled)
{
document.getElementById("useCacheBefore").disabled = smartSizeEnabled;
document.getElementById("cacheSize").disabled = smartSizeEnabled;
document.getElementById("useCacheAfter").disabled = smartSizeEnabled;
},
- readSmartSizeEnabled: function()
+ readSmartSizeEnabled()
{
// The smart_size.enabled preference element is inverted="true", so its
// value is the opposite of the actual pref value
var disabled = document.getElementById("browser.cache.disk.smart_size.enabled").value;
this.updateCacheSizeUI(!disabled);
},
/**
@@ -475,64 +475,64 @@ var gAdvancedPane = {
// Converts the cache size as specified in UI (in MB) to KB.
let intValue = parseInt(cacheSizeElem.value, 10);
cachePref.value = isNaN(intValue) ? 0 : intValue * 1024;
},
/**
* Clears the cache.
*/
- clearCache: function()
+ clearCache()
{
try {
var cache = Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
cache.clear();
} catch (ex) {}
this.updateActualCacheSize();
},
/**
* Clears the application cache.
*/
- clearOfflineAppCache: function()
+ clearOfflineAppCache()
{
Components.utils.import("resource:///modules/offlineAppCache.jsm");
OfflineAppCacheHelper.clear();
this.updateActualAppCacheSize();
this.updateOfflineApps();
},
- clearSiteData: function() {
+ clearSiteData() {
let flags =
Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 +
Services.prompt.BUTTON_POS_0_DEFAULT;
let prefStrBundle = document.getElementById("bundlePreferences");
let title = prefStrBundle.getString("clearSiteDataPromptTitle");
let text = prefStrBundle.getString("clearSiteDataPromptText");
let btn0Label = prefStrBundle.getString("clearSiteDataNow");
let result = Services.prompt.confirmEx(
window, title, text, flags, btn0Label, null, null, null, {});
if (result == 0) {
SiteDataManager.removeAll();
}
},
- readOfflineNotify: function()
+ readOfflineNotify()
{
var pref = document.getElementById("browser.offline-apps.notify");
var button = document.getElementById("offlineNotifyExceptions");
button.disabled = !pref.value;
return pref.value;
},
- showOfflineExceptions: function()
+ showOfflineExceptions()
{
var bundlePreferences = document.getElementById("bundlePreferences");
var params = { blockVisible : false,
sessionVisible : false,
allowVisible : false,
prefilledHost : "",
permissionType : "offline-app",
manageCapability : Components.interfaces.nsIPermissionManager.DENY_ACTION,
@@ -564,17 +564,17 @@ var gAdvancedPane = {
}
return usage;
},
/**
* Updates the list of offline applications
*/
- updateOfflineApps: function()
+ updateOfflineApps()
{
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var list = document.getElementById("offlineAppsList");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
@@ -605,28 +605,28 @@ var gAdvancedPane = {
row.setAttribute("usage",
bundle.getFormattedString("offlineAppUsage",
converted));
list.appendChild(row);
}
}
},
- offlineAppSelected: function()
+ offlineAppSelected()
{
var removeButton = document.getElementById("offlineAppsListRemove");
var list = document.getElementById("offlineAppsList");
if (list.selectedItem) {
removeButton.setAttribute("disabled", "false");
} else {
removeButton.setAttribute("disabled", "true");
}
},
- removeOfflineApp: function()
+ removeOfflineApp()
{
var list = document.getElementById("offlineAppsList");
var item = list.selectedItem;
var origin = item.getAttribute("origin");
var principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
@@ -697,17 +697,17 @@ var gAdvancedPane = {
*
* Disabled states:
* Element pref value locked disabled
* radiogroup i t/f f false
* i t/f *t* *true*
* ii t/f f false
* ii t/f *t* *true*
*/
- updateReadPrefs: function()
+ updateReadPrefs()
{
if (AppConstants.MOZ_UPDATER) {
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");
if (!enabledPref.value) // Don't care for autoPref.value in this case.
radiogroup.value = "manual"; // 3. Never check for updates.
@@ -743,17 +743,17 @@ var gAdvancedPane = {
}
}
}
},
/**
* Sets the pref values based on the selected item of the radiogroup.
*/
- updateWritePrefs: function()
+ updateWritePrefs()
{
if (AppConstants.MOZ_UPDATER) {
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");
switch (radiogroup.value) {
case "auto": // 1. Automatically install updates for Desktop only
enabledPref.value = true;
@@ -768,17 +768,17 @@ var gAdvancedPane = {
autoPref.value = false;
}
}
},
/**
* Displays the history of installed updates.
*/
- showUpdates: function()
+ showUpdates()
{
gSubDialog.open("chrome://mozapps/content/update/history.xul");
},
// ENCRYPTION TAB
/*
* Preferences:
@@ -790,30 +790,30 @@ var gAdvancedPane = {
* "Ask Every Time" present a dialog to the user so he can select
* the certificate to use on a site which
* requests one
*/
/**
* Displays the user's certificates and associated options.
*/
- showCertificates: function()
+ showCertificates()
{
gSubDialog.open("chrome://pippki/content/certManager.xul");
},
/**
* Displays a dialog from which the user can manage his security devices.
*/
- showSecurityDevices: function()
+ showSecurityDevices()
{
gSubDialog.open("chrome://pippki/content/device_manager.xul");
},
- observe: function(aSubject, aTopic, aData) {
+ observe(aSubject, aTopic, aData) {
if (AppConstants.MOZ_UPDATER) {
switch (aTopic) {
case "nsPref:changed":
this.updateReadPrefs();
break;
case "sitedatamanager:sites-updated":
this.updateTotalSiteDataSize();
--- a/browser/components/preferences/in-content/applications.js
+++ b/browser/components/preferences/in-content/applications.js
@@ -114,21 +114,21 @@ function getLocalHandlerApp(aFile) {
function ArrayEnumerator(aItems) {
this._index = 0;
this._contents = aItems;
}
ArrayEnumerator.prototype = {
_index: 0,
- hasMoreElements: function() {
+ hasMoreElements() {
return this._index < this._contents.length;
},
- getNext: function() {
+ getNext() {
return this._contents[this._index++];
}
};
function isFeedType(t) {
return t == TYPE_MAYBE_FEED || t == TYPE_MAYBE_VIDEO_FEED || t == TYPE_MAYBE_AUDIO_FEED;
}
@@ -167,17 +167,17 @@ HandlerInfoWrapper.prototype = {
getService(Ci.nsIHandlerService),
_prefSvc: Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch),
_categoryMgr: Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager),
- element: function(aID) {
+ element(aID) {
return document.getElementById(aID);
},
// nsIHandlerInfo
// The MIME type or protocol scheme.
_type: null,
@@ -209,26 +209,26 @@ HandlerInfoWrapper.prototype = {
if (aNewValue)
this.addPossibleApplicationHandler(aNewValue)
},
get possibleApplicationHandlers() {
return this.wrappedHandlerInfo.possibleApplicationHandlers;
},
- addPossibleApplicationHandler: function(aNewHandler) {
+ addPossibleApplicationHandler(aNewHandler) {
var possibleApps = this.possibleApplicationHandlers.enumerate();
while (possibleApps.hasMoreElements()) {
if (possibleApps.getNext().equals(aNewHandler))
return;
}
this.possibleApplicationHandlers.appendElement(aNewHandler, false);
},
- removePossibleApplicationHandler: function(aHandler) {
+ removePossibleApplicationHandler(aHandler) {
var defaultApp = this.preferredApplicationHandler;
if (defaultApp && aHandler.equals(defaultApp)) {
// If the app we remove was the default app, we must make sure
// it won't be used anymore
this.alwaysAskBeforeHandling = true;
this.preferredApplicationHandler = null;
}
@@ -357,46 +357,46 @@ HandlerInfoWrapper.prototype = {
// check for the presence of a user-configured record to determine whether
// or not this type is only handled by a plugin. Filed as bug 395142.
handledOnlyByPlugin: undefined,
get isDisabledPluginType() {
return this._getDisabledPluginTypes().indexOf(this.type) != -1;
},
- _getDisabledPluginTypes: function() {
+ _getDisabledPluginTypes() {
var types = "";
if (this._prefSvc.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES))
types = this._prefSvc.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
// Only split if the string isn't empty so we don't end up with an array
// containing a single empty string.
if (types != "")
return types.split(",");
return [];
},
- disablePluginType: function() {
+ disablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
if (disabledPluginTypes.indexOf(this.type) == -1)
disabledPluginTypes.push(this.type);
this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
disabledPluginTypes.join(","));
// Update the category manager so existing browser windows update.
this._categoryMgr.deleteCategoryEntry("Gecko-Content-Viewers",
this.type,
false);
},
- enablePluginType: function() {
+ enablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
var type = this.type;
disabledPluginTypes = disabledPluginTypes.filter(v => v != type);
this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
disabledPluginTypes.join(","));
@@ -407,28 +407,28 @@ HandlerInfoWrapper.prototype = {
"@mozilla.org/content/plugin/document-loader-factory;1",
false,
true);
},
// Storage
- store: function() {
+ store() {
this._handlerSvc.store(this.wrappedHandlerInfo);
},
// Icons
get smallIcon() {
return this._getIcon(16);
},
- _getIcon: function(aSize) {
+ _getIcon(aSize) {
if (this.primaryExtension)
return "moz-icon://goat." + this.primaryExtension + "?size=" + aSize;
if (this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo)
return "moz-icon://goat?size=" + aSize + "&contentType=" + this.type;
// FIXME: consider returning some generic icon when we can't get a URL for
// one (for example in the case of protocol schemes). Filed as bug 395141.
@@ -524,43 +524,43 @@ FeedHandlerInfo.prototype = {
return this._possibleApplicationHandlers;
// A minimal implementation of nsIMutableArray. It only supports the two
// methods its callers invoke, namely appendElement and nsIArray::enumerate.
this._possibleApplicationHandlers = {
_inner: [],
_removed: [],
- QueryInterface: function(aIID) {
+ QueryInterface(aIID) {
if (aIID.equals(Ci.nsIMutableArray) ||
aIID.equals(Ci.nsIArray) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
get length() {
return this._inner.length;
},
- enumerate: function() {
+ enumerate() {
return new ArrayEnumerator(this._inner);
},
- appendElement: function(aHandlerApp, aWeak) {
+ appendElement(aHandlerApp, aWeak) {
this._inner.push(aHandlerApp);
},
- removeElementAt: function(aIndex) {
+ removeElementAt(aIndex) {
this._removed.push(this._inner[aIndex]);
this._inner.splice(aIndex, 1);
},
- queryElementAt: function(aIndex, aInterface) {
+ queryElementAt(aIndex, aInterface) {
return this._inner[aIndex].QueryInterface(aInterface);
}
};
// Add the selected local app if it's different from the OS default handler.
// Unlike for other types, we can store only one local app at a time for the
// feed type, since we store it in a preference that historically stores
// only a single path. But we display all the local apps the user chooses
@@ -720,17 +720,17 @@ FeedHandlerInfo.prototype = {
// Storage
// Changes to the preferred action and handler take effect immediately
// (we write them out to the preferences right as they happen),
// so we when the controller calls store() after modifying the handlers,
// the only thing we need to store is the removal of possible handlers
// XXX Should we hold off on making the changes until this method gets called?
- store: function() {
+ store() {
for (let app of this._possibleApplicationHandlers._removed) {
if (app instanceof Ci.nsILocalHandlerApp) {
let pref = this.element(PREF_FEED_SELECTED_APP);
var preferredAppFile = pref.value;
if (preferredAppFile) {
let preferredApp = getLocalHandlerApp(preferredAppFile);
if (app.equals(preferredApp))
pref.reset();
@@ -795,17 +795,17 @@ function InternalHandlerInfoWrapper(aMIM
HandlerInfoWrapper.call(this, aMIMEType, handlerInfo);
}
InternalHandlerInfoWrapper.prototype = {
__proto__: HandlerInfoWrapper.prototype,
// Override store so we so we can notify any code listening for registration
// or unregistration of this handler.
- store: function() {
+ store() {
HandlerInfoWrapper.prototype.store.call(this);
Services.obs.notifyObservers(null, this._handlerChanged, null);
},
get enabled() {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
@@ -868,17 +868,17 @@ var gApplicationsPane = {
getService(Ci.nsIHandlerService),
_ioSvc : Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService),
// Initialization & Destruction
- init: function() {
+ init() {
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gApplicationsPane));
}
// Initialize shortcuts to some commonly accessed elements & values.
this._brandShortName =
@@ -947,17 +947,17 @@ var gApplicationsPane = {
// Notify observers that the UI is now ready
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService).
notifyObservers(window, "app-handler-pane-loaded", null);
}
setTimeout(_delayedPaneLoad, 0, this);
},
- destroy: function() {
+ destroy() {
window.removeEventListener("unload", this, false);
this._prefSvc.removeObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
this._prefSvc.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_READER, this);
@@ -970,29 +970,29 @@ var gApplicationsPane = {
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
},
// nsISupports
- QueryInterface: function(aIID) {
+ QueryInterface(aIID) {
if (aIID.equals(Ci.nsIObserver) ||
aIID.equals(Ci.nsIDOMEventListener ||
aIID.equals(Ci.nsISupports)))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
// nsIObserver
- observe: function(aSubject, aTopic, aData) {
+ observe(aSubject, aTopic, aData) {
// Rebuild the list when there are changes to preferences that influence
// whether or not to show certain entries in the list.
if (aTopic == "nsPref:changed" && !this._storingAction) {
// These two prefs alter the list of visible types, so we have to rebuild
// that list when they change.
if (aData == PREF_SHOW_PLUGINS_IN_LIST ||
aData == PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS) {
this._rebuildVisibleTypes();
@@ -1003,48 +1003,48 @@ var gApplicationsPane = {
// the view when any of them changes.
this._rebuildView();
}
},
// nsIDOMEventListener
- handleEvent: function(aEvent) {
+ handleEvent(aEvent) {
if (aEvent.type == "unload") {
this.destroy();
}
},
// Composed Model Construction
- _loadData: function() {
+ _loadData() {
this._loadFeedHandler();
this._loadInternalHandlers();
this._loadPluginHandlers();
this._loadApplicationHandlers();
},
- _loadFeedHandler: function() {
+ _loadFeedHandler() {
this._handledTypes[TYPE_MAYBE_FEED] = feedHandlerInfo;
feedHandlerInfo.handledOnlyByPlugin = false;
this._handledTypes[TYPE_MAYBE_VIDEO_FEED] = videoFeedHandlerInfo;
videoFeedHandlerInfo.handledOnlyByPlugin = false;
this._handledTypes[TYPE_MAYBE_AUDIO_FEED] = audioFeedHandlerInfo;
audioFeedHandlerInfo.handledOnlyByPlugin = false;
},
/**
* Load higher level internal handlers so they can be turned on/off in the
* applications menu.
*/
- _loadInternalHandlers: function() {
+ _loadInternalHandlers() {
var internalHandlers = [pdfHandlerInfo];
for (let internalHandler of internalHandlers) {
if (internalHandler.enabled) {
this._handledTypes[internalHandler.type] = internalHandler;
}
}
},
@@ -1061,17 +1061,17 @@ var gApplicationsPane = {
* to know about it even if it isn't enabled, since we're going to give
* the user an option to enable it.
*
* Also note that enabledPlugin does not get updated when
* plugin.disable_full_page_plugin_for_types changes, so even if we could use
* enabledPlugin to get the plugin that would be used, we'd still need to
* check the pref ourselves to find out if it's enabled.
*/
- _loadPluginHandlers: function() {
+ _loadPluginHandlers() {
"use strict";
let mimeTypes = navigator.mimeTypes;
for (let mimeType of mimeTypes) {
let handlerInfoWrapper;
if (mimeType.type in this._handledTypes) {
handlerInfoWrapper = this._handledTypes[mimeType.type];
@@ -1084,17 +1084,17 @@ var gApplicationsPane = {
}
handlerInfoWrapper.pluginName = mimeType.enabledPlugin.name;
}
},
/**
* Load the set of handlers defined by the application datastore.
*/
- _loadApplicationHandlers: function() {
+ _loadApplicationHandlers() {
var wrappedHandlerInfos = this._handlerSvc.enumerate();
while (wrappedHandlerInfos.hasMoreElements()) {
let wrappedHandlerInfo =
wrappedHandlerInfos.getNext().QueryInterface(Ci.nsIHandlerInfo);
let type = wrappedHandlerInfo.type;
let handlerInfoWrapper;
if (type in this._handledTypes)
@@ -1106,17 +1106,17 @@ var gApplicationsPane = {
handlerInfoWrapper.handledOnlyByPlugin = false;
}
},
// View Construction
- _rebuildVisibleTypes: function() {
+ _rebuildVisibleTypes() {
// Reset the list of visible types and the visible type description counts.
this._visibleTypes = [];
this._visibleTypeDescriptionCount = {};
// Get the preferences that help determine what types to show.
var showPlugins = this._prefSvc.getBoolPref(PREF_SHOW_PLUGINS_IN_LIST);
var hidePluginsWithoutExtensions =
this._prefSvc.getBoolPref(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS);
@@ -1145,17 +1145,17 @@ var gApplicationsPane = {
if (handlerInfo.description in this._visibleTypeDescriptionCount)
this._visibleTypeDescriptionCount[handlerInfo.description]++;
else
this._visibleTypeDescriptionCount[handlerInfo.description] = 1;
}
},
- _rebuildView: function() {
+ _rebuildView() {
// Clear the list of entries.
while (this._list.childNodes.length > 1)
this._list.removeChild(this._list.lastChild);
var visibleTypes = this._visibleTypes;
// If the user is filtering the list, then only show matching types.
if (this._filter.value)
@@ -1176,33 +1176,33 @@ var gApplicationsPane = {
}
this._list.appendChild(item);
}
this._selectLastSelectedType();
},
- _matchesFilter: function(aType) {
+ _matchesFilter(aType) {
var filterValue = this._filter.value.toLowerCase();
return this._describeType(aType).toLowerCase().indexOf(filterValue) != -1 ||
this._describePreferredAction(aType).toLowerCase().indexOf(filterValue) != -1;
},
/**
* Describe, in a human-readable fashion, the type represented by the given
* handler info object. Normally this is just the description provided by
* the info object, but if more than one object presents the same description,
* then we annotate the duplicate descriptions with the type itself to help
* users distinguish between those types.
*
* @param aHandlerInfo {nsIHandlerInfo} the type being described
* @returns {string} a description of the type
*/
- _describeType: function(aHandlerInfo) {
+ _describeType(aHandlerInfo) {
if (this._visibleTypeDescriptionCount[aHandlerInfo.description] > 1)
return this._prefsBundle.getFormattedString("typeDescriptionWithType",
[aHandlerInfo.description,
aHandlerInfo.type]);
return aHandlerInfo.description;
},
@@ -1213,17 +1213,17 @@ var gApplicationsPane = {
* XXX Should this be part of the HandlerInfoWrapper interface? It would
* violate the separation of model and view, but it might make more sense
* nonetheless (f.e. it would make sortTypes easier).
*
* @param aHandlerInfo {nsIHandlerInfo} the type whose preferred action
* is being described
* @returns {string} a description of the action
*/
- _describePreferredAction: function(aHandlerInfo) {
+ _describePreferredAction(aHandlerInfo) {
// alwaysAskBeforeHandling overrides the preferred action, so if that flag
// is set, then describe that behavior instead. For most types, this is
// the "alwaysAsk" string, but for the feed type we show something special.
if (aHandlerInfo.alwaysAskBeforeHandling) {
if (isFeedType(aHandlerInfo.type))
return this._prefsBundle.getFormattedString("previewInApp",
[this._brandShortName]);
return this._prefsBundle.getString("alwaysAsk");
@@ -1275,17 +1275,17 @@ var gApplicationsPane = {
return this._prefsBundle.getFormattedString("usePluginIn",
[aHandlerInfo.pluginName,
this._brandShortName]);
default:
throw new Error(`Unexpected preferredAction: ${aHandlerInfo.preferredAction}`);
}
},
- _selectLastSelectedType: function() {
+ _selectLastSelectedType() {
// If the list is disabled by the pref.downloads.disable_button.edit_actions
// preference being locked, then don't select the type, as that would cause
// it to appear selected, with a different background and an actions menu
// that makes it seem like you can choose an action for the type.
if (this._list.disabled)
return;
var lastSelectedType = this._list.getAttribute("lastSelectedType");
@@ -1301,33 +1301,33 @@ var gApplicationsPane = {
/**
* Whether or not the given handler app is valid.
*
* @param aHandlerApp {nsIHandlerApp} the handler app in question
*
* @returns {boolean} whether or not it's valid
*/
- isValidHandlerApp: function(aHandlerApp) {
+ isValidHandlerApp(aHandlerApp) {
if (!aHandlerApp)
return false;
if (aHandlerApp instanceof Ci.nsILocalHandlerApp)
return this._isValidHandlerExecutable(aHandlerApp.executable);
if (aHandlerApp instanceof Ci.nsIWebHandlerApp)
return aHandlerApp.uriTemplate;
if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
return aHandlerApp.uri;
return false;
},
- _isValidHandlerExecutable: function(aExecutable) {
+ _isValidHandlerExecutable(aExecutable) {
let leafName;
if (AppConstants.platform == "win") {
leafName = `${AppConstants.MOZ_APP_NAME}.exe`;
} else if (AppConstants.platform == "macosx") {
leafName = AppConstants.MOZ_MACBUNDLE_NAME;
} else {
leafName = `${AppConstants.MOZ_APP_NAME}-bin`;
}
@@ -1339,17 +1339,17 @@ var gApplicationsPane = {
// XXXmano TBD: can probably add this to nsIShellService
aExecutable.leafName != leafName;
},
/**
* Rebuild the actions menu for the selected entry. Gets called by
* the richlistitem constructor when an entry in the list gets selected.
*/
- rebuildActionsMenu: function() {
+ rebuildActionsMenu() {
var typeItem = this._list.selectedItem;
var handlerInfo = this._handledTypes[typeItem.type];
var menu =
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
var menuPopup = menu.menupopup;
// Clear out existing items.
while (menuPopup.hasChildNodes())
@@ -1534,17 +1534,17 @@ var gApplicationsPane = {
// Sorting & Filtering
_sortColumn: null,
/**
* Sort the list when the user clicks on a column header.
*/
- sort: function(event) {
+ sort(event) {
var column = event.target;
// If the user clicked on a new sort column, remove the direction indicator
// from the old column.
if (this._sortColumn && this._sortColumn != column)
this._sortColumn.removeAttribute("sortDirection");
this._sortColumn = column;
@@ -1557,17 +1557,17 @@ var gApplicationsPane = {
this._sortVisibleTypes();
this._rebuildView();
},
/**
* Sort the list of visible types by the current sort column/direction.
*/
- _sortVisibleTypes: function() {
+ _sortVisibleTypes() {
if (!this._sortColumn)
return;
var t = this;
function sortByType(a, b) {
return t._describeType(a).toLowerCase().
localeCompare(t._describeType(b).toLowerCase());
@@ -1589,40 +1589,40 @@ var gApplicationsPane = {
if (this._sortColumn.getAttribute("sortDirection") == "descending")
this._visibleTypes.reverse();
},
/**
* Filter the list when the user enters a filter term into the filter field.
*/
- filter: function() {
+ filter() {
this._rebuildView();
},
- focusFilterBox: function() {
+ focusFilterBox() {
this._filter.focus();
this._filter.select();
},
// Changes
- onSelectAction: function(aActionItem) {
+ onSelectAction(aActionItem) {
this._storingAction = true;
try {
this._storeAction(aActionItem);
}
finally {
this._storingAction = false;
}
},
- _storeAction: function(aActionItem) {
+ _storeAction(aActionItem) {
var typeItem = this._list.selectedItem;
var handlerInfo = this._handledTypes[typeItem.type];
let action = parseInt(aActionItem.getAttribute("action"));
// Set the plugin state if we're enabling or disabling a plugin.
if (action == kActionUsePlugin)
handlerInfo.enablePluginType();
@@ -1657,17 +1657,17 @@ var gApplicationsPane = {
typeItem.setAttribute("actionDescription",
this._describePreferredAction(handlerInfo));
if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
typeItem.setAttribute("actionIcon",
this._getIconURLForPreferredAction(handlerInfo));
}
},
- manageApp: function(aEvent) {
+ manageApp(aEvent) {
// Don't let the normal "on select action" handler get this event,
// as we handle it specially ourselves.
aEvent.stopPropagation();
var typeItem = this._list.selectedItem;
var handlerInfo = this._handledTypes[typeItem.type];
let onComplete = () => {
@@ -1684,17 +1684,17 @@ var gApplicationsPane = {
}
};
gSubDialog.open("chrome://browser/content/preferences/applicationManager.xul",
"resizable=no", handlerInfo, onComplete);
},
- chooseApp: function(aEvent) {
+ chooseApp(aEvent) {
// Don't let the normal "on select action" handler get this event,
// as we handle it specially ourselves.
aEvent.stopPropagation();
var handlerApp;
let chooseAppCallback = function(aHandlerApp) {
// Rebuild the actions menu whether the user picked an app or canceled.
// If they picked an app, we want to add the app to the menu and select it.
@@ -1772,23 +1772,23 @@ var gApplicationsPane = {
fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
fp.appendFilters(Ci.nsIFilePicker.filterApps);
fp.open(fpCallback);
}
},
// Mark which item in the list was last selected so we can reselect it
// when we rebuild the list or when the user returns to the prefpane.
- onSelectionChanged: function() {
+ onSelectionChanged() {
if (this._list.selectedItem)
this._list.setAttribute("lastSelectedType",
this._list.selectedItem.getAttribute("type"));
},
- _setIconClassForPreferredAction: function(aHandlerInfo, aElement) {
+ _setIconClassForPreferredAction(aHandlerInfo, aElement) {
// If this returns true, the attribute that CSS sniffs for was set to something
// so you shouldn't manually set an icon URI.
// This removes the existing actionIcon attribute if any, even if returning false.
aElement.removeAttribute("actionIcon");
if (aHandlerInfo.alwaysAskBeforeHandling) {
aElement.setAttribute(APP_ICON_ATTR_NAME, "ask");
return true;
@@ -1812,17 +1812,17 @@ var gApplicationsPane = {
case kActionUsePlugin:
aElement.setAttribute(APP_ICON_ATTR_NAME, "plugin");
return true;
}
aElement.removeAttribute(APP_ICON_ATTR_NAME);
return false;
},
- _getIconURLForPreferredAction: function(aHandlerInfo) {
+ _getIconURLForPreferredAction(aHandlerInfo) {
switch (aHandlerInfo.preferredAction) {
case Ci.nsIHandlerInfo.useSystemDefault:
return this._getIconURLForSystemDefault(aHandlerInfo);
case Ci.nsIHandlerInfo.useHelperApp:
let preferredApp = aHandlerInfo.preferredApplicationHandler;
if (this.isValidHandlerApp(preferredApp))
return this._getIconURLForHandlerApp(preferredApp);
@@ -1830,55 +1830,55 @@ var gApplicationsPane = {
// This should never happen, but if preferredAction is set to some weird
// value, then fall back to the generic application icon.
default:
return ICON_URL_APP;
}
},
- _getIconURLForHandlerApp: function(aHandlerApp) {
+ _getIconURLForHandlerApp(aHandlerApp) {
if (aHandlerApp instanceof Ci.nsILocalHandlerApp)
return this._getIconURLForFile(aHandlerApp.executable);
if (aHandlerApp instanceof Ci.nsIWebHandlerApp)
return this._getIconURLForWebApp(aHandlerApp.uriTemplate);
if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
return this._getIconURLForWebApp(aHandlerApp.uri)
// We know nothing about other kinds of handler apps.
return "";
},
- _getIconURLForFile: function(aFile) {
+ _getIconURLForFile(aFile) {
var fph = this._ioSvc.getProtocolHandler("file").
QueryInterface(Ci.nsIFileProtocolHandler);
var urlSpec = fph.getURLSpecFromFile(aFile);
return "moz-icon://" + urlSpec + "?size=16";
},
- _getIconURLForWebApp: function(aWebAppURITemplate) {
+ _getIconURLForWebApp(aWebAppURITemplate) {
var uri = this._ioSvc.newURI(aWebAppURITemplate, null, null);
// Unfortunately we can't use the favicon service to get the favicon,
// because the service looks in the annotations table for a record with
// the exact URL we give it, and users won't have such records for URLs
// they don't visit, and users won't visit the web app's URL template,
// they'll only visit URLs derived from that template (i.e. with %s
// in the template replaced by the URL of the content being handled).
if (/^https?$/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
return uri.prePath + "/favicon.ico";
return "";
},
- _getIconURLForSystemDefault: function(aHandlerInfo) {
+ _getIconURLForSystemDefault(aHandlerInfo) {
// Handler info objects for MIME types on some OSes implement a property bag
// interface from which we can get an icon for the default app, so if we're
// dealing with a MIME type on one of those OSes, then try to get the icon.
if ("wrappedHandlerInfo" in aHandlerInfo) {
let wrappedHandlerInfo = aHandlerInfo.wrappedHandlerInfo;
if (wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
wrappedHandlerInfo instanceof Ci.nsIPropertyBag) {
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -11,17 +11,17 @@ XPCOMUtils.defineLazyGetter(this, "Alert
alertsService.manualDoNotDisturb;
return alertsService;
} catch (ex) {
return undefined;
}
});
var gContentPane = {
- init: function()
+ init()
{
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gContentPane));
}
// Initializes the fonts dropdowns displayed in this pane.
@@ -94,17 +94,17 @@ var gContentPane = {
},
// UTILITY FUNCTIONS
/**
* Utility function to enable/disable the button specified by aButtonID based
* on the value of the Boolean preference specified by aPreferenceID.
*/
- updateButtons: function(aButtonID, aPreferenceID)
+ updateButtons(aButtonID, aPreferenceID)
{
var button = document.getElementById(aButtonID);
var preference = document.getElementById(aPreferenceID);
button.disabled = preference.value != true;
return undefined;
},
// BEGIN UI CODE
@@ -140,49 +140,49 @@ var gContentPane = {
// POP-UPS
/**
* Displays the popup exceptions dialog where specific site popup preferences
* can be set.
*/
- showPopupExceptions: function()
+ showPopupExceptions()
{
var bundlePreferences = document.getElementById("bundlePreferences");
var params = { blockVisible: false, sessionVisible: false, allowVisible: true,
prefilledHost: "", permissionType: "popup" }
params.windowTitle = bundlePreferences.getString("popuppermissionstitle");
params.introText = bundlePreferences.getString("popuppermissionstext");
gSubDialog.open("chrome://browser/content/preferences/permissions.xul",
"resizable=yes", params);
},
// FONTS
/**
* Populates the default font list in UI.
*/
- _rebuildFonts: function()
+ _rebuildFonts()
{
var preferences = document.getElementById("contentPreferences");
// Ensure preferences are "visible" to ensure bindings work.
preferences.hidden = false;
// Force flush:
preferences.clientHeight;
var langGroupPref = document.getElementById("font.language.group");
this._selectDefaultLanguageGroup(langGroupPref.value,
this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif");
},
/**
*
*/
- _selectDefaultLanguageGroup: function(aLanguageGroup, aIsSerif)
+ _selectDefaultLanguageGroup(aLanguageGroup, aIsSerif)
{
const kFontNameFmtSerif = "font.name.serif.%LANG%";
const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%";
const kFontNameListFmtSerif = "font.name-list.serif.%LANG%";
const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%";
const kFontSizeFmtVariable = "font.size.variable.%LANG%";
var preferences = document.getElementById("contentPreferences");
@@ -223,17 +223,17 @@ var gContentPane = {
}
}
},
/**
* Returns the type of the current default font for the language denoted by
* aLanguageGroup.
*/
- _readDefaultFontTypeForLanguage: function(aLanguageGroup)
+ _readDefaultFontTypeForLanguage(aLanguageGroup)
{
const kDefaultFontType = "font.default.%LANG%";
var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup);
var preference = document.getElementById(defaultFontTypePref);
if (!preference) {
preference = document.createElement("preference");
preference.id = defaultFontTypePref;
preference.setAttribute("name", defaultFontTypePref);
@@ -243,52 +243,52 @@ var gContentPane = {
}
return preference.value;
},
/**
* Displays the fonts dialog, where web page font names and sizes can be
* configured.
*/
- configureFonts: function()
+ configureFonts()
{
gSubDialog.open("chrome://browser/content/preferences/fonts.xul", "resizable=no");
},
/**
* Displays the colors dialog, where default web page/link/etc. colors can be
* configured.
*/
- configureColors: function()
+ configureColors()
{
gSubDialog.open("chrome://browser/content/preferences/colors.xul", "resizable=no");
},
// LANGUAGES
/**
* Shows a dialog in which the preferred language for web content may be set.
*/
- showLanguages: function()
+ showLanguages()
{
gSubDialog.open("chrome://browser/content/preferences/languages.xul");
},
/**
* Displays the translation exceptions dialog where specific site and language
* translation preferences can be set.
*/
- showTranslationExceptions: function()
+ showTranslationExceptions()
{
gSubDialog.open("chrome://browser/content/preferences/translation.xul");
},
- openTranslationProviderAttribution: function()
+ openTranslationProviderAttribution()
{
Components.utils.import("resource:///modules/translation/Translation.jsm");
Translation.openProviderAttribution();
},
- toggleDoNotDisturbNotifications: function(event)
+ toggleDoNotDisturbNotifications(event)
{
AlertsServiceDND.manualDoNotDisturb = event.target.checked;
},
};
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -15,17 +15,17 @@ if (AppConstants.E10S_TESTING_ONLY) {
XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm");
}
var gMainPane = {
/**
* Initialization of this.
*/
- init: function()
+ init()
{
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gMainPane));
}
if (AppConstants.HAVE_SHELL_SERVICE) {
@@ -116,17 +116,17 @@ var gMainPane = {
}
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "main-pane-loaded", null);
},
- enableE10SChange: function()
+ enableE10SChange()
{
if (AppConstants.E10S_TESTING_ONLY) {
let e10sCheckbox = document.getElementById("e10sAutoStart");
let e10sPref = document.getElementById("browser.tabs.remote.autostart");
let e10sTempPref = document.getElementById("e10sTempPref");
let prefsToChange;
if (e10sCheckbox.checked) {
@@ -150,17 +150,17 @@ var gMainPane = {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}
// Revert the checkbox in case we didn't quit
e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
}
},
- separateProfileModeChange: function()
+ separateProfileModeChange()
{
if (AppConstants.MOZ_DEV_EDITION) {
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
if (error) {
@@ -201,17 +201,17 @@ var gMainPane = {
return;
case CONFIRM_RESTART_PROMPT_RESTART_LATER:
createOrRemoveSpecialDevEditionFile();
return;
}
}
},
- onGetStarted: function(aEvent) {
+ onGetStarted(aEvent) {
if (AppConstants.MOZ_DEV_EDITION) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
if (win) {
let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
@@ -236,17 +236,17 @@ var gMainPane = {
* 2: the last page the user visited (DEPRECATED)
* 3: windows and tabs from the last session (a.k.a. session restore)
*
* The deprecated option is not exposed in UI; however, if the user has it
* selected and doesn't change the UI for this preference, the deprecated
* option is preserved.
*/
- syncFromHomePref: function()
+ syncFromHomePref()
{
let homePref = document.getElementById("browser.startup.homepage");
// If the pref is set to about:home or about:newtab, set the value to ""
// to show the placeholder text (about:home title) rather than
// exposing those URLs to users.
let defaultBranch = Services.prefs.getDefaultBranch("");
let defaultValue = defaultBranch.getComplexValue("browser.startup.homepage",
@@ -262,32 +262,32 @@ var gMainPane = {
// to be shown.
if (homePref.value == "")
return "about:blank";
// Otherwise, show the actual pref value.
return undefined;
},
- syncToHomePref: function(value)
+ syncToHomePref(value)
{
// If the value is "", use about:home.
if (value == "")
return "about:home";
// Otherwise, use the actual textbox value.
return undefined;
},
/**
* Sets the home page to the current displayed page (or frontmost tab, if the
* most recent browser window contains multiple tabs), updating preference
* window UI to reflect this.
*/
- setHomePageToCurrent: function()
+ setHomePageToCurrent()
{
let homePage = document.getElementById("browser.startup.homepage");
let tabs = this._getTabsForHomePage();
function getTabURI(t) {
return t.linkedBrowser.currentURI.spec;
}
// FIXME Bug 244192: using dangerous "|" joiner!
@@ -295,40 +295,40 @@ var gMainPane = {
homePage.value = tabs.map(getTabURI).join("|");
},
/**
* Displays a dialog in which the user can select a bookmark to use as home
* page. If the user selects a bookmark, that bookmark's name is displayed in
* UI and the bookmark's address is stored to the home page preference.
*/
- setHomePageToBookmark: function()
+ setHomePageToBookmark()
{
var rv = { urls: null, names: null };
gSubDialog.open("chrome://browser/content/preferences/selectBookmark.xul",
"resizable=yes, modal=yes", rv,
this._setHomePageToBookmarkClosed.bind(this, rv));
},
- _setHomePageToBookmarkClosed: function(rv, aEvent) {
+ _setHomePageToBookmarkClosed(rv, aEvent) {
if (aEvent.detail.button != "accept")
return;
if (rv.urls && rv.names) {
var homePage = document.getElementById("browser.startup.homepage");
// XXX still using dangerous "|" joiner!
homePage.value = rv.urls.join("|");
}
},
/**
* Switches the "Use Current Page" button between its singular and plural
* forms.
*/
- _updateUseCurrentButton: function() {
+ _updateUseCurrentButton() {
let useCurrent = document.getElementById("useCurrent");
let tabs = this._getTabsForHomePage();
if (tabs.length > 1)
useCurrent.label = useCurrent.getAttribute("label2");
else
@@ -337,17 +337,17 @@ var gMainPane = {
// In this case, the button's disabled state is set by preferences.xml.
let prefName = "pref.browser.homepage.disable_button.current_page";
if (document.getElementById(prefName).locked)
return;
useCurrent.disabled = !tabs.length
},
- _getTabsForHomePage: function()
+ _getTabsForHomePage()
{
var win;
var tabs = [];
const Cc = Components.classes, Ci = Components.interfaces;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
win = wm.getMostRecentWindow("navigator:browser");
@@ -361,25 +361,25 @@ var gMainPane = {
}
return tabs;
},
/**
* Check to see if a tab is not about:preferences
*/
- isNotAboutPreferences: function(aElement, aIndex, aArray)
+ isNotAboutPreferences(aElement, aIndex, aArray)
{
return !aElement.linkedBrowser.currentURI.spec.startsWith("about:preferences");
},
/**
* Restores the default home page as the user's home page.
*/
- restoreDefaultHomePage: function()
+ restoreDefaultHomePage()
{
var homePage = document.getElementById("browser.startup.homepage");
homePage.value = homePage.defaultValue;
},
// DOWNLOADS
/*
@@ -411,17 +411,17 @@ var gMainPane = {
* browser.download.defaultFolder
* deprecated.
*/
/**
* Enables/disables the folder field and Browse button based on whether a
* default download directory is being used.
*/
- readUseDownloadDir: function()
+ readUseDownloadDir()
{
var downloadFolder = document.getElementById("downloadFolder");
var chooseFolder = document.getElementById("chooseFolder");
var preference = document.getElementById("browser.download.useDownloadDir");
downloadFolder.disabled = !preference.value || preference.locked;
chooseFolder.disabled = !preference.value || preference.locked;
// don't override the preference's value in UI
@@ -524,17 +524,17 @@ var gMainPane = {
iconUrlSpec = fph.getURLSpecFromFile(yield this._getDownloadsFolder("Desktop"));
}
downloadFolder.image = "moz-icon://" + iconUrlSpec + "?size=16";
}),
/**
* Returns the textual path of a folder in readable form.
*/
- _getDisplayNameOfFile: function(aFolder)
+ _getDisplayNameOfFile(aFolder)
{
// TODO: would like to add support for 'Downloads on Macintosh HD'
// for OS X users.
return aFolder ? aFolder.path : "";
},
/**
* Returns the Downloads folder. If aFolder is "Desktop", then the Downloads
@@ -598,17 +598,17 @@ var gMainPane = {
var currentDirPref = document.getElementById("browser.download.dir");
return currentDirPref.value;
}),
/**
* Hide/show the "Show my windows and tabs from last time" option based
* on the value of the browser.privatebrowsing.autostart pref.
*/
- updateBrowserStartupLastSession: function()
+ updateBrowserStartupLastSession()
{
let pbAutoStartPref = document.getElementById("browser.privatebrowsing.autostart");
let startupPref = document.getElementById("browser.startup.page");
let menu = document.getElementById("browserStartupPage");
let option = document.getElementById("browserStartupLastSession");
if (pbAutoStartPref.value) {
option.setAttribute("disabled", "true");
if (option.selected) {
@@ -645,44 +645,44 @@ var gMainPane = {
* False - Only the window is to be shown in Windows 7 taskbar.
*/
/**
* Determines where a link which opens a new window will open.
*
* @returns |true| if such links should be opened in new tabs
*/
- readLinkTarget: function() {
+ readLinkTarget() {
var openNewWindow = document.getElementById("browser.link.open_newwindow");
return openNewWindow.value != 2;
},
/**
* Determines where a link which opens a new window will open.
*
* @returns 2 if such links should be opened in new windows,
* 3 if such links should be opened in new tabs
*/
- writeLinkTarget: function() {
+ writeLinkTarget() {
var linkTargeting = document.getElementById("linkTargeting");
return linkTargeting.checked ? 3 : 2;
},
/*
* Preferences:
*
* browser.shell.checkDefault
* - true if a default-browser check (and prompt to make it so if necessary)
* occurs at startup, false otherwise
*/
/**
* Show button for setting browser as default browser or information that
* browser is already the default browser.
*/
- updateSetDefaultBrowser: function()
+ updateSetDefaultBrowser()
{
if (AppConstants.HAVE_SHELL_SERVICE) {
let shellSvc = getShellService();
let defaultBrowserBox = document.getElementById("defaultBrowserBox");
if (!shellSvc) {
defaultBrowserBox.hidden = true;
return;
}
@@ -693,17 +693,17 @@ var gMainPane = {
alwaysCheck.disabled = alwaysCheck.disabled ||
isDefault && alwaysCheck.checked;
}
},
/**
* Set browser as the operating system default browser.
*/
- setDefaultBrowser: function()
+ setDefaultBrowser()
{
if (AppConstants.HAVE_SHELL_SERVICE) {
let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser");
alwaysCheckPref.value = true;
let shellSvc = getShellService();
if (!shellSvc)
return;
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -37,17 +37,17 @@ function init_category_if_required(categ
return;
}
categoryInfo.init();
}
function register_module(categoryName, categoryObject) {
gCategoryInits.set(categoryName, {
inited: false,
- init: function() {
+ init() {
categoryObject.init();
this.inited = true;
}
});
}
addEventListener("DOMContentLoaded", function onLoad() {
removeEventListener("DOMContentLoaded", onLoad);
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -21,17 +21,17 @@ var gPrivacyPane = {
* Whether the prompt to restart Firefox should appear when changing the autostart pref.
*/
_shouldPromptForRestart: true,
/**
* Show the Tracking Protection UI depending on the
* privacy.trackingprotection.ui.enabled pref, and linkify its Learn More link
*/
- _initTrackingProtection: function() {
+ _initTrackingProtection() {
if (!Services.prefs.getBoolPref("privacy.trackingprotection.ui.enabled")) {
return;
}
let link = document.getElementById("trackingProtectionLearnMore");
let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "tracking-protection";
link.setAttribute("href", url);
@@ -40,48 +40,48 @@ var gPrivacyPane = {
document.getElementById("trackingprotectionbox").hidden = false;
document.getElementById("trackingprotectionpbmbox").hidden = true;
},
/**
* Linkify the Learn More link of the Private Browsing Mode Tracking
* Protection UI.
*/
- _initTrackingProtectionPBM: function() {
+ _initTrackingProtectionPBM() {
let link = document.getElementById("trackingProtectionPBMLearnMore");
let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "tracking-protection-pbm";
link.setAttribute("href", url);
},
/**
* Initialize autocomplete to ensure prefs are in sync.
*/
- _initAutocomplete: function() {
+ _initAutocomplete() {
Components.classes["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Components.interfaces.mozIPlacesAutoComplete);
},
/**
* Show the Containers UI depending on the privacy.userContext.ui.enabled pref.
*/
- _initBrowserContainers: function() {
+ _initBrowserContainers() {
if (!Services.prefs.getBoolPref("privacy.userContext.ui.enabled")) {
return;
}
let link = document.getElementById("browserContainersLearnMore");
link.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "containers";
document.getElementById("browserContainersbox").hidden = false;
document.getElementById("browserContainersCheckbox").checked =
Services.prefs.getBoolPref("privacy.userContext.enabled");
},
- _checkBrowserContainers: function(event) {
+ _checkBrowserContainers(event) {
let checkbox = document.getElementById("browserContainersCheckbox");
if (checkbox.checked) {
Services.prefs.setBoolPref("privacy.userContext.enabled", true);
return;
}
let count = ContextualIdentityService.countContainerTabs();
if (count == 0) {
@@ -111,17 +111,17 @@ var gPrivacyPane = {
checkbox.checked = true;
},
/**
* Sets up the UI for the number of days of history to keep, and updates the
* label of the "Clear Now..." button.
*/
- init: function()
+ init()
{
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gPrivacyPane));
}
this._updateSanitizeSettingsButton();
@@ -266,28 +266,28 @@ var gPrivacyPane = {
/**
* Check whether preferences values are set to keep history
*
* @param aPrefs an array of pref names to check for
* @returns boolean true if all of the prefs are set to keep history,
* false otherwise
*/
- _checkHistoryValues: function(aPrefs) {
+ _checkHistoryValues(aPrefs) {
for (let pref of Object.keys(aPrefs)) {
if (document.getElementById(pref).value != aPrefs[pref])
return false;
}
return true;
},
/**
* Initialize the history mode menulist based on the privacy preferences
*/
- initializeHistoryMode: function PPP_initializeHistoryMode()
+ initializeHistoryMode()
{
let mode;
let getVal = aPref => document.getElementById(aPref).value;
if (getVal("privacy.history.custom"))
mode = "custom";
else if (this._checkHistoryValues(this.prefsForKeepingHistory)) {
if (getVal("browser.privatebrowsing.autostart"))
@@ -299,17 +299,17 @@ var gPrivacyPane = {
mode = "custom";
document.getElementById("historyMode").value = mode;
},
/**
* Update the selected pane based on the history mode menulist
*/
- updateHistoryModePane: function PPP_updateHistoryModePane()
+ updateHistoryModePane()
{
let selectedIndex = -1;
switch (document.getElementById("historyMode").value) {
case "remember":
selectedIndex = 0;
break;
case "dontremember":
selectedIndex = 1;
@@ -321,17 +321,17 @@ var gPrivacyPane = {
document.getElementById("historyPane").selectedIndex = selectedIndex;
document.getElementById("privacy.history.custom").value = selectedIndex == 2;
},
/**
* Update the private browsing auto-start pref and the history mode
* micro-management prefs based on the history mode menulist
*/
- updateHistoryModePrefs: function PPP_updateHistoryModePrefs()
+ updateHistoryModePrefs()
{
let pref = document.getElementById("browser.privatebrowsing.autostart");
switch (document.getElementById("historyMode").value) {
case "remember":
if (pref.value)
pref.value = false;
// select the remember history option if needed
@@ -356,17 +356,17 @@ var gPrivacyPane = {
break;
}
},
/**
* Update the privacy micro-management controls based on the
* value of the private browsing auto-start checkbox.
*/
- updatePrivacyMicroControls: function PPP_updatePrivacyMicroControls()
+ updatePrivacyMicroControls()
{
if (document.getElementById("historyMode").value == "custom") {
let disabled = this._autoStartPrivateBrowsing =
document.getElementById("privateBrowsingAutoStart").checked;
this.dependentControls.forEach(function(aElement) {
let control = document.getElementById(aElement);
let preferenceId = control.getAttribute("preference");
if (!preferenceId) {
@@ -408,27 +408,27 @@ var gPrivacyPane = {
}
},
// PRIVATE BROWSING
/**
* Initialize the starting state for the auto-start private browsing mode pref reverter.
*/
- initAutoStartPrivateBrowsingReverter: function PPP_initAutoStartPrivateBrowsingReverter()
+ initAutoStartPrivateBrowsingReverter()
{
let mode = document.getElementById("historyMode");
let autoStart = document.getElementById("privateBrowsingAutoStart");
this._lastMode = mode.selectedIndex;
this._lastCheckState = autoStart.hasAttribute('checked');
},
_lastMode: null,
_lastCheckState: null,
- updateAutostart: function PPP_updateAutostart() {
+ updateAutostart() {
let mode = document.getElementById("historyMode");
let autoStart = document.getElementById("privateBrowsingAutoStart");
let pref = document.getElementById("browser.privatebrowsing.autostart");
if ((mode.value == "custom" && this._lastCheckState == autoStart.checked) ||
(mode.value == "remember" && !this._lastCheckState) ||
(mode.value == "dontremember" && this._lastCheckState)) {
// These are all no-op changes, so we don't need to prompt.
this._lastMode = mode.selectedIndex;
@@ -485,17 +485,17 @@ var gPrivacyPane = {
*/
showContainerSettings() {
gotoPref("containers");
},
/**
* Displays the available block lists for tracking protection.
*/
- showBlockLists: function()
+ showBlockLists()
{
var bundlePreferences = document.getElementById("bundlePreferences");
let brandName = document.getElementById("bundleBrand")
.getString("brandShortName");
var params = { brandShortName: brandName,
windowTitle: bundlePreferences.getString("blockliststitle"),
introText: bundlePreferences.getString("blockliststext") };
gSubDialog.open("chrome://browser/content/preferences/blocklists.xul",
@@ -540,17 +540,17 @@ var gPrivacyPane = {
* 2 means keep cookies until the browser is closed
*/
/**
* Reads the network.cookie.cookieBehavior preference value and
* enables/disables the rest of the cookie UI accordingly, returning true
* if cookies are enabled.
*/
- readAcceptCookies: function()
+ readAcceptCookies()
{
var pref = document.getElementById("network.cookie.cookieBehavior");
var acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel");
var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
var keepUntil = document.getElementById("keepUntil");
var menu = document.getElementById("keepCookiesUntil");
// enable the rest of the UI for anything other than "disable all cookies"
@@ -561,32 +561,32 @@ var gPrivacyPane = {
return acceptCookies;
},
/**
* Enables/disables the "keep until" label and menulist in response to the
* "accept cookies" checkbox being checked or unchecked.
*/
- writeAcceptCookies: function()
+ writeAcceptCookies()
{
var accept = document.getElementById("acceptCookies");
var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
// if we're enabling cookies, automatically select 'accept third party always'
if (accept.checked)
acceptThirdPartyMenu.selectedIndex = 0;
return accept.checked ? 0 : 2;
},
/**
* Converts between network.cookie.cookieBehavior and the third-party cookie UI
*/
- readAcceptThirdPartyCookies: function()
+ readAcceptThirdPartyCookies()
{
var pref = document.getElementById("network.cookie.cookieBehavior");
switch (pref.value)
{
case 0:
return "always";
case 1:
return "never";
@@ -594,17 +594,17 @@ var gPrivacyPane = {
return "never";
case 3:
return "visited";
default:
return undefined;
}
},
- writeAcceptThirdPartyCookies: function()
+ writeAcceptThirdPartyCookies()
{
var accept = document.getElementById("acceptThirdPartyMenu").selectedItem;
switch (accept.value)
{
case "always":
return 0;
case "visited":
return 3;
@@ -613,34 +613,34 @@ var gPrivacyPane = {
default:
return undefined;
}
},
/**
* Displays fine-grained, per-site preferences for cookies.
*/
- showCookieExceptions: function()
+ showCookieExceptions()
{
var bundlePreferences = document.getElementById("bundlePreferences");
var params = { blockVisible : true,
sessionVisible : true,
allowVisible : true,
prefilledHost : "",
permissionType : "cookie",
windowTitle : bundlePreferences.getString("cookiepermissionstitle"),
introText : bundlePreferences.getString("cookiepermissionstext") };
gSubDialog.open("chrome://browser/content/preferences/permissions.xul",
null, params);
},
/**
* Displays all the user's cookies in a dialog.
*/
- showCookies: function(aCategory)
+ showCookies(aCategory)
{
gSubDialog.open("chrome://browser/content/preferences/cookies.xul");
},
// CLEAR PRIVATE DATA
/*
* Preferences:
@@ -648,27 +648,27 @@ var gPrivacyPane = {
* privacy.sanitize.sanitizeOnShutdown
* - true if the user's private data is cleared on startup according to the
* Clear Private Data settings, false otherwise
*/
/**
* Displays the Clear Private Data settings dialog.
*/
- showClearPrivateDataSettings: function()
+ showClearPrivateDataSettings()
{
gSubDialog.open("chrome://browser/content/preferences/sanitize.xul", "resizable=no");
},
/**
* Displays a dialog from which individual parts of private data may be
* cleared.
*/
- clearPrivateDataNow: function(aClearEverything) {
+ clearPrivateDataNow(aClearEverything) {
var ts = document.getElementById("privacy.sanitize.timeSpan");
var timeSpanOrig = ts.value;
if (aClearEverything) {
ts.value = 0;
}
gSubDialog.open("chrome://browser/content/sanitize.xul", "resizable=no", null, () => {
@@ -680,17 +680,17 @@ var gPrivacyPane = {
Services.obs.notifyObservers(null, "clear-private-data", null);
});
},
/**
* Enables or disables the "Settings..." button depending
* on the privacy.sanitize.sanitizeOnShutdown preference value
*/
- _updateSanitizeSettingsButton: function() {
+ _updateSanitizeSettingsButton() {
var settingsButton = document.getElementById("clearDataSettings");
var sanitizeOnShutdownPref = document.getElementById("privacy.sanitize.sanitizeOnShutdown");
settingsButton.disabled = !sanitizeOnShutdownPref.value;
},
// CONTAINERS
@@ -699,17 +699,17 @@ var gPrivacyPane = {
*
* privacy.userContext.enabled
* - true if containers is enabled
*/
/**
* Enables/disables the Settings button used to configure containers
*/
- readBrowserContainersCheckbox: function()
+ readBrowserContainersCheckbox()
{
var pref = document.getElementById("privacy.userContext.enabled");
var settings = document.getElementById("browserContainersSettings");
settings.disabled = !pref.value;
}
};
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -12,22 +12,22 @@ const ENGINE_FLAVOR = "text/x-moz-search
var gEngineView = null;
var gSearchPane = {
/**
* Initialize autocomplete to ensure prefs are in sync.
*/
- _initAutocomplete: function() {
+ _initAutocomplete() {
Components.classes["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Components.interfaces.mozIPlacesAutoComplete);
},
- init: function()
+ init()
{
gEngineView = new EngineView(new EngineStore());
document.getElementById("engineList").view = gEngineView;
this.buildDefaultEngineDropDown();
let addEnginesLink = document.getElementById("addEngines");
let searchEnginesURL = Services.wm.getMostRecentWindow('navigator:browser')
.BrowserSearch.searchEnginesURL;
@@ -70,17 +70,17 @@ var gSearchPane = {
urlbarSuggests.checked = false;
}
let permanentPBLabel =
document.getElementById("urlBarSuggestionPermanentPBLabel");
permanentPBLabel.hidden = urlbarSuggests.hidden || !permanentPB;
},
- buildDefaultEngineDropDown: function() {
+ buildDefaultEngineDropDown() {
// This is called each time something affects the list of engines.
let list = document.getElementById("defaultEngine");
// Set selection to the current default engine.
let currentEngine = Services.search.currentEngine.name;
// If the current engine isn't in the list any more, select the first item.
let engines = gEngineView._engineStore._engines;
if (!engines.some(e => e.name == currentEngine))
@@ -95,17 +95,17 @@ var gSearchPane = {
item.setAttribute("image", e.iconURI.spec);
}
item.engine = e;
if (e.name == currentEngine)
list.selectedItem = item;
});
},
- handleEvent: function(aEvent) {
+ handleEvent(aEvent) {
switch (aEvent.type) {
case "click":
if (aEvent.target.id != "engineChildren" &&
!aEvent.target.classList.contains("searchEngineAction")) {
let engineList = document.getElementById("engineList");
// We don't want to toggle off selection while editing keyword
// so proceed only when the input field is hidden.
// We need to check that engineList.view is defined here
@@ -157,17 +157,17 @@ var gSearchPane = {
if (aEvent.target.id == "engineList" &&
aEvent.target.inputField == document.getBindingParent(aEvent.originalTarget)) {
gSearchPane.onInputBlur();
}
break;
}
},
- observe: function(aEngine, aTopic, aVerb) {
+ observe(aEngine, aTopic, aVerb) {
if (aTopic == "browser-search-engine-modified") {
aEngine.QueryInterface(Components.interfaces.nsISearchEngine);
switch (aVerb) {
case "engine-added":
gEngineView._engineStore.addEngine(aEngine);
gEngineView.rowCountChanged(gEngineView.lastIndex, 1);
gSearchPane.buildDefaultEngineDropDown();
break;
@@ -189,32 +189,32 @@ var gSearchPane = {
break;
case "engine-default":
// Not relevant
break;
}
}
},
- onInputBlur: function(aEvent) {
+ onInputBlur(aEvent) {
let tree = document.getElementById("engineList");
if (!tree.hasAttribute("editing"))
return;
// Accept input unless discarded.
let accept = aEvent.charCode != KeyEvent.DOM_VK_ESCAPE;
tree.stopEditing(accept);
},
- onTreeSelect: function() {
+ onTreeSelect() {
document.getElementById("removeEngineButton").disabled =
!gEngineView.isEngineSelectedAndRemovable();
},
- onTreeKeyPress: function(aEvent) {
+ onTreeKeyPress(aEvent) {
let index = gEngineView.selectedIndex;
let tree = document.getElementById("engineList");
if (tree.hasAttribute("editing"))
return;
if (aEvent.charCode == KeyEvent.DOM_VK_SPACE) {
// Space toggles the checkbox.
let newValue = !gEngineView._engineStore.engines[index].shown;
@@ -233,27 +233,27 @@ var gSearchPane = {
aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE &&
gEngineView.isEngineSelectedAndRemovable())) {
// Delete and Shift+Backspace (Mac) removes selected engine.
Services.search.removeEngine(gEngineView.selectedEngine.originalEngine);
}
}
},
- onRestoreDefaults: function() {
+ onRestoreDefaults() {
let num = gEngineView._engineStore.restoreDefaultEngines();
gEngineView.rowCountChanged(0, num);
gEngineView.invalidate();
},
- showRestoreDefaults: function(aEnable) {
+ showRestoreDefaults(aEnable) {
document.getElementById("restoreDefaultSearchEngines").disabled = !aEnable;
},
- remove: function(aEngine) {
+ remove(aEngine) {
let index = gEngineView._engineStore.removeEngine(aEngine);
gEngineView.rowCountChanged(index, -1);
gEngineView.invalidate();
gEngineView.selection.select(Math.min(index, gEngineView.lastIndex));
gEngineView.ensureRowIsVisible(gEngineView.currentIndex);
document.getElementById("engineList").focus();
},
@@ -289,27 +289,27 @@ var gSearchPane = {
}
}
gEngineView._engineStore.changeEngine(aEngine, "alias", keyword);
gEngineView.invalidate();
return true;
}),
- saveOneClickEnginesList: function() {
+ saveOneClickEnginesList() {
let hiddenList = [];
for (let engine of gEngineView._engineStore.engines) {
if (!engine.shown)
hiddenList.push(engine.name);
}
document.getElementById("browser.search.hiddenOneOffs").value =
hiddenList.join(",");
},
- setDefaultEngine: function() {
+ setDefaultEngine() {
Services.search.currentEngine =
document.getElementById("defaultEngine").selectedItem.engine;
}
};
function onDragEngineStart(event) {
var selectedIndex = gEngineView.selectedIndex;
var tree = document.getElementById("engineList");
@@ -340,60 +340,60 @@ EngineStore.prototype = {
get engines() {
return this._engines;
},
set engines(val) {
this._engines = val;
return val;
},
- _getIndexForEngine: function ES_getIndexForEngine(aEngine) {
+ _getIndexForEngine(aEngine) {
return this._engines.indexOf(aEngine);
},
- _getEngineByName: function ES_getEngineByName(aName) {
+ _getEngineByName(aName) {
return this._engines.find(engine => engine.name == aName);
},
- _cloneEngine: function ES_cloneEngine(aEngine) {
+ _cloneEngine(aEngine) {
var clonedObj = {};
for (var i in aEngine)
clonedObj[i] = aEngine[i];
clonedObj.originalEngine = aEngine;
clonedObj.shown = this.hiddenList.indexOf(clonedObj.name) == -1;
return clonedObj;
},
// Callback for Array's some(). A thisObj must be passed to some()
- _isSameEngine: function ES_isSameEngine(aEngineClone) {
+ _isSameEngine(aEngineClone) {
return aEngineClone.originalEngine == this.originalEngine;
},
- addEngine: function ES_addEngine(aEngine) {
+ addEngine(aEngine) {
this._engines.push(this._cloneEngine(aEngine));
},
- moveEngine: function ES_moveEngine(aEngine, aNewIndex) {
+ moveEngine(aEngine, aNewIndex) {
if (aNewIndex < 0 || aNewIndex > this._engines.length - 1)
throw new Error("ES_moveEngine: invalid aNewIndex!");
var index = this._getIndexForEngine(aEngine);
if (index == -1)
throw new Error("ES_moveEngine: invalid engine?");
if (index == aNewIndex)
return; // nothing to do
// Move the engine in our internal store
var removedEngine = this._engines.splice(index, 1)[0];
this._engines.splice(aNewIndex, 0, removedEngine);
Services.search.moveEngine(aEngine.originalEngine, aNewIndex);
},
- removeEngine: function ES_removeEngine(aEngine) {
+ removeEngine(aEngine) {
if (this._engines.length == 1) {
throw new Error("Cannot remove last engine!");
}
let engineName = aEngine.name;
let index = this._engines.findIndex(element => element.name == engineName);
if (index == -1)
@@ -402,17 +402,17 @@ EngineStore.prototype = {
this._engines.splice(index, 1);
if (this._defaultEngines.some(this._isSameEngine, this._engines[index]))
gSearchPane.showRestoreDefaults(true);
gSearchPane.buildDefaultEngineDropDown();
return index;
},
- restoreDefaultEngines: function ES_restoreDefaultEngines() {
+ restoreDefaultEngines() {
var added = 0;
for (var i = 0; i < this._defaultEngines.length; ++i) {
var e = this._defaultEngines[i];
// If the engine is already in the list, just move it.
if (this._engines.some(this._isSameEngine, e)) {
this.moveEngine(this._getEngineByName(e.name), i);
@@ -431,26 +431,26 @@ EngineStore.prototype = {
}
}
Services.search.resetToOriginalDefaultEngine();
gSearchPane.showRestoreDefaults(false);
gSearchPane.buildDefaultEngineDropDown();
return added;
},
- changeEngine: function ES_changeEngine(aEngine, aProp, aNewValue) {
+ changeEngine(aEngine, aProp, aNewValue) {
var index = this._getIndexForEngine(aEngine);
if (index == -1)
throw new Error("invalid engine?");
this._engines[index][aProp] = aNewValue;
aEngine.originalEngine[aProp] = aNewValue;
},
- reloadIcons: function ES_reloadIcons() {
+ reloadIcons() {
this._engines.forEach(function(e) {
e.uri = e.originalEngine.uri;
});
}
};
function EngineView(aEngineStore) {
this._engineStore = aEngineStore;
@@ -471,78 +471,78 @@ EngineView.prototype = {
}
return -1;
},
get selectedEngine() {
return this._engineStore.engines[this.selectedIndex];
},
// Helpers
- rowCountChanged: function(index, count) {
+ rowCountChanged(index, count) {
this.tree.rowCountChanged(index, count);
},
- invalidate: function() {
+ invalidate() {
this.tree.invalidate();
},
- ensureRowIsVisible: function(index) {
+ ensureRowIsVisible(index) {
this.tree.ensureRowIsVisible(index);
},
- getSourceIndexFromDrag: function(dataTransfer) {
+ getSourceIndexFromDrag(dataTransfer) {
return parseInt(dataTransfer.getData(ENGINE_FLAVOR));
},
- isCheckBox: function(index, column) {
+ isCheckBox(index, column) {
return column.id == "engineShown";
},
- isEngineSelectedAndRemovable: function() {
+ isEngineSelectedAndRemovable() {
return this.selectedIndex != -1 && this.lastIndex != 0;
},
// nsITreeView
get rowCount() {
return this._engineStore.engines.length;
},
- getImageSrc: function(index, column) {
+ getImageSrc(index, column) {
if (column.id == "engineName") {
if (this._engineStore.engines[index].iconURI)
return this._engineStore.engines[index].iconURI.spec;
if (window.devicePixelRatio > 1)
return "chrome://browser/skin/search-engine-placeholder@2x.png";
return "chrome://browser/skin/search-engine-placeholder.png";
}
return "";
},
- getCellText: function(index, column) {
+ getCellText(index, column) {
if (column.id == "engineName")
return this._engineStore.engines[index].name;
else if (column.id == "engineKeyword")
return this._engineStore.engines[index].alias;
return "";
},
- setTree: function(tree) {
+ setTree(tree) {
this.tree = tree;
},
- canDrop: function(targetIndex, orientation, dataTransfer) {
+ canDrop(targetIndex, orientation, dataTransfer) {
var sourceIndex = this.getSourceIndexFromDrag(dataTransfer);
return (sourceIndex != -1 &&
sourceIndex != targetIndex &&
sourceIndex != targetIndex + orientation);
},
- drop: function(dropIndex, orientation, dataTransfer) {
+ drop(dropIndex, orientation, dataTransfer) {
var sourceIndex = this.getSourceIndexFromDrag(dataTransfer);
var sourceEngine = this._engineStore.engines[sourceIndex];
const nsITreeView = Components.interfaces.nsITreeView;
if (dropIndex > sourceIndex) {
if (orientation == nsITreeView.DROP_BEFORE)
dropIndex--;
} else if (orientation == nsITreeView.DROP_AFTER) {
@@ -554,51 +554,51 @@ EngineView.prototype = {
gSearchPane.buildDefaultEngineDropDown();
// Redraw, and adjust selection
this.invalidate();
this.selection.select(dropIndex);
},
selection: null,
- getRowProperties: function(index) { return ""; },
- getCellProperties: function(index, column) { return ""; },
- getColumnProperties: function(column) { return ""; },
- isContainer: function(index) { return false; },
- isContainerOpen: function(index) { return false; },
- isContainerEmpty: function(index) { return false; },
- isSeparator: function(index) { return false; },
- isSorted: function(index) { return false; },
- getParentIndex: function(index) { return -1; },
- hasNextSibling: function(parentIndex, index) { return false; },
- getLevel: function(index) { return 0; },
- getProgressMode: function(index, column) { },
- getCellValue: function(index, column) {
+ getRowProperties(index) { return ""; },
+ getCellProperties(index, column) { return ""; },
+ getColumnProperties(column) { return ""; },
+ isContainer(index) { return false; },
+ isContainerOpen(index) { return false; },
+ isContainerEmpty(index) { return false; },
+ isSeparator(index) { return false; },
+ isSorted(index) { return false; },
+ getParentIndex(index) { return -1; },
+ hasNextSibling(parentIndex, index) { return false; },
+ getLevel(index) { return 0; },
+ getProgressMode(index, column) { },
+ getCellValue(index, column) {
if (column.id == "engineShown")
return this._engineStore.engines[index].shown;
return undefined;
},
- toggleOpenState: function(index) { },
- cycleHeader: function(column) { },
- selectionChanged: function() { },
- cycleCell: function(row, column) { },
- isEditable: function(index, column) { return column.id != "engineName"; },
- isSelectable: function(index, column) { return false; },
- setCellValue: function(index, column, value) {
+ toggleOpenState(index) { },
+ cycleHeader(column) { },
+ selectionChanged() { },
+ cycleCell(row, column) { },
+ isEditable(index, column) { return column.id != "engineName"; },
+ isSelectable(index, column) { return false; },
+ setCellValue(index, column, value) {
if (column.id == "engineShown") {
this._engineStore.engines[index].shown = value == "true";
gEngineView.invalidate();
gSearchPane.saveOneClickEnginesList();
}
},
- setCellText: function(index, column, value) {
+ setCellText(index, column, value) {
if (column.id == "engineKeyword") {
gSearchPane.editKeyword(this._engineStore.engines[index], value)
.then(valid => {
if (!valid)
document.getElementById("engineList").startEditing(index, column);
});
}
},
- performAction: function(action) { },
- performActionOnRow: function(action, index) { },
- performActionOnCell: function(action, index, column) { }
+ performAction(action) { },
+ performActionOnRow(action, index) { },
+ performActionOnCell(action, index, column) { }
};
--- a/browser/components/preferences/in-content/security.js
+++ b/browser/components/preferences/in-content/security.js
@@ -8,17 +8,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
var gSecurityPane = {
_pane: null,
/**
* Initializes master password UI.
*/
- init: function()
+ init()
{
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gSecurityPane));
}
this._pane = document.getElementById("paneSecurity");
@@ -47,31 +47,31 @@ var gSecurityPane = {
* provided by the site may be installed from it, false if the extension
* may be directly installed after a confirmation dialog
*/
/**
* Enables/disables the add-ons Exceptions button depending on whether
* or not add-on installation warnings are displayed.
*/
- readWarnAddonInstall: function()
+ readWarnAddonInstall()
{
var warn = document.getElementById("xpinstall.whitelist.required");
var exceptions = document.getElementById("addonExceptions");
exceptions.disabled = !warn.value;
// don't override the preference value
return undefined;
},
/**
* Displays the exceptions lists for add-on installation warnings.
*/
- showAddonExceptions: function()
+ showAddonExceptions()
{
var bundlePrefs = document.getElementById("bundlePreferences");
var params = this._addonParams;
if (!params.windowTitle || !params.introText) {
params.windowTitle = bundlePrefs.getString("addons_permissions_title");
params.introText = bundlePrefs.getString("addonspermissionstext");
}
@@ -101,17 +101,17 @@ var gSecurityPane = {
* - true if passwords are remembered, false otherwise
*/
/**
* Enables/disables the Exceptions button used to configure sites where
* passwords are never saved. When browser is set to start in Private
* Browsing mode, the "Remember passwords" UI is useless, so we disable it.
*/
- readSavePasswords: function()
+ readSavePasswords()
{
var pref = document.getElementById("signon.rememberSignons");
var excepts = document.getElementById("passwordExceptions");
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
document.getElementById("savePasswords").disabled = true;
excepts.disabled = true;
return false;
@@ -120,17 +120,17 @@ var gSecurityPane = {
// don't override pref value in UI
return undefined;
},
/**
* Displays a dialog in which the user can view and modify the list of sites
* where passwords are never saved.
*/
- showPasswordExceptions: function()
+ showPasswordExceptions()
{
var bundlePrefs = document.getElementById("bundlePreferences");
var params = {
blockVisible: true,
sessionVisible: false,
allowVisible: false,
hideStatusColumn: true,
prefilledHost: "",
@@ -144,17 +144,17 @@ var gSecurityPane = {
},
/**
* Initializes master password UI: the "use master password" checkbox, selects
* the master password button to show, and enables/disables it as necessary.
* The master password is controlled by various bits of NSS functionality, so
* the UI for it can't be controlled by the normal preference bindings.
*/
- _initMasterPasswordUI: function()
+ _initMasterPasswordUI()
{
var noMP = !LoginHelper.isMasterPasswordSet();
var button = document.getElementById("changeMasterPassword");
button.disabled = noMP;
var checkbox = document.getElementById("useMasterPassword");
checkbox.checked = !noMP;
@@ -233,17 +233,17 @@ var gSecurityPane = {
blockUncommonUnwanted.checked = blockUnwantedPref.value && blockUncommonPref.value;
},
/**
* Enables/disables the master password button depending on the state of the
* "use master password" checkbox, and prompts for master password removal if
* one is set.
*/
- updateMasterPasswordButton: function()
+ updateMasterPasswordButton()
{
var checkbox = document.getElementById("useMasterPassword");
var button = document.getElementById("changeMasterPassword");
button.disabled = !checkbox.checked;
// unchecking the checkbox should try to immediately remove the master
// password, because it's impossible to non-destructively remove the master
// password used to encrypt all the passwords without providing it (by
@@ -257,17 +257,17 @@ var gSecurityPane = {
this._initMasterPasswordUI();
},
/**
* Displays the "remove master password" dialog to allow the user to remove
* the current master password. When the dialog is dismissed, master password
* UI is automatically updated.
*/
- _removeMasterPassword: function()
+ _removeMasterPassword()
{
var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
getService(Ci.nsIPKCS11ModuleDB);
if (secmodDB.isFIPSEnabled) {
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
var bundle = document.getElementById("bundlePreferences");
promptService.alert(window,
@@ -279,24 +279,24 @@ var gSecurityPane = {
gSubDialog.open("chrome://mozapps/content/preferences/removemp.xul",
null, null, this._initMasterPasswordUI.bind(this));
}
},
/**
* Displays a dialog in which the master password may be changed.
*/
- changeMasterPassword: function()
+ changeMasterPassword()
{
gSubDialog.open("chrome://mozapps/content/preferences/changemp.xul",
"resizable=no", null, this._initMasterPasswordUI.bind(this));
},
/**
* Shows the sites where the user has saved passwords and the associated login
* information.
*/
- showPasswords: function()
+ showPasswords()
{
gSubDialog.open("chrome://passwordmgr/content/passwordManager.xul");
}
};
--- a/browser/components/preferences/in-content/subdialogs.js
+++ b/browser/components/preferences/in-content/subdialogs.js
@@ -14,39 +14,39 @@ var gSubDialog = {
_injectedStyleSheets: [
"chrome://browser/skin/preferences/preferences.css",
"chrome://global/skin/in-content/common.css",
"chrome://browser/skin/preferences/in-content/preferences.css",
"chrome://browser/skin/preferences/in-content/dialog.css",
],
_resizeObserver: null,
- init: function() {
+ init() {
this._frame = document.getElementById("dialogFrame");
this._overlay = document.getElementById("dialogOverlay");
this._box = document.getElementById("dialogBox");
this._closeButton = document.getElementById("dialogClose");
},
- updateTitle: function(aEvent) {
+ updateTitle(aEvent) {
if (aEvent.target != gSubDialog._frame.contentDocument)
return;
document.getElementById("dialogTitle").textContent = gSubDialog._frame.contentDocument.title;
},
- injectXMLStylesheet: function(aStylesheetURL) {
+ injectXMLStylesheet(aStylesheetURL) {
let contentStylesheet = this._frame.contentDocument.createProcessingInstruction(
'xml-stylesheet',
'href="' + aStylesheetURL + '" type="text/css"'
);
this._frame.contentDocument.insertBefore(contentStylesheet,
this._frame.contentDocument.documentElement);
},
- open: function(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
+ open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
// If we're already open/opening on this URL, do nothing.
if (this._openedURL == aURL && !this._isClosing) {
return;
}
// If we're open on some (other) URL or we're closing, open when closing has finished.
if (this._openedURL || this._isClosing) {
if (!this._isClosing) {
this.close();
@@ -71,17 +71,17 @@ var gSubDialog = {
features = features.replace(/,/g, "&");
let featureParams = new URLSearchParams(features.toLowerCase());
this._box.setAttribute("resizable", featureParams.has("resizable") &&
featureParams.get("resizable") != "no" &&
featureParams.get("resizable") != "0");
},
- close: function(aEvent = null) {
+ close(aEvent = null) {
if (this._isClosing) {
return;
}
this._isClosing = true;
this._closingPromise = new Promise(resolve => {
this._resolveClosePromise = resolve;
});
@@ -117,17 +117,17 @@ var gSubDialog = {
this._resolveClosePromise();
}
};
this._frame.addEventListener("load", onBlankLoad);
this._frame.loadURI("about:blank");
}, 0);
},
- handleEvent: function(aEvent) {
+ handleEvent(aEvent) {
switch (aEvent.type) {
case "command":
this._frame.contentWindow.close();
break;
case "dialogclosing":
this._onDialogClosing(aEvent);
break;
case "DOMTitleChanged":
@@ -148,23 +148,23 @@ var gSubDialog = {
case "focus":
this._onParentWinFocus(aEvent);
break;
}
},
/* Private methods */
- _onUnload: function(aEvent) {
+ _onUnload(aEvent) {
if (aEvent.target.location.href == this._openedURL) {
this._frame.contentWindow.close();
}
},
- _onContentLoaded: function(aEvent) {
+ _onContentLoaded(aEvent) {
if (aEvent.target != this._frame || aEvent.target.contentWindow.location == "about:blank") {
return;
}
for (let styleSheetURL of this._injectedStyleSheets) {
this.injectXMLStylesheet(styleSheetURL);
}
@@ -204,17 +204,17 @@ var gSubDialog = {
// XXX: Hack to make focus during the dialog's load functions work. Make the element visible
// sooner in DOMContentLoaded but mostly invisible instead of changing visibility just before
// the dialog's load event.
this._overlay.style.visibility = "visible";
this._overlay.style.opacity = "0.01";
},
- _onLoad: function(aEvent) {
+ _onLoad(aEvent) {
if (aEvent.target.contentWindow.location == "about:blank") {
return;
}
// Do this on load to wait for the CSS to load and apply before calculating the size.
let docEl = this._frame.contentDocument.documentElement;
let groupBoxTitle = document.getAnonymousElementByAttribute(this._box, "class", "groupbox-title");
@@ -288,17 +288,17 @@ var gSubDialog = {
if (this._box.getAttribute("resizable") == "true") {
this._resizeObserver = new MutationObserver(this._onResize);
this._resizeObserver.observe(this._box, {attributes: true});
}
this._trapFocus();
},
- _onResize: function(mutations) {
+ _onResize(mutations) {
let frame = gSubDialog._frame;
// The width and height styles are needed for the initial
// layout of the frame, but afterward they need to be removed
// or their presence will restrict the contents of the <browser>
// from resizing to a smaller size.
frame.style.removeProperty("width");
frame.style.removeProperty("height");
@@ -314,22 +314,22 @@ var gSubDialog = {
if (mutation.attributeName == "width") {
docEl.setAttribute("width", docEl.scrollWidth);
} else if (mutation.attributeName == "height") {
docEl.setAttribute("height", docEl.scrollHeight);
}
}
},
- _onDialogClosing: function(aEvent) {
+ _onDialogClosing(aEvent) {
this._frame.contentWindow.removeEventListener("dialogclosing", this);
this._closingEvent = aEvent;
},
- _onKeyDown: function(aEvent) {
+ _onKeyDown(aEvent) {
if (aEvent.currentTarget == window && aEvent.keyCode == aEvent.DOM_VK_ESCAPE &&
!aEvent.defaultPrevented) {
this.close(aEvent);
return;
}
if (aEvent.keyCode != aEvent.DOM_VK_TAB ||
aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey) {
return;
@@ -357,25 +357,25 @@ var gSubDialog = {
} else {
// Somehow, moving back 'past' the opening doc is not trivial. Cheat by doing it in 2 steps:
fm.moveFocus(window, null, fm.MOVEFOCUS_ROOT, fm.FLAG_BYKEY);
fm.moveFocus(parentWin, null, fm.MOVEFOCUS_BACKWARD, fm.FLAG_BYKEY);
}
}
},
- _onParentWinFocus: function(aEvent) {
+ _onParentWinFocus(aEvent) {
// Explicitly check for the focus target of |window| to avoid triggering this when the window
// is refocused
if (aEvent.target != this._closeButton && aEvent.target != window) {
this._closeButton.focus();
}
},
- _addDialogEventListeners: function() {
+ _addDialogEventListeners() {
// Make the close button work.
this._closeButton.addEventListener("command", this);
// DOMTitleChanged isn't fired on the frame, only on the chromeEventHandler
let chromeBrowser = this._getBrowser();
chromeBrowser.addEventListener("DOMTitleChanged", this, true);
// Similarly DOMFrameContentLoaded only fires on the top window
@@ -387,17 +387,17 @@ var gSubDialog = {
chromeBrowser.addEventListener("unload", this, true);
// Ensure we get <esc> keypresses even if nothing in the subdialog is focusable
// (happens on OS X when only text inputs and lists are focusable, and
// the subdialog only has checkboxes/radiobuttons/buttons)
window.addEventListener("keydown", this, true);
},
- _removeDialogEventListeners: function() {
+ _removeDialogEventListeners() {
let chromeBrowser = this._getBrowser();
chromeBrowser.removeEventListener("DOMTitleChanged", this, true);
chromeBrowser.removeEventListener("unload", this, true);
this._closeButton.removeEventListener("command", this);
window.removeEventListener("DOMFrameContentLoaded", this, true);
this._frame.removeEventListener("load", this);
@@ -405,30 +405,30 @@ var gSubDialog = {
window.removeEventListener("keydown", this, true);
if (this._resizeObserver) {
this._resizeObserver.disconnect();
this._resizeObserver = null;
}
this._untrapFocus();
},
- _trapFocus: function() {
+ _trapFocus() {
let fm = Services.focus;
fm.moveFocus(this._frame.contentWindow, null, fm.MOVEFOCUS_FIRST, 0);
this._frame.contentDocument.addEventListener("keydown", this, true);
this._closeButton.addEventListener("keydown", this);
window.addEventListener("focus", this, true);
},
- _untrapFocus: function() {
+ _untrapFocus() {
this._frame.contentDocument.removeEventListener("keydown", this, true);
this._closeButton.removeEventListener("keydown", this);
window.removeEventListener("focus", this);
},
- _getBrowser: function() {
+ _getBrowser() {
return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
},
};
--- a/browser/components/preferences/in-content/sync.js
+++ b/browser/components/preferences/in-content/sync.js
@@ -37,24 +37,24 @@ var gSyncPane = {
set page(val) {
document.getElementById("weavePrefsDeck").selectedIndex = val;
},
get _usingCustomServer() {
return Weave.Svc.Prefs.isSet("serverURL");
},
- needsUpdate: function() {
+ needsUpdate() {
this.page = PAGE_NEEDS_UPDATE;
let label = document.getElementById("loginError");
label.textContent = Weave.Utils.getErrorString(Weave.Status.login);
label.className = "error";
},
- init: function() {
+ init() {
this._setupEventListeners();
// If the Service hasn't finished initializing, wait for it.
let xps = Components.classes["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
if (xps.ready) {
@@ -80,17 +80,17 @@ var gSyncPane = {
}.bind(this);
Services.obs.addObserver(onReady, "weave:service:ready", false);
window.addEventListener("unload", onUnload, false);
xps.ensureLoaded();
},
- _showLoadPage: function(xps) {
+ _showLoadPage(xps) {
let username;
try {
username = Services.prefs.getCharPref("services.sync.username");
} catch (e) {}
if (!username) {
this.page = FXA_PAGE_LOGGED_OUT;
} else if (xps.fxAccountsEnabled) {
// Use cached values while we wait for the up-to-date values
@@ -104,17 +104,17 @@ var gSyncPane = {
document.getElementById("fxaEmailAddress1").textContent = username;
this._populateComputerName(cachedComputerName);
this.page = FXA_PAGE_LOGGED_IN;
} else { // Old Sync
this.page = PAGE_HAS_ACCOUNT;
}
},
- _init: function() {
+ _init() {
let topics = ["weave:service:login:error",
"weave:service:login:finish",
"weave:service:start-over:finish",
"weave:service:setup-complete",
"weave:service:logout:finish",
FxAccountsCommon.ONVERIFIED_NOTIFICATION,
FxAccountsCommon.ONLOGIN_NOTIFICATION,
FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION,
@@ -156,51 +156,51 @@ var gSyncPane = {
document.getElementById("verifiedManage").setAttribute("href", accountsManageURI);
});
this.updateWeavePrefs();
this._initProfileImageUI();
},
- _toggleComputerNameControls: function(editMode) {
+ _toggleComputerNameControls(editMode) {
let textbox = document.getElementById("fxaSyncComputerName");
textbox.disabled = !editMode;
document.getElementById("fxaChangeDeviceName").hidden = editMode;
document.getElementById("fxaCancelChangeDeviceName").hidden = !editMode;
document.getElementById("fxaSaveChangeDeviceName").hidden = !editMode;
},
- _focusComputerNameTextbox: function() {
+ _focusComputerNameTextbox() {
let textbox = document.getElementById("fxaSyncComputerName");
let valLength = textbox.value.length;
textbox.focus();
textbox.setSelectionRange(valLength, valLength);
},
- _blurComputerNameTextbox: function() {
+ _blurComputerNameTextbox() {
document.getElementById("fxaSyncComputerName").blur();
},
- _focusAfterComputerNameTextbox: function() {
+ _focusAfterComputerNameTextbox() {
// Focus the most appropriate element that's *not* the "computer name" box.
Services.focus.moveFocus(window,
document.getElementById("fxaSyncComputerName"),
Services.focus.MOVEFOCUS_FORWARD, 0);
},
- _updateComputerNameValue: function(save) {
+ _updateComputerNameValue(save) {
if (save) {
let textbox = document.getElementById("fxaSyncComputerName");
Weave.Service.clientsEngine.localName = textbox.value;
}
this._populateComputerName(Weave.Service.clientsEngine.localName);
},
- _setupEventListeners: function() {
+ _setupEventListeners() {
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gSyncPane));
}
setEventListener("noAccountSetup", "click", function(aEvent) {
aEvent.stopPropagation();
@@ -289,25 +289,25 @@ var gSyncPane = {
if (e.keyCode == KeyEvent.DOM_VK_RETURN) {
document.getElementById("fxaSaveChangeDeviceName").click();
} else if (e.keyCode == KeyEvent.DOM_VK_ESCAPE) {
document.getElementById("fxaCancelChangeDeviceName").click();
}
});
},
- _initProfileImageUI: function() {
+ _initProfileImageUI() {
try {
if (Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled")) {
document.getElementById("fxaProfileImage").hidden = false;
}
} catch (e) { }
},
- updateWeavePrefs: function() {
+ updateWeavePrefs() {
let service = Components.classes["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
// service.fxAccountsEnabled is false iff sync is already configured for
// the legacy provider.
if (service.fxAccountsEnabled) {
let displayNameLabel = document.getElementById("fxaDisplayName");
let fxaEmailAddress1Label = document.getElementById("fxaEmailAddress1");
@@ -422,17 +422,17 @@ var gSyncPane = {
} else {
this.page = PAGE_HAS_ACCOUNT;
document.getElementById("accountName").textContent = Weave.Service.identity.account;
document.getElementById("syncComputerName").value = Weave.Service.clientsEngine.localName;
document.getElementById("tosPP-normal").hidden = this._usingCustomServer;
}
},
- startOver: function(showDialog) {
+ startOver(showDialog) {
if (showDialog) {
let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
Services.prompt.BUTTON_POS_1_DEFAULT;
let buttonChoice =
Services.prompt.confirmEx(window,
this._stringBundle.GetStringFromName("syncUnlink.title"),
this._stringBundle.GetStringFromName("syncUnlink.label"),
@@ -444,36 +444,36 @@ var gSyncPane = {
if (buttonChoice == 1)
return;
}
Weave.Service.startOver();
this.updateWeavePrefs();
},
- updatePass: function() {
+ updatePass() {
if (Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED)
gSyncUtils.changePassword();
else
gSyncUtils.updatePassphrase();
},
- resetPass: function() {
+ resetPass() {
if (Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED)
gSyncUtils.resetPassword();
else
gSyncUtils.resetPassphrase();
},
- _getEntryPoint: function() {
+ _getEntryPoint() {
let params = new URLSearchParams(document.URL.split("#")[0].split("?")[1] || "");
return params.get("entrypoint") || "preferences";
},
- _openAboutAccounts: function(action) {
+ _openAboutAccounts(action) {
let entryPoint = this._getEntryPoint();
let params = new URLSearchParams();
if (action) {
params.set("action", action);
}
params.set("entrypoint", entryPoint);
this.replaceTabWithUrl("about:accounts?" + params);
@@ -483,17 +483,17 @@ var gSyncPane = {
* Invoke the Sync setup wizard.
*
* @param wizardType
* Indicates type of wizard to launch:
* null -- regular set up wizard
* "pair" -- pair a device first
* "reset" -- reset sync
*/
- openSetup: function(wizardType) {
+ openSetup(wizardType) {
let service = Components.classes["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
if (service.fxAccountsEnabled) {
this._openAboutAccounts();
} else {
let win = Services.wm.getMostRecentWindow("Weave:AccountSetup");
@@ -502,17 +502,17 @@ var gSyncPane = {
else {
window.openDialog("chrome://browser/content/sync/setup.xul",
"weaveSetup", "centerscreen,chrome,resizable=no",
wizardType);
}
}
},
- openContentInBrowser: function(url, options) {
+ openContentInBrowser(url, options) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
if (!win) {
// no window to use, so use _openLink to create a new one. We don't
// always use that as it prefers to open a new window rather than use
// an existing one.
gSyncUtils._openLink(url);
return;
}
@@ -525,68 +525,68 @@ var gSyncPane = {
let browser = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
// And tell it to load our URL.
browser.loadURI(url);
},
- signUp: function() {
+ signUp() {
this._openAboutAccounts("signup");
},
- signIn: function() {
+ signIn() {
this._openAboutAccounts("signin");
},
- reSignIn: function() {
+ reSignIn() {
this._openAboutAccounts("reauth");
},
- clickOrSpaceOrEnterPressed: function(event) {
+ clickOrSpaceOrEnterPressed(event) {
// Note: charCode is deprecated, but 'char' not yet implemented.
// Replace charCode with char when implemented, see Bug 680830
return ((event.type == "click" && event.button == 0) ||
(event.type == "keypress" &&
(event.charCode == KeyEvent.DOM_VK_SPACE || event.keyCode == KeyEvent.DOM_VK_RETURN)));
},
- openChangeProfileImage: function(event) {
+ openChangeProfileImage(event) {
if (this.clickOrSpaceOrEnterPressed(event)) {
fxAccounts.promiseAccountsChangeProfileURI(this._getEntryPoint(), "avatar")
.then(url => {
this.openContentInBrowser(url, {
replaceQueryString: true
});
});
// Prevent page from scrolling on the space key.
event.preventDefault();
}
},
- openManageFirefoxAccount: function(event) {
+ openManageFirefoxAccount(event) {
if (this.clickOrSpaceOrEnterPressed(event)) {
this.manageFirefoxAccount();
// Prevent page from scrolling on the space key.
event.preventDefault();
}
},
- manageFirefoxAccount: function() {
+ manageFirefoxAccount() {
fxAccounts.promiseAccountsManageURI(this._getEntryPoint())
.then(url => {
this.openContentInBrowser(url, {
replaceQueryString: true
});
});
},
- verifyFirefoxAccount: function() {
+ verifyFirefoxAccount() {
let showVerifyNotification = (data) => {
let isError = !data;
let maybeNot = isError ? "Not" : "";
let sb = this._accountsStringBundle;
let title = sb.GetStringFromName("verification" + maybeNot + "SentTitle");
let email = !isError && data ? data.email : "";
let body = sb.formatStringFromName("verification" + maybeNot + "SentBody", [email], 1);
new Notification(title, { body })
@@ -604,22 +604,22 @@ var gSyncPane = {
}
};
fxAccounts.resendVerificationEmail()
.then(fxAccounts.getSignedInUser, onError)
.then(onSuccess, onError);
},
- openOldSyncSupportPage: function() {
+ openOldSyncSupportPage() {
let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "old-sync";
this.openContentInBrowser(url);
},
- unlinkFirefoxAccount: function(confirm) {
+ unlinkFirefoxAccount(confirm) {
if (confirm) {
// We use a string bundle shared with aboutAccounts.
let sb = Services.strings.createBundle("chrome://browser/locale/syncSetup.properties");
let disconnectLabel = sb.GetStringFromName("disconnect.label");
let title = sb.GetStringFromName("disconnect.verify.title");
let body = sb.GetStringFromName("disconnect.verify.bodyHeading") +
"\n\n" +
sb.GetStringFromName("disconnect.verify.bodyText");
@@ -641,29 +641,29 @@ var gSyncPane = {
return;
}
}
fxAccounts.signOut().then(() => {
this.updateWeavePrefs();
});
},
- openAddDevice: function() {
+ openAddDevice() {
if (!Weave.Utils.ensureMPUnlocked())
return;
let win = Services.wm.getMostRecentWindow("Sync:AddDevice");
if (win)
win.focus();
else
window.openDialog("chrome://browser/content/sync/addDevice.xul",
"syncAddDevice", "centerscreen,chrome,resizable=no");
},
- resetSync: function() {
+ resetSync() {
this.openSetup("reset");
},
_populateComputerName(value) {
let textbox = document.getElementById("fxaSyncComputerName");
if (!textbox.hasAttribute("placeholder")) {
textbox.setAttribute("placeholder",
Weave.Utils.getDefaultDeviceName());