1 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is the Firefox Preferences System.
17 # The Initial Developer of the Original Code is
19 # Portions created by the Initial Developer are Copyright (C) 2005
20 # the Initial Developer. All Rights Reserved.
23 # Ben Goodger <ben@mozilla.org>
24 # Jeff Walden <jwalden+code@mit.edu>
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
41 Components.utils.import(
"resource://gre/modules/DownloadUtils.jsm");
52 var advancedPrefs = document.getElementById(
"advancedPrefs");
54 var extraArgs =
window.arguments[1];
55 if (extraArgs && extraArgs[
"advancedTab"]){
56 advancedPrefs.selectedTab = document.getElementById(extraArgs[
"advancedTab"]);
58 var preference = document.getElementById(
"browser.preferences.advanced.selectedTabIndex");
59 if (preference.value !==
null)
60 advancedPrefs.selectedIndex = preference.value;
64 this.updateAppUpdateItems();
65 this.updateAutoItems();
66 this.updateModeItems();
68 this.updateOfflineApps();
75 tabSelectionChanged:
function ()
79 var advancedPrefs = document.getElementById(
"advancedPrefs");
80 var preference = document.getElementById(
"browser.preferences.advanced.selectedTabIndex");
81 preference.valueFromPreferences = advancedPrefs.selectedIndex;
116 _storedSpellCheck: 0,
123 readCheckSpelling:
function ()
125 var
pref = document.getElementById(
"layout.spellcheckDefault");
126 this._storedSpellCheck = pref.value;
128 return (pref.value != 0);
136 writeCheckSpelling:
function ()
138 var checkbox = document.getElementById(
"checkSpelling");
139 return checkbox.checked ? (this._storedSpellCheck == 2 ? 2 : 1) : 0;
154 showConnections:
function ()
156 document.documentElement.openSubDialog(
"chrome://browser/content/preferences/connection.xul",
164 readCacheSize:
function ()
166 var preference = document.getElementById(
"browser.cache.disk.capacity");
167 return preference.value / 1024;
174 writeCacheSize:
function ()
176 var cacheSize = document.getElementById(
"cacheSize");
177 var intValue = parseInt(cacheSize.value, 10);
178 return isNaN(intValue) ? 0 : intValue * 1024;
184 clearCache:
function ()
186 var
cacheService = Components.classes[
"@mozilla.org/network/cache-service;1"]
187 .getService(Components.interfaces.nsICacheService);
189 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
193 readOfflineNotify:
function()
195 var
pref = document.getElementById(
"browser.offline-apps.notify");
196 var button = document.getElementById(
"offlineNotifyExceptions");
197 button.disabled = !pref.value;
201 showOfflineExceptions:
function()
203 var bundlePreferences = document.getElementById(
"bundlePreferences");
204 var params = { blockVisible :
false,
205 sessionVisible :
false,
206 allowVisible :
false,
208 permissionType :
"offline-app",
209 manageCapability : Components.interfaces.nsIPermissionManager.DENY_ACTION,
210 windowTitle : bundlePreferences.getString(
"offlinepermissionstitle"),
211 introText : bundlePreferences.getString(
"offlinepermissionstext") };
212 document.documentElement.openWindow(
"Browser:Permissions",
213 "chrome://browser/content/preferences/permissions.xul",
218 _getOfflineAppUsage:
function (host, groups)
220 var
cacheService = Components.classes[
"@mozilla.org/network/application-cache-service;1"].
221 getService(Components.interfaces.nsIApplicationCacheService);
223 groups = cacheService.getGroups({});
225 var
ios = Components.classes[
"@mozilla.org/network/io-service;1"].
226 getService(Components.interfaces.nsIIOService);
229 for (var
i = 0;
i < groups.length;
i++) {
231 if (uri.asciiHost == host) {
232 var cache = cacheService.getActiveCache(groups[i]);
233 usage += cache.usage;
237 var storageManager = Components.classes[
"@mozilla.org/dom/storagemanager;1"].
238 getService(Components.interfaces.nsIDOMStorageManager);
239 usage += storageManager.getUsage(host);
247 updateOfflineApps:
function ()
249 var pm = Components.classes[
"@mozilla.org/permissionmanager;1"]
250 .getService(Components.interfaces.nsIPermissionManager);
252 var list = document.getElementById(
"offlineAppsList");
253 while (list.firstChild) {
254 list.removeChild(list.firstChild);
257 var
cacheService = Components.classes[
"@mozilla.org/network/application-cache-service;1"].
258 getService(Components.interfaces.nsIApplicationCacheService);
259 var groups = cacheService.getGroups({});
261 var
bundle = document.getElementById(
"bundlePreferences");
263 var enumerator = pm.enumerator;
264 while (enumerator.hasMoreElements()) {
265 var perm = enumerator.getNext().QueryInterface(Components.interfaces.nsIPermission);
266 if (perm.type ==
"offline-app" &&
267 perm.capability != Components.interfaces.nsIPermissionManager.DEFAULT_ACTION &&
268 perm.capability != Components.interfaces.nsIPermissionManager.DENY_ACTION) {
269 var row = document.createElement(
"listitem");
271 row.className =
"offlineapp";
272 row.setAttribute(
"host", perm.host);
273 var converted = DownloadUtils.
275 row.setAttribute(
"usage",
276 bundle.getFormattedString(
"offlineAppUsage",
278 list.appendChild(row);
283 offlineAppSelected:
function()
285 var removeButton = document.getElementById(
"offlineAppsListRemove");
286 var list = document.getElementById(
"offlineAppsList");
287 if (list.selectedItem) {
288 removeButton.setAttribute(
"disabled",
"false");
290 removeButton.setAttribute(
"disabled",
"true");
294 removeOfflineApp:
function()
296 var list = document.getElementById(
"offlineAppsList");
297 var item = list.selectedItem;
298 var host = item.getAttribute(
"host");
300 var prompts = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"]
301 .getService(Components.interfaces.nsIPromptService);
302 var
flags = prompts.BUTTON_TITLE_IS_STRING * prompts.BUTTON_POS_0 +
303 prompts.BUTTON_TITLE_CANCEL * prompts.BUTTON_POS_1;
305 var
bundle = document.getElementById(
"bundlePreferences");
306 var title = bundle.getString(
"offlineAppRemoveTitle");
307 var
prompt = bundle.getFormattedString(
"offlineAppRemovePrompt", [host]);
308 var confirm = bundle.getString(
"offlineAppRemoveConfirm");
309 var result = prompts.confirmEx(
window, title, prompt, flags, confirm,
315 var
cacheService = Components.classes[
"@mozilla.org/network/application-cache-service;1"].
316 getService(Components.interfaces.nsIApplicationCacheService);
317 var
ios = Components.classes[
"@mozilla.org/network/io-service;1"].
318 getService(Components.interfaces.nsIIOService);
319 var groups = cacheService.getGroups({});
320 for (var
i = 0;
i < groups.length;
i++) {
322 if (uri.asciiHost == host) {
323 var cache = cacheService.getActiveCache(groups[i]);
330 var obs = Components.classes[
"@mozilla.org/observer-service;1"]
331 .getService(Components.interfaces.nsIObserverService);
332 obs.notifyObservers(
null,
"offline-app-removed", host);
335 var pm = Components.classes[
"@mozilla.org/permissionmanager;1"]
336 .getService(Components.interfaces.nsIPermissionManager);
337 pm.remove(host,
"offline-app",
338 Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
339 pm.remove(host,
"offline-app",
340 Components.interfaces.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
342 list.removeChild(item);
343 gAdvancedPane.offlineAppSelected();
402 updateAppUpdateItems:
function ()
405 Components.classes[
"@mozilla.org/updates/update-service;1"].
406 getService(Components.interfaces.nsIApplicationUpdateService2);
408 var enabledPref = document.getElementById(
"app.update.enabled");
409 var enableAppUpdate = document.getElementById(
"enableAppUpdate");
411 enableAppUpdate.disabled = !aus.canCheckForUpdates || enabledPref.locked;
418 updateAutoItems:
function ()
420 var enabledPref = document.getElementById(
"app.update.enabled");
421 var autoPref = document.getElementById(
"app.update.auto");
423 var updateModeLabel = document.getElementById(
"updateModeLabel");
424 var updateMode = document.getElementById(
"updateMode");
426 var disable = enabledPref.locked || !enabledPref.value ||
428 updateModeLabel.disabled = updateMode.disabled = disable;
435 updateModeItems:
function ()
437 var enabledPref = document.getElementById(
"app.update.enabled");
438 var autoPref = document.getElementById(
"app.update.auto");
439 var modePref = document.getElementById(
"app.update.mode");
441 var warnIncompatible = document.getElementById(
"warnIncompatible");
443 var disable = enabledPref.locked || !enabledPref.value || autoPref.locked ||
444 !autoPref.value || modePref.locked;
445 warnIncompatible.disabled = disable;
470 readAddonWarn:
function ()
472 var preference = document.getElementById(
"app.update.mode");
473 var doNotWarn = preference.value != 0;
474 gAdvancedPane._modePreference = doNotWarn ? preference.value : 1;
483 writeAddonWarn:
function ()
485 var warnIncompatible = document.getElementById(
"warnIncompatible");
486 return !warnIncompatible.checked ? 0 : gAdvancedPane._modePreference;
492 showUpdates:
function ()
494 var prompter = Components.classes[
"@mozilla.org/updates/update-prompt;1"]
495 .createInstance(Components.interfaces.nsIUpdatePrompt);
496 prompter.showUpdateHistory(
window);
504 updateAddonUpdateUI:
function ()
506 var enabledPref = document.getElementById(
"extensions.update.enabled");
507 var enableAddonUpdate = document.getElementById(
"enableAddonUpdate");
509 enableAddonUpdate.disabled = enabledPref.locked;
533 showCertificates:
function ()
535 document.documentElement.openWindow(
"mozilla:certmanager",
536 "chrome://pippki/content/certManager.xul",
543 showCRLs:
function ()
545 document.documentElement.openWindow(
"mozilla:crlmanager",
546 "chrome://pippki/content/crlManager.xul",
553 showOCSP:
function ()
555 document.documentElement.openSubDialog(
"chrome://mozapps/content/preferences/ocsp.xul",
562 showSecurityDevices:
function ()
564 document.documentElement.openWindow(
"mozilla:devicemanager",
565 "chrome://pippki/content/device_manager.xul",
568 #ifdef HAVE_SHELL_SERVICE
587 checkNow:
function ()
589 var shellSvc = Components.classes[
"@mozilla.org/browser/shell-service;1"]
590 .getService(Components.interfaces.nsIShellService);
591 var
brandBundle = document.getElementById(
"bundleBrand");
592 var shellBundle = document.getElementById(
"bundleShell");
593 var brandShortName = brandBundle.getString(
"brandShortName");
594 var promptTitle = shellBundle.getString(
"setDefaultBrowserTitle");
596 const IPS = Components.interfaces.nsIPromptService;
597 var psvc = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"]
599 if (!shellSvc.isDefaultBrowser(
false)) {
600 promptMessage = shellBundle.getFormattedString(
"setDefaultBrowserMessage",
602 var rv = psvc.confirmEx(
window, promptTitle, promptMessage,
603 IPS.STD_YES_NO_BUTTONS,
606 shellSvc.setDefaultBrowser(
true,
false);
609 promptMessage = shellBundle.getFormattedString(
"alreadyDefaultBrowser",
611 psvc.alert(
window, promptTitle, promptMessage);
function convertByteUnits(aBytes)
sbDeviceFirmwareAutoCheckForUpdate prototype flags
getService(Ci.sbIFaceplateManager)
_getSelectedPageStyle s i