2007-03-22 10:30:00 -07:00
|
|
|
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
# for the specific language governing rights and limitations under the
|
|
|
|
# License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Firefox Preferences System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Ben Goodger.
|
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
|
|
|
# Ben Goodger <ben@mozilla.org>
|
|
|
|
# Jeff Walden <jwalden+code@mit.edu>
|
|
|
|
#
|
|
|
|
# Alternatively, the contents of this file may be used under the terms of
|
|
|
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
# of those above. If you wish to allow use of your version of this file only
|
|
|
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
# use your version of this file under the terms of the MPL, indicate your
|
|
|
|
# decision by deleting the provisions above and replace them with the notice
|
|
|
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
# the provisions above, a recipient may use your version of this file under
|
|
|
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
2008-02-26 13:13:17 -08:00
|
|
|
// Load DownloadUtils module for convertByteUnits
|
2008-02-27 10:00:15 -08:00
|
|
|
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
|
2010-09-10 11:42:15 -07:00
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
2008-02-26 13:13:17 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var gAdvancedPane = {
|
|
|
|
_inited: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Brings the appropriate tab to the front and initializes various bits of UI.
|
|
|
|
*/
|
|
|
|
init: function ()
|
|
|
|
{
|
|
|
|
this._inited = true;
|
|
|
|
var advancedPrefs = document.getElementById("advancedPrefs");
|
2008-04-04 17:18:07 -07:00
|
|
|
|
|
|
|
var extraArgs = window.arguments[1];
|
|
|
|
if (extraArgs && extraArgs["advancedTab"]){
|
|
|
|
advancedPrefs.selectedTab = document.getElementById(extraArgs["advancedTab"]);
|
|
|
|
} else {
|
|
|
|
var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
|
2009-07-29 00:49:27 -07:00
|
|
|
if (preference.value !== null)
|
|
|
|
advancedPrefs.selectedIndex = preference.value;
|
2008-04-04 17:18:07 -07:00
|
|
|
}
|
|
|
|
|
2008-11-26 00:45:24 -08:00
|
|
|
#ifdef MOZ_UPDATER
|
2007-03-22 10:30:00 -07:00
|
|
|
this.updateAppUpdateItems();
|
|
|
|
this.updateAutoItems();
|
|
|
|
this.updateModeItems();
|
2008-11-26 00:45:24 -08:00
|
|
|
#endif
|
2008-01-22 18:10:50 -08:00
|
|
|
this.updateOfflineApps();
|
2010-02-09 17:05:31 -08:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
this.initSubmitCrashes();
|
|
|
|
#endif
|
2010-09-15 11:42:38 -07:00
|
|
|
this.updateActualCacheSize();
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 ()
|
|
|
|
{
|
|
|
|
if (!this._inited)
|
|
|
|
return;
|
|
|
|
var advancedPrefs = document.getElementById("advancedPrefs");
|
|
|
|
var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
|
|
|
|
preference.valueFromPreferences = advancedPrefs.selectedIndex;
|
|
|
|
},
|
|
|
|
|
|
|
|
// GENERAL TAB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* accessibility.browsewithcaret
|
|
|
|
* - true enables keyboard navigation and selection within web pages using a
|
|
|
|
* visible caret, false uses normal keyboard navigation with no caret
|
|
|
|
* accessibility.typeaheadfind
|
|
|
|
* - when set to true, typing outside text areas and input boxes will
|
|
|
|
* automatically start searching for what's typed within the current
|
|
|
|
* document; when set to false, no search action happens
|
|
|
|
* general.autoScroll
|
|
|
|
* - when set to true, clicking the scroll wheel on the mouse activates a
|
|
|
|
* mouse mode where moving the mouse down scrolls the document downward with
|
|
|
|
* speed correlated with the distance of the cursor from the original
|
|
|
|
* position at which the click occurred (and likewise with movement upward);
|
|
|
|
* if false, this behavior is disabled
|
|
|
|
* general.smoothScroll
|
|
|
|
* - set to true to enable finer page scrolling than line-by-line on page-up,
|
|
|
|
* page-down, and other such page movements
|
|
|
|
* layout.spellcheckDefault
|
|
|
|
* - an integer:
|
|
|
|
* 0 disables spellchecking
|
|
|
|
* 1 enables spellchecking, but only for multiline text fields
|
|
|
|
* 2 enables spellchecking for all text fields
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the original value of the spellchecking preference to enable proper
|
|
|
|
* restoration if unchanged (since we're mapping a tristate onto a checkbox).
|
|
|
|
*/
|
|
|
|
_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 ()
|
|
|
|
{
|
|
|
|
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 ()
|
|
|
|
{
|
|
|
|
var checkbox = document.getElementById("checkSpelling");
|
|
|
|
return checkbox.checked ? (this._storedSpellCheck == 2 ? 2 : 1) : 0;
|
|
|
|
},
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
initSubmitCrashes: function ()
|
|
|
|
{
|
|
|
|
var checkbox = document.getElementById("submitCrashesBox");
|
|
|
|
try {
|
|
|
|
var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
|
|
|
|
getService(Components.interfaces.nsICrashReporter);
|
|
|
|
checkbox.checked = cr.submitReports;
|
|
|
|
} catch (e) {
|
|
|
|
checkbox.style.display = "none";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
updateSubmitCrashes: function ()
|
|
|
|
{
|
|
|
|
var checkbox = document.getElementById("submitCrashesBox");
|
|
|
|
try {
|
|
|
|
var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
|
|
|
|
getService(Components.interfaces.nsICrashReporter);
|
|
|
|
cr.submitReports = checkbox.checked;
|
|
|
|
} catch (e) { }
|
|
|
|
},
|
|
|
|
|
2010-09-10 11:42:15 -07:00
|
|
|
/**
|
|
|
|
* When the user toggles the layers.accelerate-none pref,
|
|
|
|
* sync its new value to the gfx.direct2d.disabled pref too.
|
|
|
|
*/
|
|
|
|
updateHardwareAcceleration: function()
|
|
|
|
{
|
|
|
|
#ifdef XP_WIN
|
|
|
|
var pref = document.getElementById("layers.accelerate-none");
|
|
|
|
Services.prefs.setBoolPref("gfx.direct2d.disabled", !pref.value);
|
|
|
|
#endif
|
|
|
|
},
|
2010-02-09 17:05:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// NETWORK TAB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* browser.cache.disk.capacity
|
|
|
|
* - the size of the browser cache in KB
|
2010-09-22 14:33:54 -07:00
|
|
|
* - Only used if browser.cache.disk.smart_size.enabled is disabled
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog in which proxy settings may be changed.
|
|
|
|
*/
|
|
|
|
showConnections: function ()
|
|
|
|
{
|
|
|
|
document.documentElement.openSubDialog("chrome://browser/content/preferences/connection.xul",
|
|
|
|
"", null);
|
|
|
|
},
|
2010-09-15 11:42:38 -07:00
|
|
|
|
|
|
|
// Retrieves the amount of space currently used by disk cache
|
|
|
|
updateActualCacheSize: function ()
|
|
|
|
{
|
|
|
|
var visitor = {
|
|
|
|
visitDevice: function (deviceID, deviceInfo)
|
|
|
|
{
|
|
|
|
if (deviceID == "disk") {
|
|
|
|
var actualSizeLabel = document.getElementById("actualCacheSize");
|
|
|
|
var sizeStrings = DownloadUtils.convertByteUnits(deviceInfo.totalSize);
|
|
|
|
var prefStrBundle = document.getElementById("bundlePreferences");
|
|
|
|
var sizeStr = prefStrBundle.getFormattedString("actualCacheSize",
|
|
|
|
sizeStrings);
|
|
|
|
actualSizeLabel.value = sizeStr;
|
|
|
|
}
|
|
|
|
// Do not enumerate entries
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
visitEntry: function (deviceID, entryInfo)
|
|
|
|
{
|
|
|
|
// Do not enumerate entries.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var cacheService =
|
|
|
|
Components.classes["@mozilla.org/network/cache-service;1"]
|
|
|
|
.getService(Components.interfaces.nsICacheService);
|
|
|
|
cacheService.visitEntries(visitor);
|
|
|
|
},
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-15 11:42:38 -07:00
|
|
|
updateCacheSizeUI: function (smartSizeEnabled)
|
|
|
|
{
|
|
|
|
document.getElementById("useCacheBefore").disabled = smartSizeEnabled;
|
|
|
|
document.getElementById("cacheSize").disabled = smartSizeEnabled;
|
|
|
|
document.getElementById("useCacheAfter").disabled = smartSizeEnabled;
|
|
|
|
},
|
|
|
|
|
|
|
|
readSmartSizeEnabled: function ()
|
|
|
|
{
|
2010-09-22 14:33:54 -07:00
|
|
|
// 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);
|
2010-09-15 11:42:38 -07:00
|
|
|
},
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Converts the cache size from units of KB to units of MB and returns that
|
|
|
|
* value.
|
|
|
|
*/
|
|
|
|
readCacheSize: function ()
|
|
|
|
{
|
|
|
|
var preference = document.getElementById("browser.cache.disk.capacity");
|
2008-10-12 08:33:36 -07:00
|
|
|
return preference.value / 1024;
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the cache size as specified in UI (in MB) to KB and returns that
|
|
|
|
* value.
|
|
|
|
*/
|
|
|
|
writeCacheSize: function ()
|
|
|
|
{
|
|
|
|
var cacheSize = document.getElementById("cacheSize");
|
|
|
|
var intValue = parseInt(cacheSize.value, 10);
|
2008-10-12 08:33:36 -07:00
|
|
|
return isNaN(intValue) ? 0 : intValue * 1024;
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the cache.
|
|
|
|
*/
|
|
|
|
clearCache: function ()
|
|
|
|
{
|
|
|
|
var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
|
|
|
|
.getService(Components.interfaces.nsICacheService);
|
|
|
|
try {
|
|
|
|
cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
|
|
|
|
} catch(ex) {}
|
2010-09-15 11:42:38 -07:00
|
|
|
this.updateActualCacheSize();
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
|
|
|
|
2008-02-21 22:34:15 -08:00
|
|
|
readOfflineNotify: function()
|
|
|
|
{
|
|
|
|
var pref = document.getElementById("browser.offline-apps.notify");
|
|
|
|
var button = document.getElementById("offlineNotifyExceptions");
|
|
|
|
button.disabled = !pref.value;
|
|
|
|
return pref.value;
|
|
|
|
},
|
|
|
|
|
|
|
|
showOfflineExceptions: function()
|
|
|
|
{
|
|
|
|
var bundlePreferences = document.getElementById("bundlePreferences");
|
|
|
|
var params = { blockVisible : false,
|
|
|
|
sessionVisible : false,
|
|
|
|
allowVisible : false,
|
|
|
|
prefilledHost : "",
|
|
|
|
permissionType : "offline-app",
|
2008-02-25 13:24:14 -08:00
|
|
|
manageCapability : Components.interfaces.nsIPermissionManager.DENY_ACTION,
|
2008-02-21 22:34:15 -08:00
|
|
|
windowTitle : bundlePreferences.getString("offlinepermissionstitle"),
|
|
|
|
introText : bundlePreferences.getString("offlinepermissionstext") };
|
|
|
|
document.documentElement.openWindow("Browser:Permissions",
|
|
|
|
"chrome://browser/content/preferences/permissions.xul",
|
|
|
|
"", params);
|
|
|
|
},
|
|
|
|
|
2008-03-28 14:26:42 -07:00
|
|
|
// XXX: duplicated in browser.js
|
2009-02-22 11:09:10 -08:00
|
|
|
_getOfflineAppUsage: function (host, groups)
|
2008-03-28 14:26:42 -07:00
|
|
|
{
|
2009-02-22 11:09:10 -08:00
|
|
|
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
|
|
|
|
getService(Components.interfaces.nsIApplicationCacheService);
|
2009-11-04 11:23:20 -08:00
|
|
|
if (!groups)
|
|
|
|
groups = cacheService.getGroups();
|
|
|
|
|
2009-02-22 11:09:10 -08:00
|
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
|
|
|
getService(Components.interfaces.nsIIOService);
|
|
|
|
|
2008-08-26 16:09:02 -07:00
|
|
|
var usage = 0;
|
2009-02-22 11:09:10 -08:00
|
|
|
for (var i = 0; i < groups.length; i++) {
|
|
|
|
var uri = ios.newURI(groups[i], null, null);
|
|
|
|
if (uri.asciiHost == host) {
|
|
|
|
var cache = cacheService.getActiveCache(groups[i]);
|
|
|
|
usage += cache.usage;
|
|
|
|
}
|
|
|
|
}
|
2008-03-28 14:26:42 -07:00
|
|
|
|
|
|
|
var storageManager = Components.classes["@mozilla.org/dom/storagemanager;1"].
|
|
|
|
getService(Components.interfaces.nsIDOMStorageManager);
|
|
|
|
usage += storageManager.getUsage(host);
|
|
|
|
|
|
|
|
return usage;
|
|
|
|
},
|
|
|
|
|
2008-01-22 18:10:50 -08:00
|
|
|
/**
|
|
|
|
* Updates the list of offline applications
|
|
|
|
*/
|
|
|
|
updateOfflineApps: function ()
|
|
|
|
{
|
|
|
|
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
|
|
|
|
.getService(Components.interfaces.nsIPermissionManager);
|
|
|
|
|
|
|
|
var list = document.getElementById("offlineAppsList");
|
|
|
|
while (list.firstChild) {
|
|
|
|
list.removeChild(list.firstChild);
|
|
|
|
}
|
|
|
|
|
2009-02-22 11:09:10 -08:00
|
|
|
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
|
|
|
|
getService(Components.interfaces.nsIApplicationCacheService);
|
2009-11-04 11:23:20 -08:00
|
|
|
var groups = cacheService.getGroups();
|
2009-02-22 11:09:10 -08:00
|
|
|
|
2008-02-26 13:13:17 -08:00
|
|
|
var bundle = document.getElementById("bundlePreferences");
|
|
|
|
|
2008-01-22 18:10:50 -08:00
|
|
|
var enumerator = pm.enumerator;
|
|
|
|
while (enumerator.hasMoreElements()) {
|
|
|
|
var perm = enumerator.getNext().QueryInterface(Components.interfaces.nsIPermission);
|
|
|
|
if (perm.type == "offline-app" &&
|
|
|
|
perm.capability != Components.interfaces.nsIPermissionManager.DEFAULT_ACTION &&
|
|
|
|
perm.capability != Components.interfaces.nsIPermissionManager.DENY_ACTION) {
|
2008-01-31 15:50:54 -08:00
|
|
|
var row = document.createElement("listitem");
|
2008-01-22 18:10:50 -08:00
|
|
|
row.id = "";
|
2008-02-26 13:13:17 -08:00
|
|
|
row.className = "offlineapp";
|
|
|
|
row.setAttribute("host", perm.host);
|
|
|
|
var converted = DownloadUtils.
|
2009-02-22 11:09:10 -08:00
|
|
|
convertByteUnits(this._getOfflineAppUsage(perm.host, groups));
|
2008-02-26 13:13:17 -08:00
|
|
|
row.setAttribute("usage",
|
|
|
|
bundle.getFormattedString("offlineAppUsage",
|
|
|
|
converted));
|
2008-01-22 18:10:50 -08:00
|
|
|
list.appendChild(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
offlineAppSelected: function()
|
|
|
|
{
|
|
|
|
var removeButton = document.getElementById("offlineAppsListRemove");
|
|
|
|
var list = document.getElementById("offlineAppsList");
|
|
|
|
if (list.selectedItem) {
|
|
|
|
removeButton.setAttribute("disabled", "false");
|
|
|
|
} else {
|
|
|
|
removeButton.setAttribute("disabled", "true");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
removeOfflineApp: function()
|
|
|
|
{
|
|
|
|
var list = document.getElementById("offlineAppsList");
|
|
|
|
var item = list.selectedItem;
|
2008-02-26 13:13:17 -08:00
|
|
|
var host = item.getAttribute("host");
|
2008-01-22 18:10:50 -08:00
|
|
|
|
|
|
|
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
var flags = prompts.BUTTON_TITLE_IS_STRING * prompts.BUTTON_POS_0 +
|
|
|
|
prompts.BUTTON_TITLE_CANCEL * prompts.BUTTON_POS_1;
|
|
|
|
|
|
|
|
var bundle = document.getElementById("bundlePreferences");
|
|
|
|
var title = bundle.getString("offlineAppRemoveTitle");
|
|
|
|
var prompt = bundle.getFormattedString("offlineAppRemovePrompt", [host]);
|
|
|
|
var confirm = bundle.getString("offlineAppRemoveConfirm");
|
|
|
|
var result = prompts.confirmEx(window, title, prompt, flags, confirm,
|
|
|
|
null, null, null, {});
|
|
|
|
if (result != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// clear offline cache entries
|
2009-02-22 11:09:10 -08:00
|
|
|
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
|
|
|
|
getService(Components.interfaces.nsIApplicationCacheService);
|
|
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
|
|
|
getService(Components.interfaces.nsIIOService);
|
2009-11-04 11:23:20 -08:00
|
|
|
var groups = cacheService.getGroups();
|
2009-02-22 11:09:10 -08:00
|
|
|
for (var i = 0; i < groups.length; i++) {
|
|
|
|
var uri = ios.newURI(groups[i], null, null);
|
|
|
|
if (uri.asciiHost == host) {
|
|
|
|
var cache = cacheService.getActiveCache(groups[i]);
|
|
|
|
cache.discard();
|
|
|
|
}
|
|
|
|
}
|
2008-01-22 18:10:50 -08:00
|
|
|
|
|
|
|
// send out an offline-app-removed signal. The nsDOMStorage
|
|
|
|
// service will clear DOM storage for this host.
|
|
|
|
var obs = Components.classes["@mozilla.org/observer-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIObserverService);
|
|
|
|
obs.notifyObservers(null, "offline-app-removed", host);
|
|
|
|
|
|
|
|
// remove the permission
|
|
|
|
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
|
|
|
|
.getService(Components.interfaces.nsIPermissionManager);
|
|
|
|
pm.remove(host, "offline-app",
|
|
|
|
Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
|
|
|
|
pm.remove(host, "offline-app",
|
|
|
|
Components.interfaces.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
|
|
|
|
|
|
|
|
list.removeChild(item);
|
|
|
|
gAdvancedPane.offlineAppSelected();
|
|
|
|
},
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// UPDATE TAB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* app.update.enabled
|
|
|
|
* - true if updates to the application are enabled, false otherwise
|
|
|
|
* extensions.update.enabled
|
|
|
|
* - true if updates to extensions and themes are enabled, false otherwise
|
|
|
|
* browser.search.update
|
|
|
|
* - true if updates to search engines are enabled, false otherwise
|
|
|
|
* app.update.auto
|
|
|
|
* - true if updates should be automatically downloaded and installed,
|
|
|
|
* possibly with a warning if incompatible extensions are installed (see
|
|
|
|
* app.update.mode); false if the user should be asked what he wants to do
|
|
|
|
* when an update is available
|
|
|
|
* app.update.mode
|
|
|
|
* - an integer:
|
|
|
|
* 0 do not warn if an update will disable extensions or themes
|
|
|
|
* 1 warn if an update will disable extensions or themes
|
|
|
|
* 2 warn if an update will disable extensions or themes *or* if the
|
|
|
|
* update is a major update
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables and disables various UI preferences as necessary to reflect locked,
|
|
|
|
* disabled, and checked/unchecked states.
|
|
|
|
*
|
|
|
|
* UI state matrix for update preference conditions
|
|
|
|
*
|
|
|
|
* UI Components: Preferences
|
|
|
|
* 1 = Firefox checkbox i = app.update.enabled
|
|
|
|
* 2 = When updates for Firefox are found label ii = app.update.auto
|
|
|
|
* 3 = Automatic Radiogroup (Ask vs. Automatically) iii = app.update.mode
|
|
|
|
* 4 = Warn before disabling extensions checkbox
|
|
|
|
*
|
|
|
|
* States:
|
|
|
|
* Element p val locked Disabled
|
|
|
|
* 1 i t/f f false
|
|
|
|
* i t/f t true
|
|
|
|
* ii t/f t/f false
|
|
|
|
* iii 0/1/2 t/f false
|
|
|
|
* 2,3 i t t/f false
|
|
|
|
* i f t/f true
|
|
|
|
* ii t/f f false
|
|
|
|
* ii t/f t true
|
|
|
|
* iii 0/1/2 t/f false
|
|
|
|
* 4 i t t/f false
|
|
|
|
* i f t/f true
|
|
|
|
* ii t t/f false
|
|
|
|
* ii f t/f true
|
|
|
|
* iii 0/1/2 f false
|
|
|
|
* iii 0/1/2 t true
|
|
|
|
*
|
|
|
|
*/
|
2008-11-26 00:45:24 -08:00
|
|
|
#ifdef MOZ_UPDATER
|
2007-03-22 10:30:00 -07:00
|
|
|
updateAppUpdateItems: function ()
|
|
|
|
{
|
|
|
|
var aus =
|
|
|
|
Components.classes["@mozilla.org/updates/update-service;1"].
|
2009-12-18 14:02:08 -08:00
|
|
|
getService(Components.interfaces.nsIApplicationUpdateService);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
var enabledPref = document.getElementById("app.update.enabled");
|
|
|
|
var enableAppUpdate = document.getElementById("enableAppUpdate");
|
|
|
|
|
2009-11-19 15:07:56 -08:00
|
|
|
enableAppUpdate.disabled = !aus.canCheckForUpdates || enabledPref.locked;
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables/disables UI for "when updates are found" based on the values,
|
|
|
|
* and "locked" states of associated preferences.
|
|
|
|
*/
|
|
|
|
updateAutoItems: function ()
|
|
|
|
{
|
|
|
|
var enabledPref = document.getElementById("app.update.enabled");
|
|
|
|
var autoPref = document.getElementById("app.update.auto");
|
|
|
|
|
|
|
|
var updateModeLabel = document.getElementById("updateModeLabel");
|
|
|
|
var updateMode = document.getElementById("updateMode");
|
|
|
|
|
|
|
|
var disable = enabledPref.locked || !enabledPref.value ||
|
|
|
|
autoPref.locked;
|
|
|
|
updateModeLabel.disabled = updateMode.disabled = disable;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables/disables the "warn if incompatible extensions/themes exist" UI
|
|
|
|
* based on the values and "locked" states of various preferences.
|
|
|
|
*/
|
|
|
|
updateModeItems: function ()
|
|
|
|
{
|
|
|
|
var enabledPref = document.getElementById("app.update.enabled");
|
|
|
|
var autoPref = document.getElementById("app.update.auto");
|
|
|
|
var modePref = document.getElementById("app.update.mode");
|
|
|
|
|
|
|
|
var warnIncompatible = document.getElementById("warnIncompatible");
|
|
|
|
|
|
|
|
var disable = enabledPref.locked || !enabledPref.value || autoPref.locked ||
|
|
|
|
!autoPref.value || modePref.locked;
|
|
|
|
warnIncompatible.disabled = disable;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the value of the app.update.mode preference, which is a tristate
|
|
|
|
* integer preference. We store the value here so that we can properly
|
|
|
|
* restore the preference value if the UI reflecting the preference value
|
|
|
|
* is in a state which can represent either of two integer values (as
|
|
|
|
* opposed to only one possible value in the other UI state).
|
|
|
|
*/
|
|
|
|
_modePreference: -1,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the app.update.mode preference and converts its value into a
|
|
|
|
* true/false value for use in determining whether the "Warn me if this will
|
|
|
|
* disable extensions or themes" checkbox is checked. We also save the value
|
|
|
|
* of the preference so that the preference value can be properly restored if
|
|
|
|
* the user's preferences cannot adequately be expressed by a single checkbox.
|
|
|
|
*
|
|
|
|
* app.update.modee Checkbox State Meaning
|
|
|
|
* 0 Unchecked Do not warn
|
|
|
|
* 1 Checked Warn if there are incompatibilities
|
|
|
|
* 2 Checked Warn if there are incompatibilities,
|
|
|
|
* or the update is major.
|
|
|
|
*/
|
|
|
|
readAddonWarn: function ()
|
|
|
|
{
|
|
|
|
var preference = document.getElementById("app.update.mode");
|
|
|
|
var doNotWarn = preference.value != 0;
|
|
|
|
gAdvancedPane._modePreference = doNotWarn ? preference.value : 1;
|
|
|
|
return doNotWarn;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the state of the "Warn me if this will disable extensions or
|
|
|
|
* themes" checkbox into the integer preference which represents it,
|
|
|
|
* returning that value.
|
|
|
|
*/
|
|
|
|
writeAddonWarn: function ()
|
|
|
|
{
|
|
|
|
var warnIncompatible = document.getElementById("warnIncompatible");
|
|
|
|
return !warnIncompatible.checked ? 0 : gAdvancedPane._modePreference;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the history of installed updates.
|
|
|
|
*/
|
|
|
|
showUpdates: function ()
|
|
|
|
{
|
|
|
|
var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIUpdatePrompt);
|
|
|
|
prompter.showUpdateHistory(window);
|
|
|
|
},
|
2008-11-26 00:45:24 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Extensions checkbox and button are disabled only if the enable Addon
|
|
|
|
* update preference is locked.
|
|
|
|
*/
|
|
|
|
updateAddonUpdateUI: function ()
|
|
|
|
{
|
|
|
|
var enabledPref = document.getElementById("extensions.update.enabled");
|
|
|
|
var enableAddonUpdate = document.getElementById("enableAddonUpdate");
|
|
|
|
|
|
|
|
enableAddonUpdate.disabled = enabledPref.locked;
|
|
|
|
},
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// ENCRYPTION TAB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* security.enable_ssl3
|
|
|
|
* - true if SSL 3 encryption is enabled, false otherwise
|
|
|
|
* security.enable_tls
|
|
|
|
* - true if TLS encryption is enabled, false otherwise
|
|
|
|
* security.default_personal_cert
|
|
|
|
* - a string:
|
|
|
|
* "Select Automatically" select a certificate automatically when a site
|
|
|
|
* requests one
|
|
|
|
* "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 ()
|
|
|
|
{
|
|
|
|
document.documentElement.openWindow("mozilla:certmanager",
|
|
|
|
"chrome://pippki/content/certManager.xul",
|
|
|
|
"", null);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog which describes the user's CRLs.
|
|
|
|
*/
|
|
|
|
showCRLs: function ()
|
|
|
|
{
|
2008-09-30 22:02:22 -07:00
|
|
|
document.documentElement.openWindow("mozilla:crlmanager",
|
2007-03-22 10:30:00 -07:00
|
|
|
"chrome://pippki/content/crlManager.xul",
|
|
|
|
"", null);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog in which OCSP preferences can be configured.
|
|
|
|
*/
|
|
|
|
showOCSP: function ()
|
|
|
|
{
|
|
|
|
document.documentElement.openSubDialog("chrome://mozapps/content/preferences/ocsp.xul",
|
|
|
|
"", null);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog from which the user can manage his security devices.
|
|
|
|
*/
|
|
|
|
showSecurityDevices: function ()
|
|
|
|
{
|
|
|
|
document.documentElement.openWindow("mozilla:devicemanager",
|
|
|
|
"chrome://pippki/content/device_manager.xul",
|
|
|
|
"", null);
|
|
|
|
}
|
2007-12-03 18:38:06 -08:00
|
|
|
#ifdef HAVE_SHELL_SERVICE
|
|
|
|
,
|
|
|
|
|
|
|
|
// SYSTEM DEFAULTS
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* browser.shell.checkDefault
|
|
|
|
* - true if a default-browser check (and prompt to make it so if necessary)
|
|
|
|
* occurs at startup, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the browser is currently registered with the operating
|
|
|
|
* system as the default browser. If the browser is not currently the
|
|
|
|
* default browser, the user is given the option of making it the default;
|
|
|
|
* otherwise, the user is informed that this browser already is the browser.
|
|
|
|
*/
|
|
|
|
checkNow: function ()
|
|
|
|
{
|
|
|
|
var shellSvc = Components.classes["@mozilla.org/browser/shell-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIShellService);
|
|
|
|
var brandBundle = document.getElementById("bundleBrand");
|
|
|
|
var shellBundle = document.getElementById("bundleShell");
|
|
|
|
var brandShortName = brandBundle.getString("brandShortName");
|
|
|
|
var promptTitle = shellBundle.getString("setDefaultBrowserTitle");
|
|
|
|
var promptMessage;
|
|
|
|
const IPS = Components.interfaces.nsIPromptService;
|
|
|
|
var psvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(IPS);
|
|
|
|
if (!shellSvc.isDefaultBrowser(false)) {
|
|
|
|
promptMessage = shellBundle.getFormattedString("setDefaultBrowserMessage",
|
|
|
|
[brandShortName]);
|
|
|
|
var rv = psvc.confirmEx(window, promptTitle, promptMessage,
|
|
|
|
IPS.STD_YES_NO_BUTTONS,
|
|
|
|
null, null, null, null, { });
|
|
|
|
if (rv == 0)
|
|
|
|
shellSvc.setDefaultBrowser(true, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
promptMessage = shellBundle.getFormattedString("alreadyDefaultBrowser",
|
|
|
|
[brandShortName]);
|
|
|
|
psvc.alert(window, promptTitle, promptMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|