2012-08-10 20:20:25 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-02-25 09:07:58 +00:00
|
|
|
|
2009-04-15 20:48:22 +00:00
|
|
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
2005-02-25 09:07:58 +00:00
|
|
|
var gPrivacyPane = {
|
2006-07-05 22:41:03 +00:00
|
|
|
|
2009-04-15 20:48:22 +00:00
|
|
|
/**
|
|
|
|
* Whether the use has selected the auto-start private browsing mode in the UI.
|
|
|
|
*/
|
|
|
|
_autoStartPrivateBrowsing: false,
|
|
|
|
|
2012-12-20 22:57:20 +00:00
|
|
|
/**
|
|
|
|
* Whether the prompt to restart Firefox should appear when changing the autostart pref.
|
|
|
|
*/
|
|
|
|
_shouldPromptForRestart: true,
|
|
|
|
|
2006-07-05 22:41:03 +00:00
|
|
|
/**
|
2006-07-27 21:19:10 +00:00
|
|
|
* Sets up the UI for the number of days of history to keep, and updates the
|
2006-07-31 22:07:00 +00:00
|
|
|
* label of the "Clear Now..." button.
|
2006-07-05 22:41:03 +00:00
|
|
|
*/
|
2005-02-25 09:07:58 +00:00
|
|
|
init: function ()
|
|
|
|
{
|
2009-02-07 12:04:09 +00:00
|
|
|
this._updateSanitizeSettingsButton();
|
2009-04-15 20:48:22 +00:00
|
|
|
this.initializeHistoryMode();
|
|
|
|
this.updateHistoryModePane();
|
|
|
|
this.updatePrivacyMicroControls();
|
2013-03-06 14:51:00 +00:00
|
|
|
this.initAutoStartPrivateBrowsingReverter();
|
2009-04-15 20:48:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// HISTORY MODE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of preferences which affect the initial history mode settings.
|
|
|
|
* If the auto start private browsing mode pref is active, the initial
|
|
|
|
* history mode would be set to "Don't remember anything".
|
|
|
|
* If all of these preferences have their default values, and the auto-start
|
|
|
|
* private browsing mode is not active, the initial history mode would be
|
|
|
|
* set to "Remember everything".
|
|
|
|
* Otherwise, the initial history mode would be set to "Custom".
|
|
|
|
*
|
|
|
|
* Extensions adding their own preferences can append their IDs to this array if needed.
|
|
|
|
*/
|
|
|
|
prefsForDefault: [
|
2010-01-15 16:40:14 +00:00
|
|
|
"places.history.enabled",
|
2009-04-15 20:48:22 +00:00
|
|
|
"browser.formfill.enable",
|
|
|
|
"network.cookie.cookieBehavior",
|
|
|
|
"network.cookie.lifetimePolicy",
|
|
|
|
"privacy.sanitize.sanitizeOnShutdown"
|
|
|
|
],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of control IDs which are dependent on the auto-start private
|
|
|
|
* browsing setting, such that in "Custom" mode they would be disabled if
|
|
|
|
* the auto-start private browsing checkbox is checked, and enabled otherwise.
|
|
|
|
*
|
|
|
|
* Extensions adding their own controls can append their IDs to this array if needed.
|
|
|
|
*/
|
|
|
|
dependentControls: [
|
2010-01-15 16:40:14 +00:00
|
|
|
"rememberHistory",
|
2009-04-15 20:48:22 +00:00
|
|
|
"rememberForms",
|
|
|
|
"keepUntil",
|
|
|
|
"keepCookiesUntil",
|
|
|
|
"alwaysClear",
|
|
|
|
"clearDataSettings"
|
|
|
|
],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether all the preferences values are set to their default values
|
|
|
|
*
|
|
|
|
* @param aPrefs an array of pref names to check for
|
|
|
|
* @returns boolean true if all of the prefs are set to their default values,
|
|
|
|
* false otherwise
|
|
|
|
*/
|
|
|
|
_checkDefaultValues: function(aPrefs) {
|
|
|
|
for (let i = 0; i < aPrefs.length; ++i) {
|
|
|
|
let pref = document.getElementById(aPrefs[i]);
|
|
|
|
if (pref.value != pref.defaultValue)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the history mode menulist based on the privacy preferences
|
|
|
|
*/
|
|
|
|
initializeHistoryMode: function PPP_initializeHistoryMode()
|
|
|
|
{
|
|
|
|
let mode;
|
|
|
|
let getVal = function (aPref)
|
|
|
|
document.getElementById(aPref).value;
|
|
|
|
|
2009-05-16 04:54:28 +00:00
|
|
|
if (this._checkDefaultValues(this.prefsForDefault)) {
|
|
|
|
if (getVal("browser.privatebrowsing.autostart"))
|
|
|
|
mode = "dontremember";
|
|
|
|
else
|
|
|
|
mode = "remember";
|
|
|
|
}
|
2009-04-15 20:48:22 +00:00
|
|
|
else
|
|
|
|
mode = "custom";
|
|
|
|
|
|
|
|
document.getElementById("historyMode").value = mode;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the selected pane based on the history mode menulist
|
|
|
|
*/
|
|
|
|
updateHistoryModePane: function PPP_updateHistoryModePane()
|
|
|
|
{
|
|
|
|
let selectedIndex = -1;
|
|
|
|
switch (document.getElementById("historyMode").value) {
|
|
|
|
case "remember":
|
|
|
|
selectedIndex = 0;
|
|
|
|
break;
|
|
|
|
case "dontremember":
|
|
|
|
selectedIndex = 1;
|
|
|
|
break;
|
|
|
|
case "custom":
|
|
|
|
selectedIndex = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
document.getElementById("historyPane").selectedIndex = selectedIndex;
|
|
|
|
},
|
|
|
|
|
2012-06-14 21:19:27 +00:00
|
|
|
/**
|
|
|
|
* Update the Tracking preferences based on controls.
|
|
|
|
*/
|
|
|
|
setTrackingPrefs: function PPP_setTrackingPrefs()
|
|
|
|
{
|
|
|
|
let dntRadioGroup = document.getElementById("doNotTrackSelection"),
|
|
|
|
dntValuePref = document.getElementById("privacy.donottrackheader.value"),
|
|
|
|
dntEnabledPref = document.getElementById("privacy.donottrackheader.enabled");
|
|
|
|
|
|
|
|
// if the selected radio button says "no preference", set on/off pref to
|
|
|
|
// false and don't change the value pref.
|
|
|
|
if (dntRadioGroup.selectedItem.value == -1) {
|
|
|
|
dntEnabledPref.value = false;
|
|
|
|
return dntValuePref.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
dntEnabledPref.value = true;
|
|
|
|
return dntRadioGroup.selectedItem.value;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the tracking preference value and reflect it in the UI.
|
|
|
|
*/
|
|
|
|
getTrackingPrefs: function PPP_getTrackingPrefs()
|
|
|
|
{
|
|
|
|
let dntValuePref = document.getElementById("privacy.donottrackheader.value"),
|
|
|
|
dntEnabledPref = document.getElementById("privacy.donottrackheader.enabled");
|
|
|
|
|
|
|
|
// if DNT is enbaled, select the value from the selected radio
|
|
|
|
// button, otherwise choose the "no preference" radio button
|
|
|
|
if (dntEnabledPref.value)
|
|
|
|
return dntValuePref.value;
|
|
|
|
|
|
|
|
return document.getElementById("dntnopref").value;
|
|
|
|
},
|
|
|
|
|
2009-04-15 20:48:22 +00:00
|
|
|
/**
|
|
|
|
* Update the private browsing auto-start pref and the history mode
|
|
|
|
* micro-management prefs based on the history mode menulist
|
|
|
|
*/
|
|
|
|
updateHistoryModePrefs: function PPP_updateHistoryModePrefs()
|
|
|
|
{
|
|
|
|
let pref = document.getElementById("browser.privatebrowsing.autostart");
|
|
|
|
switch (document.getElementById("historyMode").value) {
|
|
|
|
case "remember":
|
2012-12-20 22:57:20 +00:00
|
|
|
if (pref.value)
|
|
|
|
pref.value = false;
|
2009-04-15 20:48:22 +00:00
|
|
|
|
|
|
|
// select the remember history option if needed
|
2010-01-15 16:40:14 +00:00
|
|
|
let rememberHistoryCheckbox = document.getElementById("rememberHistory");
|
|
|
|
if (!rememberHistoryCheckbox.checked)
|
2009-04-15 20:48:22 +00:00
|
|
|
rememberHistoryCheckbox.checked = true;
|
|
|
|
|
|
|
|
// select the remember forms history option
|
|
|
|
document.getElementById("browser.formfill.enable").value = true;
|
|
|
|
|
2013-05-14 16:11:56 +00:00
|
|
|
#ifdef RELEASE_BUILD
|
|
|
|
// select the accept cookies option
|
|
|
|
document.getElementById("network.cookie.cookieBehavior").value = 0;
|
|
|
|
#else
|
2013-02-22 16:16:01 +00:00
|
|
|
// select the limit cookies option
|
|
|
|
document.getElementById("network.cookie.cookieBehavior").value = 3;
|
2013-05-14 16:11:56 +00:00
|
|
|
#endif
|
2009-04-15 20:48:22 +00:00
|
|
|
// select the cookie lifetime policy option
|
|
|
|
document.getElementById("network.cookie.lifetimePolicy").value = 0;
|
|
|
|
|
|
|
|
// select the clear on close option
|
|
|
|
document.getElementById("privacy.sanitize.sanitizeOnShutdown").value = false;
|
|
|
|
break;
|
|
|
|
case "dontremember":
|
2012-12-20 22:57:20 +00:00
|
|
|
if (!pref.value)
|
|
|
|
pref.value = true;
|
2009-04-15 20:48:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the privacy micro-management controls based on the
|
|
|
|
* value of the private browsing auto-start checkbox.
|
|
|
|
*/
|
|
|
|
updatePrivacyMicroControls: function PPP_updatePrivacyMicroControls()
|
|
|
|
{
|
|
|
|
if (document.getElementById("historyMode").value == "custom") {
|
|
|
|
let disabled = this._autoStartPrivateBrowsing =
|
|
|
|
document.getElementById("privateBrowsingAutoStart").checked;
|
|
|
|
this.dependentControls
|
|
|
|
.forEach(function (aElement)
|
|
|
|
document.getElementById(aElement).disabled = disabled);
|
|
|
|
|
|
|
|
// adjust the cookie controls status
|
|
|
|
this.readAcceptCookies();
|
|
|
|
document.getElementById("keepCookiesUntil").value = disabled ? 2 :
|
|
|
|
document.getElementById("network.cookie.lifetimePolicy").value;
|
|
|
|
|
|
|
|
// adjust the checked state of the sanitizeOnShutdown checkbox
|
|
|
|
document.getElementById("alwaysClear").checked = disabled ? false :
|
|
|
|
document.getElementById("privacy.sanitize.sanitizeOnShutdown").value;
|
|
|
|
|
|
|
|
// adjust the checked state of the remember history checkboxes
|
2010-01-15 16:40:14 +00:00
|
|
|
document.getElementById("rememberHistory").checked = disabled ? false :
|
|
|
|
document.getElementById("places.history.enabled").value;
|
2009-04-15 20:48:22 +00:00
|
|
|
document.getElementById("rememberForms").checked = disabled ? false :
|
|
|
|
document.getElementById("browser.formfill.enable").value;
|
|
|
|
|
|
|
|
if (!disabled) {
|
|
|
|
// adjust the Settings button for sanitizeOnShutdown
|
|
|
|
this._updateSanitizeSettingsButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// PRIVATE BROWSING
|
|
|
|
|
|
|
|
/**
|
2013-03-06 14:51:00 +00:00
|
|
|
* Initialize the starting state for the auto-start private browsing mode pref reverter.
|
2010-11-26 20:24:26 +00:00
|
|
|
*/
|
2013-03-06 14:51:00 +00:00
|
|
|
initAutoStartPrivateBrowsingReverter: function PPP_initAutoStartPrivateBrowsingReverter()
|
2010-11-26 20:24:26 +00:00
|
|
|
{
|
2013-03-06 14:51:00 +00:00
|
|
|
let mode = document.getElementById("historyMode");
|
|
|
|
let autoStart = document.getElementById("privateBrowsingAutoStart");
|
|
|
|
this._lastMode = mode.selectedIndex;
|
|
|
|
this._lastCheckState = autoStart.hasAttribute('checked');
|
2009-04-15 20:48:22 +00:00
|
|
|
},
|
|
|
|
|
2013-03-06 14:51:00 +00:00
|
|
|
_lastMode: null,
|
2014-02-18 13:49:39 +00:00
|
|
|
_lastCheckState: null,
|
2013-03-06 14:51:00 +00:00
|
|
|
updateAutostart: function PPP_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;
|
|
|
|
this._lastCheckState = autoStart.hasAttribute('checked');
|
|
|
|
return;
|
|
|
|
}
|
2009-04-15 20:48:22 +00:00
|
|
|
|
2013-03-06 14:51:00 +00:00
|
|
|
if (!this._shouldPromptForRestart) {
|
2012-12-20 22:57:20 +00:00
|
|
|
// We're performing a revert. Just let it happen.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Cc = Components.classes, Ci = Components.interfaces;
|
|
|
|
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
|
|
|
|
let bundle = document.getElementById("bundlePreferences");
|
2013-03-15 17:34:59 +00:00
|
|
|
let msg = bundle.getFormattedString(autoStart.checked ?
|
2012-12-20 22:57:20 +00:00
|
|
|
"featureEnableRequiresRestart" : "featureDisableRequiresRestart",
|
|
|
|
[brandName]);
|
|
|
|
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
|
|
|
|
let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
|
|
|
|
let shouldProceed = prompts.confirm(window, title, msg)
|
|
|
|
if (shouldProceed) {
|
|
|
|
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
|
|
|
|
.createInstance(Ci.nsISupportsPRBool);
|
|
|
|
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
|
|
|
|
"restart");
|
|
|
|
shouldProceed = !cancelQuit.data;
|
|
|
|
|
|
|
|
if (shouldProceed) {
|
2013-03-17 15:04:55 +00:00
|
|
|
pref.value = autoStart.hasAttribute('checked');
|
2013-03-06 14:51:00 +00:00
|
|
|
document.documentElement.acceptDialog();
|
2012-12-20 22:57:20 +00:00
|
|
|
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
|
|
|
.getService(Ci.nsIAppStartup);
|
|
|
|
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-06 14:51:00 +00:00
|
|
|
this._shouldPromptForRestart = false;
|
|
|
|
|
|
|
|
if (this._lastCheckState) {
|
|
|
|
autoStart.checked = "checked";
|
2012-12-20 22:57:20 +00:00
|
|
|
} else {
|
2013-03-06 14:51:00 +00:00
|
|
|
autoStart.removeAttribute('checked');
|
2012-12-20 22:57:20 +00:00
|
|
|
}
|
2014-02-18 13:49:39 +00:00
|
|
|
pref.value = autoStart.hasAttribute('checked');
|
2013-03-06 14:51:00 +00:00
|
|
|
mode.selectedIndex = this._lastMode;
|
|
|
|
mode.doCommand();
|
|
|
|
|
|
|
|
this._shouldPromptForRestart = true;
|
2005-02-25 09:07:58 +00:00
|
|
|
},
|
2006-07-05 22:41:03 +00:00
|
|
|
|
|
|
|
// HISTORY
|
|
|
|
|
2009-01-21 08:00:04 +00:00
|
|
|
/**
|
|
|
|
* Read the location bar enabled and suggestion prefs
|
|
|
|
* @return Int value for suggestion menulist
|
|
|
|
*/
|
|
|
|
readSuggestionPref: function PPP_readSuggestionPref()
|
|
|
|
{
|
|
|
|
let getVal = function(aPref)
|
|
|
|
document.getElementById("browser.urlbar." + aPref).value;
|
|
|
|
|
|
|
|
// Suggest nothing if autocomplete is not enabled
|
|
|
|
if (!getVal("autocomplete.enabled"))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
// Bottom 2 bits of default.behavior specify history/bookmark
|
|
|
|
return getVal("default.behavior") & 3;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write the location bar enabled and suggestion prefs when necessary
|
|
|
|
* @return Bool value for enabled pref
|
|
|
|
*/
|
|
|
|
writeSuggestionPref: function PPP_writeSuggestionPref()
|
|
|
|
{
|
|
|
|
let menuVal = document.getElementById("locationBarSuggestion").value;
|
|
|
|
let enabled = menuVal != -1;
|
|
|
|
|
|
|
|
// Only update default.behavior if we're giving suggestions
|
|
|
|
if (enabled) {
|
|
|
|
// Put the selected menu item's value directly into the bottom 2 bits
|
|
|
|
let behavior = document.getElementById("browser.urlbar.default.behavior");
|
|
|
|
behavior.value = behavior.value >> 2 << 2 | menuVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Always update the enabled pref
|
|
|
|
return enabled;
|
|
|
|
},
|
|
|
|
|
2006-07-05 22:41:03 +00:00
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
2010-01-15 16:40:14 +00:00
|
|
|
* places.history.enabled
|
|
|
|
* - whether history is enabled or not
|
2006-07-05 22:41:03 +00:00
|
|
|
* browser.formfill.enable
|
|
|
|
* - true if entries in forms and the search bar should be saved, false
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
// COOKIES
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preferences:
|
|
|
|
*
|
|
|
|
* network.cookie.cookieBehavior
|
|
|
|
* - determines how the browser should handle cookies:
|
|
|
|
* 0 means enable all cookies
|
2013-02-22 16:16:01 +00:00
|
|
|
* 1 means reject all third party cookies
|
2006-07-05 22:41:03 +00:00
|
|
|
* 2 means disable all cookies
|
2013-02-22 16:16:01 +00:00
|
|
|
* 3 means reject third party cookies unless at least one is already set for the eTLD
|
|
|
|
* see netwerk/cookie/src/nsCookieService.cpp for details
|
2006-07-05 22:41:03 +00:00
|
|
|
* 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
|
2008-03-11 18:23:25 +00:00
|
|
|
* enables/disables the rest of the cookie UI accordingly, returning true
|
2006-07-05 22:41:03 +00:00
|
|
|
* if cookies are enabled.
|
|
|
|
*/
|
|
|
|
readAcceptCookies: function ()
|
2005-02-25 09:07:58 +00:00
|
|
|
{
|
2006-07-05 22:41:03 +00:00
|
|
|
var pref = document.getElementById("network.cookie.cookieBehavior");
|
2013-02-22 16:16:01 +00:00
|
|
|
var acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel");
|
|
|
|
var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
|
2006-07-05 22:41:03 +00:00
|
|
|
var keepUntil = document.getElementById("keepUntil");
|
|
|
|
var menu = document.getElementById("keepCookiesUntil");
|
|
|
|
|
2008-03-11 18:23:25 +00:00
|
|
|
// enable the rest of the UI for anything other than "disable all cookies"
|
2006-07-05 22:41:03 +00:00
|
|
|
var acceptCookies = (pref.value != 2);
|
|
|
|
|
2013-02-22 16:16:01 +00:00
|
|
|
acceptThirdPartyLabel.disabled = acceptThirdPartyMenu.disabled = !acceptCookies;
|
2009-04-15 20:48:22 +00:00
|
|
|
keepUntil.disabled = menu.disabled = this._autoStartPrivateBrowsing || !acceptCookies;
|
2006-07-05 22:41:03 +00:00
|
|
|
|
|
|
|
return acceptCookies;
|
2005-02-25 09:07:58 +00:00
|
|
|
},
|
2006-07-05 22:41:03 +00: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 19:00:42 +00:00
|
|
|
{
|
2008-03-11 18:23:25 +00:00
|
|
|
var accept = document.getElementById("acceptCookies");
|
2013-02-22 16:16:01 +00:00
|
|
|
var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
|
2008-03-11 18:23:25 +00:00
|
|
|
|
2013-05-14 16:11:56 +00:00
|
|
|
#ifdef RELEASE_BUILD
|
|
|
|
// if we're enabling cookies, automatically select 'accept third party always'
|
|
|
|
if (accept.checked)
|
|
|
|
acceptThirdPartyMenu.selectedIndex = 0;
|
|
|
|
|
|
|
|
return accept.checked ? 0 : 2;
|
|
|
|
#else
|
2013-02-22 16:16:01 +00:00
|
|
|
// if we're enabling cookies, automatically select 'accept third party from visited'
|
2008-03-11 18:23:25 +00:00
|
|
|
if (accept.checked)
|
2013-02-22 16:16:01 +00:00
|
|
|
acceptThirdPartyMenu.selectedIndex = 1;
|
2008-03-11 18:23:25 +00:00
|
|
|
|
2013-02-22 16:16:01 +00:00
|
|
|
return accept.checked ? 3 : 2;
|
2013-05-14 16:11:56 +00:00
|
|
|
#endif
|
2008-03-11 18:23:25 +00:00
|
|
|
},
|
2013-05-14 16:11:56 +00:00
|
|
|
|
2013-02-22 16:16:01 +00:00
|
|
|
/**
|
|
|
|
* Converts between network.cookie.cookieBehavior and the third-party cookie UI
|
|
|
|
*/
|
|
|
|
readAcceptThirdPartyCookies: function ()
|
|
|
|
{
|
|
|
|
var pref = document.getElementById("network.cookie.cookieBehavior");
|
|
|
|
switch (pref.value)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return "always";
|
|
|
|
case 1:
|
|
|
|
return "never";
|
|
|
|
case 2:
|
|
|
|
return "never";
|
|
|
|
case 3:
|
|
|
|
return "visited";
|
|
|
|
default:
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-03-11 18:23:25 +00:00
|
|
|
writeAcceptThirdPartyCookies: function ()
|
|
|
|
{
|
2013-02-22 16:16:01 +00:00
|
|
|
var accept = document.getElementById("acceptThirdPartyMenu").selectedItem;
|
|
|
|
switch (accept.value)
|
|
|
|
{
|
|
|
|
case "always":
|
|
|
|
return 0;
|
|
|
|
case "visited":
|
|
|
|
return 3;
|
|
|
|
case "never":
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return undefined;
|
|
|
|
}
|
2006-05-20 19:00:42 +00:00
|
|
|
},
|
2006-07-05 22:41:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays fine-grained, per-site preferences for cookies.
|
|
|
|
*/
|
|
|
|
showCookieExceptions: function ()
|
2005-02-25 09:07:58 +00: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-05 22:41:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays all the user's cookies in a dialog.
|
|
|
|
*/
|
|
|
|
showCookies: function (aCategory)
|
2005-02-25 09:07:58 +00:00
|
|
|
{
|
2006-07-05 22:41:03 +00:00
|
|
|
document.documentElement.openWindow("Browser:Cookies",
|
|
|
|
"chrome://browser/content/preferences/cookies.xul",
|
|
|
|
"", null);
|
2005-02-27 00:19:23 +00:00
|
|
|
},
|
2006-07-05 22:41:03 +00: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-31 22:07:00 +00:00
|
|
|
/**
|
2006-07-05 22:41:03 +00:00
|
|
|
* Displays the Clear Private Data settings dialog.
|
|
|
|
*/
|
|
|
|
showClearPrivateDataSettings: function ()
|
2005-02-27 00:19:23 +00:00
|
|
|
{
|
2006-07-05 22:41:03 +00:00
|
|
|
document.documentElement.openSubDialog("chrome://browser/content/preferences/sanitize.xul",
|
|
|
|
"", null);
|
2006-07-21 17:42:26 +00:00
|
|
|
},
|
|
|
|
|
2009-04-15 20:48:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog from which individual parts of private data may be
|
|
|
|
* cleared.
|
|
|
|
*/
|
|
|
|
clearPrivateDataNow: function (aClearEverything)
|
|
|
|
{
|
|
|
|
var ts = document.getElementById("privacy.sanitize.timeSpan");
|
|
|
|
var timeSpanOrig = ts.value;
|
|
|
|
if (aClearEverything)
|
|
|
|
ts.value = 0;
|
|
|
|
|
|
|
|
const Cc = Components.classes, Ci = Components.interfaces;
|
|
|
|
var glue = Cc["@mozilla.org/browser/browserglue;1"]
|
|
|
|
.getService(Ci.nsIBrowserGlue);
|
2009-08-04 18:10:23 +00:00
|
|
|
glue.sanitize(window);
|
2009-04-15 20:48:22 +00:00
|
|
|
|
|
|
|
// reset the timeSpan pref
|
|
|
|
if (aClearEverything)
|
|
|
|
ts.value = timeSpanOrig;
|
|
|
|
},
|
|
|
|
|
2009-02-07 12:04:09 +00:00
|
|
|
/**
|
|
|
|
* Enables or disables the "Settings..." button depending
|
|
|
|
* on the privacy.sanitize.sanitizeOnShutdown preference value
|
|
|
|
*/
|
|
|
|
_updateSanitizeSettingsButton: function () {
|
|
|
|
var settingsButton = document.getElementById("clearDataSettings");
|
|
|
|
var sanitizeOnShutdownPref = document.getElementById("privacy.sanitize.sanitizeOnShutdown");
|
|
|
|
|
2013-02-22 16:16:01 +00:00
|
|
|
settingsButton.disabled = !sanitizeOnShutdownPref.value;
|
2009-02-07 12:04:09 +00:00
|
|
|
}
|
2006-07-05 22:41:03 +00:00
|
|
|
|
2005-02-25 09:07:58 +00:00
|
|
|
};
|