Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | var gPrivacyPane = { |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | * Whether the use has selected the auto-start private browsing mode in the UI. |
michael@0 | 9 | */ |
michael@0 | 10 | _autoStartPrivateBrowsing: false, |
michael@0 | 11 | |
michael@0 | 12 | /** |
michael@0 | 13 | * Whether the prompt to restart Firefox should appear when changing the autostart pref. |
michael@0 | 14 | */ |
michael@0 | 15 | _shouldPromptForRestart: true, |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * Sets up the UI for the number of days of history to keep, and updates the |
michael@0 | 19 | * label of the "Clear Now..." button. |
michael@0 | 20 | */ |
michael@0 | 21 | init: function () |
michael@0 | 22 | { |
michael@0 | 23 | this._updateSanitizeSettingsButton(); |
michael@0 | 24 | this.initializeHistoryMode(); |
michael@0 | 25 | this.updateHistoryModePane(); |
michael@0 | 26 | this.updatePrivacyMicroControls(); |
michael@0 | 27 | this.initAutoStartPrivateBrowsingReverter(); |
michael@0 | 28 | }, |
michael@0 | 29 | |
michael@0 | 30 | // HISTORY MODE |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * The list of preferences which affect the initial history mode settings. |
michael@0 | 34 | * If the auto start private browsing mode pref is active, the initial |
michael@0 | 35 | * history mode would be set to "Don't remember anything". |
michael@0 | 36 | * If all of these preferences have their default values, and the auto-start |
michael@0 | 37 | * private browsing mode is not active, the initial history mode would be |
michael@0 | 38 | * set to "Remember everything". |
michael@0 | 39 | * Otherwise, the initial history mode would be set to "Custom". |
michael@0 | 40 | * |
michael@0 | 41 | * Extensions adding their own preferences can append their IDs to this array if needed. |
michael@0 | 42 | */ |
michael@0 | 43 | prefsForDefault: [ |
michael@0 | 44 | "places.history.enabled", |
michael@0 | 45 | "browser.formfill.enable", |
michael@0 | 46 | "network.cookie.cookieBehavior", |
michael@0 | 47 | "network.cookie.lifetimePolicy", |
michael@0 | 48 | "privacy.sanitize.sanitizeOnShutdown" |
michael@0 | 49 | ], |
michael@0 | 50 | |
michael@0 | 51 | /** |
michael@0 | 52 | * The list of control IDs which are dependent on the auto-start private |
michael@0 | 53 | * browsing setting, such that in "Custom" mode they would be disabled if |
michael@0 | 54 | * the auto-start private browsing checkbox is checked, and enabled otherwise. |
michael@0 | 55 | * |
michael@0 | 56 | * Extensions adding their own controls can append their IDs to this array if needed. |
michael@0 | 57 | */ |
michael@0 | 58 | dependentControls: [ |
michael@0 | 59 | "rememberHistory", |
michael@0 | 60 | "rememberForms", |
michael@0 | 61 | "keepUntil", |
michael@0 | 62 | "keepCookiesUntil", |
michael@0 | 63 | "alwaysClear", |
michael@0 | 64 | "clearDataSettings" |
michael@0 | 65 | ], |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | * Check whether all the preferences values are set to their default values |
michael@0 | 69 | * |
michael@0 | 70 | * @param aPrefs an array of pref names to check for |
michael@0 | 71 | * @returns boolean true if all of the prefs are set to their default values, |
michael@0 | 72 | * false otherwise |
michael@0 | 73 | */ |
michael@0 | 74 | _checkDefaultValues: function(aPrefs) { |
michael@0 | 75 | for (let i = 0; i < aPrefs.length; ++i) { |
michael@0 | 76 | let pref = document.getElementById(aPrefs[i]); |
michael@0 | 77 | if (pref.value != pref.defaultValue) |
michael@0 | 78 | return false; |
michael@0 | 79 | } |
michael@0 | 80 | return true; |
michael@0 | 81 | }, |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Initialize the history mode menulist based on the privacy preferences |
michael@0 | 85 | */ |
michael@0 | 86 | initializeHistoryMode: function PPP_initializeHistoryMode() |
michael@0 | 87 | { |
michael@0 | 88 | let mode; |
michael@0 | 89 | let getVal = function (aPref) |
michael@0 | 90 | document.getElementById(aPref).value; |
michael@0 | 91 | |
michael@0 | 92 | if (this._checkDefaultValues(this.prefsForDefault)) { |
michael@0 | 93 | if (getVal("browser.privatebrowsing.autostart")) |
michael@0 | 94 | mode = "dontremember"; |
michael@0 | 95 | else |
michael@0 | 96 | mode = "remember"; |
michael@0 | 97 | } |
michael@0 | 98 | else |
michael@0 | 99 | mode = "custom"; |
michael@0 | 100 | |
michael@0 | 101 | document.getElementById("historyMode").value = mode; |
michael@0 | 102 | }, |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Update the selected pane based on the history mode menulist |
michael@0 | 106 | */ |
michael@0 | 107 | updateHistoryModePane: function PPP_updateHistoryModePane() |
michael@0 | 108 | { |
michael@0 | 109 | let selectedIndex = -1; |
michael@0 | 110 | switch (document.getElementById("historyMode").value) { |
michael@0 | 111 | case "remember": |
michael@0 | 112 | selectedIndex = 0; |
michael@0 | 113 | break; |
michael@0 | 114 | case "dontremember": |
michael@0 | 115 | selectedIndex = 1; |
michael@0 | 116 | break; |
michael@0 | 117 | case "custom": |
michael@0 | 118 | selectedIndex = 2; |
michael@0 | 119 | break; |
michael@0 | 120 | } |
michael@0 | 121 | document.getElementById("historyPane").selectedIndex = selectedIndex; |
michael@0 | 122 | }, |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * Update the Tracking preferences based on controls. |
michael@0 | 126 | */ |
michael@0 | 127 | setTrackingPrefs: function PPP_setTrackingPrefs() |
michael@0 | 128 | { |
michael@0 | 129 | let dntRadioGroup = document.getElementById("doNotTrackSelection"), |
michael@0 | 130 | dntValuePref = document.getElementById("privacy.donottrackheader.value"), |
michael@0 | 131 | dntEnabledPref = document.getElementById("privacy.donottrackheader.enabled"); |
michael@0 | 132 | |
michael@0 | 133 | // if the selected radio button says "no preference", set on/off pref to |
michael@0 | 134 | // false and don't change the value pref. |
michael@0 | 135 | if (dntRadioGroup.selectedItem.value == -1) { |
michael@0 | 136 | dntEnabledPref.value = false; |
michael@0 | 137 | return dntValuePref.value; |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | dntEnabledPref.value = true; |
michael@0 | 141 | return dntRadioGroup.selectedItem.value; |
michael@0 | 142 | }, |
michael@0 | 143 | |
michael@0 | 144 | /** |
michael@0 | 145 | * Obtain the tracking preference value and reflect it in the UI. |
michael@0 | 146 | */ |
michael@0 | 147 | getTrackingPrefs: function PPP_getTrackingPrefs() |
michael@0 | 148 | { |
michael@0 | 149 | // XXX avoid using bindings that might not be attached, see bug 859982 |
michael@0 | 150 | let dntValue = Services.prefs.getIntPref("privacy.donottrackheader.value"), |
michael@0 | 151 | dntEnabled = Services.prefs.getBoolPref("privacy.donottrackheader.enabled"); |
michael@0 | 152 | |
michael@0 | 153 | // if DNT is enbaled, select the value from the selected radio |
michael@0 | 154 | // button, otherwise choose the "no preference" radio button |
michael@0 | 155 | if (dntEnabled) |
michael@0 | 156 | return dntValue; |
michael@0 | 157 | |
michael@0 | 158 | return document.getElementById("dntnopref").value; |
michael@0 | 159 | }, |
michael@0 | 160 | |
michael@0 | 161 | /** |
michael@0 | 162 | * Update the private browsing auto-start pref and the history mode |
michael@0 | 163 | * micro-management prefs based on the history mode menulist |
michael@0 | 164 | */ |
michael@0 | 165 | updateHistoryModePrefs: function PPP_updateHistoryModePrefs() |
michael@0 | 166 | { |
michael@0 | 167 | let pref = document.getElementById("browser.privatebrowsing.autostart"); |
michael@0 | 168 | switch (document.getElementById("historyMode").value) { |
michael@0 | 169 | case "remember": |
michael@0 | 170 | if (pref.value) |
michael@0 | 171 | pref.value = false; |
michael@0 | 172 | |
michael@0 | 173 | // select the remember history option if needed |
michael@0 | 174 | let rememberHistoryCheckbox = document.getElementById("rememberHistory"); |
michael@0 | 175 | if (!rememberHistoryCheckbox.checked) |
michael@0 | 176 | rememberHistoryCheckbox.checked = true; |
michael@0 | 177 | |
michael@0 | 178 | // select the remember forms history option |
michael@0 | 179 | document.getElementById("browser.formfill.enable").value = true; |
michael@0 | 180 | |
michael@0 | 181 | #ifdef RELEASE_BUILD |
michael@0 | 182 | // select the allow cookies option |
michael@0 | 183 | document.getElementById("network.cookie.cookieBehavior").value = 0; |
michael@0 | 184 | #else |
michael@0 | 185 | // select the limit cookies option |
michael@0 | 186 | document.getElementById("network.cookie.cookieBehavior").value = 3; |
michael@0 | 187 | #endif |
michael@0 | 188 | // select the cookie lifetime policy option |
michael@0 | 189 | document.getElementById("network.cookie.lifetimePolicy").value = 0; |
michael@0 | 190 | |
michael@0 | 191 | // select the clear on close option |
michael@0 | 192 | document.getElementById("privacy.sanitize.sanitizeOnShutdown").value = false; |
michael@0 | 193 | break; |
michael@0 | 194 | case "dontremember": |
michael@0 | 195 | if (!pref.value) |
michael@0 | 196 | pref.value = true; |
michael@0 | 197 | break; |
michael@0 | 198 | } |
michael@0 | 199 | }, |
michael@0 | 200 | |
michael@0 | 201 | /** |
michael@0 | 202 | * Update the privacy micro-management controls based on the |
michael@0 | 203 | * value of the private browsing auto-start checkbox. |
michael@0 | 204 | */ |
michael@0 | 205 | updatePrivacyMicroControls: function PPP_updatePrivacyMicroControls() |
michael@0 | 206 | { |
michael@0 | 207 | if (document.getElementById("historyMode").value == "custom") { |
michael@0 | 208 | let disabled = this._autoStartPrivateBrowsing = |
michael@0 | 209 | document.getElementById("privateBrowsingAutoStart").checked; |
michael@0 | 210 | this.dependentControls |
michael@0 | 211 | .forEach(function (aElement) |
michael@0 | 212 | document.getElementById(aElement).disabled = disabled); |
michael@0 | 213 | |
michael@0 | 214 | // adjust the cookie controls status |
michael@0 | 215 | this.readAcceptCookies(); |
michael@0 | 216 | document.getElementById("keepCookiesUntil").value = disabled ? 2 : |
michael@0 | 217 | document.getElementById("network.cookie.lifetimePolicy").value; |
michael@0 | 218 | |
michael@0 | 219 | // adjust the checked state of the sanitizeOnShutdown checkbox |
michael@0 | 220 | document.getElementById("alwaysClear").checked = disabled ? false : |
michael@0 | 221 | document.getElementById("privacy.sanitize.sanitizeOnShutdown").value; |
michael@0 | 222 | |
michael@0 | 223 | // adjust the checked state of the remember history checkboxes |
michael@0 | 224 | document.getElementById("rememberHistory").checked = disabled ? false : |
michael@0 | 225 | document.getElementById("places.history.enabled").value; |
michael@0 | 226 | document.getElementById("rememberForms").checked = disabled ? false : |
michael@0 | 227 | document.getElementById("browser.formfill.enable").value; |
michael@0 | 228 | |
michael@0 | 229 | if (!disabled) { |
michael@0 | 230 | // adjust the Settings button for sanitizeOnShutdown |
michael@0 | 231 | this._updateSanitizeSettingsButton(); |
michael@0 | 232 | } |
michael@0 | 233 | } |
michael@0 | 234 | }, |
michael@0 | 235 | |
michael@0 | 236 | // PRIVATE BROWSING |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Initialize the starting state for the auto-start private browsing mode pref reverter. |
michael@0 | 240 | */ |
michael@0 | 241 | initAutoStartPrivateBrowsingReverter: function PPP_initAutoStartPrivateBrowsingReverter() |
michael@0 | 242 | { |
michael@0 | 243 | let mode = document.getElementById("historyMode"); |
michael@0 | 244 | let autoStart = document.getElementById("privateBrowsingAutoStart"); |
michael@0 | 245 | this._lastMode = mode.selectedIndex; |
michael@0 | 246 | this._lastCheckState = autoStart.hasAttribute('checked'); |
michael@0 | 247 | }, |
michael@0 | 248 | |
michael@0 | 249 | _lastMode: null, |
michael@0 | 250 | _lastCheckState: null, |
michael@0 | 251 | updateAutostart: function PPP_updateAutostart() { |
michael@0 | 252 | let mode = document.getElementById("historyMode"); |
michael@0 | 253 | let autoStart = document.getElementById("privateBrowsingAutoStart"); |
michael@0 | 254 | let pref = document.getElementById("browser.privatebrowsing.autostart"); |
michael@0 | 255 | if ((mode.value == "custom" && this._lastCheckState == autoStart.checked) || |
michael@0 | 256 | (mode.value == "remember" && !this._lastCheckState) || |
michael@0 | 257 | (mode.value == "dontremember" && this._lastCheckState)) { |
michael@0 | 258 | // These are all no-op changes, so we don't need to prompt. |
michael@0 | 259 | this._lastMode = mode.selectedIndex; |
michael@0 | 260 | this._lastCheckState = autoStart.hasAttribute('checked'); |
michael@0 | 261 | return; |
michael@0 | 262 | } |
michael@0 | 263 | |
michael@0 | 264 | if (!this._shouldPromptForRestart) { |
michael@0 | 265 | // We're performing a revert. Just let it happen. |
michael@0 | 266 | return; |
michael@0 | 267 | } |
michael@0 | 268 | |
michael@0 | 269 | const Cc = Components.classes, Ci = Components.interfaces; |
michael@0 | 270 | let brandName = document.getElementById("bundleBrand").getString("brandShortName"); |
michael@0 | 271 | let bundle = document.getElementById("bundlePreferences"); |
michael@0 | 272 | let msg = bundle.getFormattedString(autoStart.checked ? |
michael@0 | 273 | "featureEnableRequiresRestart" : "featureDisableRequiresRestart", |
michael@0 | 274 | [brandName]); |
michael@0 | 275 | let title = bundle.getFormattedString("shouldRestartTitle", [brandName]); |
michael@0 | 276 | let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); |
michael@0 | 277 | let shouldProceed = prompts.confirm(window, title, msg) |
michael@0 | 278 | if (shouldProceed) { |
michael@0 | 279 | let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] |
michael@0 | 280 | .createInstance(Ci.nsISupportsPRBool); |
michael@0 | 281 | Services.obs.notifyObservers(cancelQuit, "quit-application-requested", |
michael@0 | 282 | "restart"); |
michael@0 | 283 | shouldProceed = !cancelQuit.data; |
michael@0 | 284 | |
michael@0 | 285 | if (shouldProceed) { |
michael@0 | 286 | pref.value = autoStart.hasAttribute('checked'); |
michael@0 | 287 | document.documentElement.acceptDialog(); |
michael@0 | 288 | let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"] |
michael@0 | 289 | .getService(Ci.nsIAppStartup); |
michael@0 | 290 | appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); |
michael@0 | 291 | return; |
michael@0 | 292 | } |
michael@0 | 293 | } |
michael@0 | 294 | |
michael@0 | 295 | this._shouldPromptForRestart = false; |
michael@0 | 296 | |
michael@0 | 297 | if (this._lastCheckState) { |
michael@0 | 298 | autoStart.checked = "checked"; |
michael@0 | 299 | } else { |
michael@0 | 300 | autoStart.removeAttribute('checked'); |
michael@0 | 301 | } |
michael@0 | 302 | pref.value = autoStart.hasAttribute('checked'); |
michael@0 | 303 | mode.selectedIndex = this._lastMode; |
michael@0 | 304 | mode.doCommand(); |
michael@0 | 305 | |
michael@0 | 306 | this._shouldPromptForRestart = true; |
michael@0 | 307 | }, |
michael@0 | 308 | |
michael@0 | 309 | // HISTORY |
michael@0 | 310 | |
michael@0 | 311 | /** |
michael@0 | 312 | * Read the location bar enabled and suggestion prefs |
michael@0 | 313 | * @return Int value for suggestion menulist |
michael@0 | 314 | */ |
michael@0 | 315 | readSuggestionPref: function PPP_readSuggestionPref() |
michael@0 | 316 | { |
michael@0 | 317 | let getVal = function(aPref) |
michael@0 | 318 | document.getElementById("browser.urlbar." + aPref).value; |
michael@0 | 319 | |
michael@0 | 320 | // Suggest nothing if autocomplete is not enabled |
michael@0 | 321 | if (!getVal("autocomplete.enabled")) |
michael@0 | 322 | return -1; |
michael@0 | 323 | |
michael@0 | 324 | // Bottom 2 bits of default.behavior specify history/bookmark |
michael@0 | 325 | return getVal("default.behavior") & 3; |
michael@0 | 326 | }, |
michael@0 | 327 | |
michael@0 | 328 | /** |
michael@0 | 329 | * Write the location bar enabled and suggestion prefs when necessary |
michael@0 | 330 | * @return Bool value for enabled pref |
michael@0 | 331 | */ |
michael@0 | 332 | writeSuggestionPref: function PPP_writeSuggestionPref() |
michael@0 | 333 | { |
michael@0 | 334 | let menuVal = document.getElementById("locationBarSuggestion").value; |
michael@0 | 335 | let enabled = menuVal != -1; |
michael@0 | 336 | |
michael@0 | 337 | // Only update default.behavior if we're giving suggestions |
michael@0 | 338 | if (enabled) { |
michael@0 | 339 | // Put the selected menu item's value directly into the bottom 2 bits |
michael@0 | 340 | let behavior = document.getElementById("browser.urlbar.default.behavior"); |
michael@0 | 341 | behavior.value = behavior.value >> 2 << 2 | menuVal; |
michael@0 | 342 | } |
michael@0 | 343 | |
michael@0 | 344 | // Always update the enabled pref |
michael@0 | 345 | return enabled; |
michael@0 | 346 | }, |
michael@0 | 347 | |
michael@0 | 348 | /* |
michael@0 | 349 | * Preferences: |
michael@0 | 350 | * |
michael@0 | 351 | * places.history.enabled |
michael@0 | 352 | * - whether history is enabled or not |
michael@0 | 353 | * browser.formfill.enable |
michael@0 | 354 | * - true if entries in forms and the search bar should be saved, false |
michael@0 | 355 | * otherwise |
michael@0 | 356 | */ |
michael@0 | 357 | |
michael@0 | 358 | // COOKIES |
michael@0 | 359 | |
michael@0 | 360 | /* |
michael@0 | 361 | * Preferences: |
michael@0 | 362 | * |
michael@0 | 363 | * network.cookie.cookieBehavior |
michael@0 | 364 | * - determines how the browser should handle cookies: |
michael@0 | 365 | * 0 means enable all cookies |
michael@0 | 366 | * 1 means reject all third party cookies |
michael@0 | 367 | * 2 means disable all cookies |
michael@0 | 368 | * 3 means reject third party cookies unless at least one is already set for the eTLD |
michael@0 | 369 | * see netwerk/cookie/src/nsCookieService.cpp for details |
michael@0 | 370 | * network.cookie.lifetimePolicy |
michael@0 | 371 | * - determines how long cookies are stored: |
michael@0 | 372 | * 0 means keep cookies until they expire |
michael@0 | 373 | * 1 means ask how long to keep each cookie |
michael@0 | 374 | * 2 means keep cookies until the browser is closed |
michael@0 | 375 | */ |
michael@0 | 376 | |
michael@0 | 377 | /** |
michael@0 | 378 | * Reads the network.cookie.cookieBehavior preference value and |
michael@0 | 379 | * enables/disables the rest of the cookie UI accordingly, returning true |
michael@0 | 380 | * if cookies are enabled. |
michael@0 | 381 | */ |
michael@0 | 382 | readAcceptCookies: function () |
michael@0 | 383 | { |
michael@0 | 384 | var pref = document.getElementById("network.cookie.cookieBehavior"); |
michael@0 | 385 | var acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel"); |
michael@0 | 386 | var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu"); |
michael@0 | 387 | var keepUntil = document.getElementById("keepUntil"); |
michael@0 | 388 | var menu = document.getElementById("keepCookiesUntil"); |
michael@0 | 389 | |
michael@0 | 390 | // enable the rest of the UI for anything other than "disable all cookies" |
michael@0 | 391 | var acceptCookies = (pref.value != 2); |
michael@0 | 392 | |
michael@0 | 393 | acceptThirdPartyLabel.disabled = acceptThirdPartyMenu.disabled = !acceptCookies; |
michael@0 | 394 | keepUntil.disabled = menu.disabled = this._autoStartPrivateBrowsing || !acceptCookies; |
michael@0 | 395 | |
michael@0 | 396 | return acceptCookies; |
michael@0 | 397 | }, |
michael@0 | 398 | |
michael@0 | 399 | /** |
michael@0 | 400 | * Enables/disables the "keep until" label and menulist in response to the |
michael@0 | 401 | * "accept cookies" checkbox being checked or unchecked. |
michael@0 | 402 | */ |
michael@0 | 403 | writeAcceptCookies: function () |
michael@0 | 404 | { |
michael@0 | 405 | var accept = document.getElementById("acceptCookies"); |
michael@0 | 406 | var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu"); |
michael@0 | 407 | |
michael@0 | 408 | #ifdef RELEASE_BUILD |
michael@0 | 409 | // if we're enabling cookies, automatically select 'accept third party always' |
michael@0 | 410 | if (accept.checked) |
michael@0 | 411 | acceptThirdPartyMenu.selectedIndex = 0; |
michael@0 | 412 | |
michael@0 | 413 | return accept.checked ? 0 : 2; |
michael@0 | 414 | #else |
michael@0 | 415 | // if we're enabling cookies, automatically select 'accept third party from visited' |
michael@0 | 416 | if (accept.checked) |
michael@0 | 417 | acceptThirdPartyMenu.selectedIndex = 1; |
michael@0 | 418 | |
michael@0 | 419 | return accept.checked ? 3 : 2; |
michael@0 | 420 | #endif |
michael@0 | 421 | }, |
michael@0 | 422 | |
michael@0 | 423 | /** |
michael@0 | 424 | * Converts between network.cookie.cookieBehavior and the third-party cookie UI |
michael@0 | 425 | */ |
michael@0 | 426 | readAcceptThirdPartyCookies: function () |
michael@0 | 427 | { |
michael@0 | 428 | var pref = document.getElementById("network.cookie.cookieBehavior"); |
michael@0 | 429 | switch (pref.value) |
michael@0 | 430 | { |
michael@0 | 431 | case 0: |
michael@0 | 432 | return "always"; |
michael@0 | 433 | case 1: |
michael@0 | 434 | return "never"; |
michael@0 | 435 | case 2: |
michael@0 | 436 | return "never"; |
michael@0 | 437 | case 3: |
michael@0 | 438 | return "visited"; |
michael@0 | 439 | default: |
michael@0 | 440 | return undefined; |
michael@0 | 441 | } |
michael@0 | 442 | }, |
michael@0 | 443 | |
michael@0 | 444 | writeAcceptThirdPartyCookies: function () |
michael@0 | 445 | { |
michael@0 | 446 | var accept = document.getElementById("acceptThirdPartyMenu").selectedItem; |
michael@0 | 447 | switch (accept.value) |
michael@0 | 448 | { |
michael@0 | 449 | case "always": |
michael@0 | 450 | return 0; |
michael@0 | 451 | case "visited": |
michael@0 | 452 | return 3; |
michael@0 | 453 | case "never": |
michael@0 | 454 | return 1; |
michael@0 | 455 | default: |
michael@0 | 456 | return undefined; |
michael@0 | 457 | } |
michael@0 | 458 | }, |
michael@0 | 459 | |
michael@0 | 460 | /** |
michael@0 | 461 | * Displays fine-grained, per-site preferences for cookies. |
michael@0 | 462 | */ |
michael@0 | 463 | showCookieExceptions: function () |
michael@0 | 464 | { |
michael@0 | 465 | var bundlePreferences = document.getElementById("bundlePreferences"); |
michael@0 | 466 | var params = { blockVisible : true, |
michael@0 | 467 | sessionVisible : true, |
michael@0 | 468 | allowVisible : true, |
michael@0 | 469 | prefilledHost : "", |
michael@0 | 470 | permissionType : "cookie", |
michael@0 | 471 | windowTitle : bundlePreferences.getString("cookiepermissionstitle"), |
michael@0 | 472 | introText : bundlePreferences.getString("cookiepermissionstext") }; |
michael@0 | 473 | openDialog("chrome://browser/content/preferences/permissions.xul", |
michael@0 | 474 | "Browser:Permissions", |
michael@0 | 475 | "modal=yes", params); |
michael@0 | 476 | }, |
michael@0 | 477 | |
michael@0 | 478 | /** |
michael@0 | 479 | * Displays all the user's cookies in a dialog. |
michael@0 | 480 | */ |
michael@0 | 481 | showCookies: function (aCategory) |
michael@0 | 482 | { |
michael@0 | 483 | openDialog("chrome://browser/content/preferences/cookies.xul", |
michael@0 | 484 | "Browser:Cookies", |
michael@0 | 485 | "modal=yes", null); |
michael@0 | 486 | }, |
michael@0 | 487 | |
michael@0 | 488 | // CLEAR PRIVATE DATA |
michael@0 | 489 | |
michael@0 | 490 | /* |
michael@0 | 491 | * Preferences: |
michael@0 | 492 | * |
michael@0 | 493 | * privacy.sanitize.sanitizeOnShutdown |
michael@0 | 494 | * - true if the user's private data is cleared on startup according to the |
michael@0 | 495 | * Clear Private Data settings, false otherwise |
michael@0 | 496 | */ |
michael@0 | 497 | |
michael@0 | 498 | /** |
michael@0 | 499 | * Displays the Clear Private Data settings dialog. |
michael@0 | 500 | */ |
michael@0 | 501 | showClearPrivateDataSettings: function () |
michael@0 | 502 | { |
michael@0 | 503 | openDialog("chrome://browser/content/preferences/sanitize.xul", |
michael@0 | 504 | "modal=yes", null); |
michael@0 | 505 | }, |
michael@0 | 506 | |
michael@0 | 507 | |
michael@0 | 508 | /** |
michael@0 | 509 | * Displays a dialog from which individual parts of private data may be |
michael@0 | 510 | * cleared. |
michael@0 | 511 | */ |
michael@0 | 512 | clearPrivateDataNow: function (aClearEverything) |
michael@0 | 513 | { |
michael@0 | 514 | var ts = document.getElementById("privacy.sanitize.timeSpan"); |
michael@0 | 515 | var timeSpanOrig = ts.value; |
michael@0 | 516 | if (aClearEverything) |
michael@0 | 517 | ts.value = 0; |
michael@0 | 518 | |
michael@0 | 519 | const Cc = Components.classes, Ci = Components.interfaces; |
michael@0 | 520 | var glue = Cc["@mozilla.org/browser/browserglue;1"] |
michael@0 | 521 | .getService(Ci.nsIBrowserGlue); |
michael@0 | 522 | glue.sanitize(window); |
michael@0 | 523 | |
michael@0 | 524 | // reset the timeSpan pref |
michael@0 | 525 | if (aClearEverything) |
michael@0 | 526 | ts.value = timeSpanOrig; |
michael@0 | 527 | }, |
michael@0 | 528 | |
michael@0 | 529 | /** |
michael@0 | 530 | * Enables or disables the "Settings..." button depending |
michael@0 | 531 | * on the privacy.sanitize.sanitizeOnShutdown preference value |
michael@0 | 532 | */ |
michael@0 | 533 | _updateSanitizeSettingsButton: function () { |
michael@0 | 534 | var settingsButton = document.getElementById("clearDataSettings"); |
michael@0 | 535 | var sanitizeOnShutdownPref = document.getElementById("privacy.sanitize.sanitizeOnShutdown"); |
michael@0 | 536 | |
michael@0 | 537 | settingsButton.disabled = !sanitizeOnShutdownPref.value; |
michael@0 | 538 | } |
michael@0 | 539 | |
michael@0 | 540 | }; |