2006-07-06 02:41:03 +04:00
|
|
|
/*
|
2005-02-25 12:07:58 +03:00
|
|
|
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2005-09-13 22:40:56 +04:00
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
2005-02-25 12:07:58 +03:00
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# 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/
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# 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.
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# The Original Code is the Firefox Preferences System.
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Ben Goodger.
|
2005-02-25 12:07:58 +03:00
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# Contributor(s):
|
|
|
|
# Ben Goodger <ben@mozilla.org>
|
2006-07-06 02:41:03 +04:00
|
|
|
# Jeff Walden <jwalden+code@mit.edu>
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# 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.
|
2005-09-13 22:40:56 +04:00
|
|
|
#
|
2005-02-25 12:07:58 +03:00
|
|
|
# ***** END LICENSE BLOCK *****
|
2006-07-06 02:41:03 +04:00
|
|
|
*/
|
2005-02-25 12:07:58 +03:00
|
|
|
|
|
|
|
var gPrivacyPane = {
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
/**
|
2006-07-28 01:19:10 +04:00
|
|
|
* Sets up the UI for the number of days of history to keep, and updates the
|
2006-08-01 02:07:00 +04:00
|
|
|
* label of the "Clear Now..." button.
|
2006-07-06 02:41:03 +04:00
|
|
|
*/
|
2005-02-25 12:07:58 +03:00
|
|
|
init: function ()
|
|
|
|
{
|
2006-08-02 22:28:26 +04:00
|
|
|
this._updateHistoryDaysUI();
|
2006-07-28 01:19:10 +04:00
|
|
|
this.updateClearNowButtonLabel();
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
// HISTORY
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
2007-12-05 11:30:07 +03:00
|
|
|
* NOTE: These first two are no longer shown in the UI. They're controlled
|
|
|
|
* via the checkbox, which uses the zero state of the pref to turn
|
|
|
|
* history off.
|
2006-07-06 02:41:03 +04:00
|
|
|
* browser.history_expire_days
|
|
|
|
* - the number of days of history to remember
|
2006-08-02 22:28:26 +04:00
|
|
|
* browser.history_expire_days.mirror
|
|
|
|
* - a preference whose value mirrors that of browser.history_expire_days, to
|
|
|
|
* make the "days of history" checkbox easier to code
|
2007-12-05 11:30:07 +03:00
|
|
|
*
|
|
|
|
* browser.history_expire_days_min
|
|
|
|
* - the mininum number of days of history to remember
|
|
|
|
* browser.history_expire_days_min.mirror
|
|
|
|
* - a preference whose value mirrors that of browser.history_expire_days_min
|
|
|
|
* to make the "days of history" checkbox easier to code
|
2006-07-06 02:41:03 +04:00
|
|
|
* browser.formfill.enable
|
|
|
|
* - true if entries in forms and the search bar should be saved, false
|
|
|
|
* otherwise
|
|
|
|
* browser.download.manager.retention
|
|
|
|
* - determines when downloads are automatically removed from the download
|
|
|
|
* manager:
|
|
|
|
*
|
|
|
|
* 0 means remove downloads when they finish downloading
|
|
|
|
* 1 means downloads will be removed when the browser quits
|
|
|
|
* 2 means never remove downloads
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2006-08-02 22:28:26 +04:00
|
|
|
* Initializes the days-of-history mirror preference and connects it to the
|
|
|
|
* days-of-history checkbox so that updates to the textbox are transmitted to
|
|
|
|
* the real days-of-history preference.
|
2006-07-06 02:41:03 +04:00
|
|
|
*/
|
2006-08-02 22:28:26 +04:00
|
|
|
_updateHistoryDaysUI: function ()
|
2006-07-06 02:41:03 +04:00
|
|
|
{
|
|
|
|
var pref = document.getElementById("browser.history_expire_days");
|
2006-08-02 22:28:26 +04:00
|
|
|
var mirror = document.getElementById("browser.history_expire_days.mirror");
|
2007-12-05 11:30:07 +03:00
|
|
|
var pref_min = document.getElementById("browser.history_expire_days_min");
|
2006-07-06 02:41:03 +04:00
|
|
|
var textbox = document.getElementById("historyDays");
|
|
|
|
var checkbox = document.getElementById("rememberHistoryDays");
|
|
|
|
|
2006-08-02 22:28:26 +04:00
|
|
|
// handle mirror non-existence or mirror/pref unsync
|
|
|
|
if (mirror.value === null || mirror.value != pref.value)
|
|
|
|
mirror.value = pref.value ? pref.value : pref.defaultValue;
|
|
|
|
|
|
|
|
checkbox.checked = (pref.value > 0);
|
|
|
|
textbox.disabled = !checkbox.checked;
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
|
|
|
|
2006-07-06 02:41:03 +04:00
|
|
|
/**
|
2006-08-02 22:28:26 +04:00
|
|
|
* Responds to the checking or unchecking of the days-of-history UI, storing
|
|
|
|
* the appropriate value to the days-of-history preference and enabling or
|
|
|
|
* disabling the number textbox as appropriate.
|
2006-07-06 02:41:03 +04:00
|
|
|
*/
|
2006-08-02 22:28:26 +04:00
|
|
|
onchangeHistoryDaysCheck: function ()
|
2006-07-06 02:41:03 +04:00
|
|
|
{
|
|
|
|
var pref = document.getElementById("browser.history_expire_days");
|
2006-08-02 22:28:26 +04:00
|
|
|
var mirror = document.getElementById("browser.history_expire_days.mirror");
|
|
|
|
var textbox = document.getElementById("historyDays");
|
|
|
|
var checkbox = document.getElementById("rememberHistoryDays");
|
2006-07-06 02:41:03 +04:00
|
|
|
|
2006-08-02 22:28:26 +04:00
|
|
|
pref.value = checkbox.checked ? mirror.value : 0;
|
|
|
|
textbox.disabled = !checkbox.checked;
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
2007-12-05 11:30:07 +03:00
|
|
|
/**
|
|
|
|
* Responds to changes in the days-of-history textbox,
|
|
|
|
* unchecking the history-enabled checkbox if the days
|
|
|
|
* value is zero.
|
|
|
|
*/
|
|
|
|
onkeyupHistoryDaysText: function ()
|
|
|
|
{
|
|
|
|
var textbox = document.getElementById("historyDays");
|
|
|
|
var checkbox = document.getElementById("rememberHistoryDays");
|
|
|
|
|
|
|
|
checkbox.checked = textbox.value != 0;
|
|
|
|
},
|
|
|
|
|
2006-07-06 02:41:03 +04:00
|
|
|
/**
|
|
|
|
* Converts the value of the browser.download.manager.retention preference
|
|
|
|
* into a Boolean value. "remove on close" and "don't remember" both map
|
|
|
|
* to an unchecked checkbox, while "remember" maps to a checked checkbox.
|
|
|
|
*/
|
|
|
|
readDownloadRetention: function ()
|
2005-02-25 12:07:58 +03:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
var pref = document.getElementById("browser.download.manager.retention");
|
|
|
|
return (pref.value == 2);
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the appropriate value of the browser.download.manager.retention
|
|
|
|
* preference for the current UI.
|
|
|
|
*/
|
|
|
|
writeDownloadRetention: function ()
|
2005-02-25 12:07:58 +03:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
var checkbox = document.getElementById("rememberDownloads");
|
|
|
|
return checkbox.checked ? 2 : 0;
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
// COOKIES
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* network.cookie.cookieBehavior
|
|
|
|
* - determines how the browser should handle cookies:
|
|
|
|
* 0 means enable all cookies
|
|
|
|
* 1 means allow cookies from the "originating" server only; see
|
|
|
|
* netwerk/cookie/src/nsCookieService.cpp for a hairier definition
|
|
|
|
* 2 means disable all cookies
|
|
|
|
* network.cookie.lifetimePolicy
|
|
|
|
* - determines how long cookies are stored:
|
|
|
|
* 0 means keep cookies until they expire
|
|
|
|
* 1 means ask how long to keep each cookie
|
|
|
|
* 2 means keep cookies until the browser is closed
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the network.cookie.cookieBehavior preference value and
|
|
|
|
* enables/disables the "Keep until:" UI accordingly, returning true
|
|
|
|
* if cookies are enabled.
|
|
|
|
*/
|
|
|
|
readAcceptCookies: function ()
|
2005-02-25 12:07:58 +03:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
var pref = document.getElementById("network.cookie.cookieBehavior");
|
|
|
|
var keepUntil = document.getElementById("keepUntil");
|
|
|
|
var menu = document.getElementById("keepCookiesUntil");
|
|
|
|
|
|
|
|
// anything other than "disable all cookies" maps to "accept cookies"
|
|
|
|
var acceptCookies = (pref.value != 2);
|
|
|
|
|
|
|
|
keepUntil.disabled = menu.disabled = !acceptCookies;
|
|
|
|
|
|
|
|
return acceptCookies;
|
2005-02-25 12:07:58 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables/disables the "keep until" label and menulist in response to the
|
|
|
|
* "accept cookies" checkbox being checked or unchecked.
|
|
|
|
*/
|
|
|
|
writeAcceptCookies: function ()
|
2006-05-20 23:00:42 +04:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
var checkbox = document.getElementById("acceptCookies");
|
2008-02-25 11:50:16 +03:00
|
|
|
return checkbox.checked ? 0 : 2;
|
2006-05-20 23:00:42 +04:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays fine-grained, per-site preferences for cookies.
|
|
|
|
*/
|
|
|
|
showCookieExceptions: function ()
|
2005-02-25 12:07:58 +03:00
|
|
|
{
|
|
|
|
var bundlePreferences = document.getElementById("bundlePreferences");
|
|
|
|
var params = { blockVisible : true,
|
|
|
|
sessionVisible : true,
|
|
|
|
allowVisible : true,
|
|
|
|
prefilledHost : "",
|
|
|
|
permissionType : "cookie",
|
|
|
|
windowTitle : bundlePreferences.getString("cookiepermissionstitle"),
|
|
|
|
introText : bundlePreferences.getString("cookiepermissionstext") };
|
|
|
|
document.documentElement.openWindow("Browser:Permissions",
|
|
|
|
"chrome://browser/content/preferences/permissions.xul",
|
|
|
|
"", params);
|
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays all the user's cookies in a dialog.
|
|
|
|
*/
|
|
|
|
showCookies: function (aCategory)
|
2005-02-25 12:07:58 +03:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
document.documentElement.openWindow("Browser:Cookies",
|
|
|
|
"chrome://browser/content/preferences/cookies.xul",
|
|
|
|
"", null);
|
2005-02-27 03:19:23 +03:00
|
|
|
},
|
2006-07-06 02:41:03 +04:00
|
|
|
|
|
|
|
// CLEAR PRIVATE DATA
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* privacy.sanitize.sanitizeOnShutdown
|
|
|
|
* - true if the user's private data is cleared on startup according to the
|
|
|
|
* Clear Private Data settings, false otherwise
|
2006-07-21 21:42:26 +04:00
|
|
|
* privacy.sanitize.promptOnSanitize
|
|
|
|
* - true if sanitizing forces the user to accept a dialog, false otherwise
|
2006-07-06 02:41:03 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2006-07-28 01:19:10 +04:00
|
|
|
* Sets the label of the "Clear Now..." button according to the
|
2006-09-13 00:43:36 +04:00
|
|
|
* privacy.sanitize.promptOnSanitize preference. Read valueFromPreferences to
|
|
|
|
* only change the button when the underlying pref changes, since in the case
|
|
|
|
* of instantApply=false, the call to clearPrivateDataNow would result in the
|
|
|
|
* dialog appearing when the user just unchecked the "Ask me" checkbox.
|
2006-08-01 02:07:00 +04:00
|
|
|
*/
|
|
|
|
updateClearNowButtonLabel: function ()
|
|
|
|
{
|
2006-08-05 01:35:18 +04:00
|
|
|
var pref = document.getElementById("privacy.sanitize.promptOnSanitize");
|
2006-08-01 02:07:00 +04:00
|
|
|
var clearNowButton = document.getElementById("clearDataNow");
|
2006-08-05 01:35:18 +04:00
|
|
|
|
2006-09-13 00:43:36 +04:00
|
|
|
if (pref.valueFromPreferences)
|
2006-08-01 02:07:00 +04:00
|
|
|
clearNowButton.label = clearNowButton.getAttribute("label1"); // "Clear Now..."
|
|
|
|
else
|
|
|
|
clearNowButton.label = clearNowButton.getAttribute("label2"); // "Clear Now"
|
|
|
|
},
|
2006-07-28 01:19:10 +04:00
|
|
|
|
2006-08-01 02:07:00 +04:00
|
|
|
/**
|
2006-07-06 02:41:03 +04:00
|
|
|
* Displays the Clear Private Data settings dialog.
|
|
|
|
*/
|
|
|
|
showClearPrivateDataSettings: function ()
|
2005-02-27 03:19:23 +03:00
|
|
|
{
|
2006-07-06 02:41:03 +04:00
|
|
|
document.documentElement.openSubDialog("chrome://browser/content/preferences/sanitize.xul",
|
|
|
|
"", null);
|
2006-07-28 01:19:10 +04:00
|
|
|
this.updateClearNowButtonLabel();
|
2006-07-21 21:42:26 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Either displays a dialog from which individual parts of private data may be
|
|
|
|
* cleared, or automatically clears private data according to current
|
|
|
|
* CPD settings. The former happens if privacy.sanitize.promptOnSanitize is
|
|
|
|
* true, and the latter happens otherwise.
|
|
|
|
*/
|
|
|
|
clearPrivateDataNow: function ()
|
|
|
|
{
|
|
|
|
const Cc = Components.classes, Ci = Components.interfaces;
|
|
|
|
var glue = Cc["@mozilla.org/browser/browserglue;1"]
|
|
|
|
.getService(Ci.nsIBrowserGlue);
|
|
|
|
glue.sanitize(window || null);
|
2005-06-14 14:19:34 +04:00
|
|
|
}
|
2006-07-06 02:41:03 +04:00
|
|
|
|
2005-02-25 12:07:58 +03:00
|
|
|
};
|