44 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
51 _autoStartPrivateBrowsing:
false,
59 this._updateHistoryDaysUI();
60 this._updateSanitizeSettingsButton();
61 this.initializeHistoryMode();
62 this.updateHistoryModePane();
63 this.updatePrivacyMicroControls();
64 this.initAutoStartPrivateBrowsingObserver();
81 "browser.history_expire_days",
82 "browser.history_expire_days_min",
83 "browser.download.manager.retention",
84 "browser.formfill.enable",
85 "network.cookie.cookieBehavior",
86 "network.cookie.lifetimePolicy",
87 "privacy.sanitize.sanitizeOnShutdown"
98 "rememberHistoryDays",
115 _checkDefaultValues:
function(aPrefs) {
116 for (let
i = 0;
i < aPrefs.length; ++
i) {
117 let
pref = document.getElementById(aPrefs[
i]);
118 if (pref.value != pref.defaultValue)
127 initializeHistoryMode:
function PPP_initializeHistoryMode()
130 let getVal =
function (aPref)
131 document.getElementById(aPref).value;
133 if (this._checkDefaultValues(this.prefsForDefault)) {
134 if (getVal(
"browser.privatebrowsing.autostart"))
135 mode =
"dontremember";
142 document.getElementById(
"historyMode").value = mode;
148 updateHistoryModePane:
function PPP_updateHistoryModePane()
150 let selectedIndex = -1;
151 switch (document.getElementById(
"historyMode").value) {
162 document.getElementById(
"historyPane").selectedIndex = selectedIndex;
169 updateHistoryModePrefs:
function PPP_updateHistoryModePrefs()
171 let
pref = document.getElementById(
"browser.privatebrowsing.autostart");
172 switch (document.getElementById(
"historyMode").value) {
177 let rememberHistoryCheckbox = document.getElementById(
"rememberHistoryDays");
178 if (!rememberHistoryCheckbox.checked) {
179 rememberHistoryCheckbox.checked =
true;
180 this.onchangeHistoryDaysCheck();
184 if (!document.getElementById(
"rememberDownloads").checked)
185 document.getElementById(
"browser.download.manager.retention").value = 2;
188 document.getElementById(
"browser.formfill.enable").value =
true;
191 document.getElementById(
"network.cookie.cookieBehavior").value = 0;
193 document.getElementById(
"network.cookie.lifetimePolicy").value = 0;
196 document.getElementById(
"privacy.sanitize.sanitizeOnShutdown").value =
false;
208 updatePrivacyMicroControls:
function PPP_updatePrivacyMicroControls()
210 if (document.getElementById(
"historyMode").value ==
"custom") {
211 let disabled = this._autoStartPrivateBrowsing =
216 this.dependentControls
217 .forEach(
function (aElement)
218 document.getElementById(aElement).disabled = disabled);
221 this.readAcceptCookies();
222 document.getElementById(
"keepCookiesUntil").value = disabled ? 2 :
223 document.getElementById(
"network.cookie.lifetimePolicy").value;
226 document.getElementById(
"alwaysClear").checked = disabled ?
false :
227 document.getElementById(
"privacy.sanitize.sanitizeOnShutdown").value;
230 document.getElementById(
"rememberHistoryDays").checked = disabled ?
false :
231 document.getElementById(
"browser.history_expire_days").value > 0;
232 this.onchangeHistoryDaysCheck();
233 document.getElementById(
"rememberDownloads").checked = disabled ?
false :
234 this.readDownloadRetention();
235 document.getElementById(
"rememberForms").checked = disabled ?
false :
236 document.getElementById(
"browser.formfill.enable").value;
240 this._updateSanitizeSettingsButton();
250 initAutoStartPrivateBrowsingObserver:
function PPP_initAutoStartPrivateBrowsingObserver()
252 let prefService = document.getElementById(
"privacyPreferences")
254 .QueryInterface(Components.interfaces.nsIPrefBranch2);
255 prefService.addObserver(
"browser.privatebrowsing.autostart",
256 this.autoStartPrivateBrowsingObserver,
260 autoStartPrivateBrowsingObserver:
262 QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver,
263 Components.interfaces.nsISupportsWeakReference]),
267 let privateBrowsingService = Components.classes[
"@mozilla.org/privatebrowsing;1"].
268 getService(Components.interfaces.nsIPrivateBrowsingService);
271 let prefValue = document.getElementById(
"browser.privatebrowsing.autostart").value;
272 let keepCurrentSession = document.getElementById(
"browser.privatebrowsing.keep_current_session");
273 keepCurrentSession.value =
true;
276 if (prefValue && privateBrowsingService.privateBrowsingEnabled)
277 privateBrowsingService.privateBrowsingEnabled =
false;
278 privateBrowsingService.privateBrowsingEnabled = prefValue;
279 keepCurrentSession.reset();
289 readSuggestionPref:
function PPP_readSuggestionPref()
291 let getVal =
function(aPref)
292 document.getElementById(
"browser.urlbar." + aPref).value;
295 if (!getVal(
"autocomplete.enabled"))
299 return getVal(
"default.behavior") & 3;
306 writeSuggestionPref:
function PPP_writeSuggestionPref()
308 let menuVal = document.getElementById(
"locationBarSuggestion").value;
309 let enabled = menuVal != -1;
314 let behavior = document.getElementById(
"browser.urlbar.default.behavior");
315 behavior.value = behavior.value >> 2 << 2 | menuVal;
356 _updateHistoryDaysUI:
function ()
358 var
pref = document.getElementById(
"browser.history_expire_days");
359 var mirror = document.getElementById(
"browser.history_expire_days.mirror");
360 var pref_min = document.getElementById(
"browser.history_expire_days_min");
361 var textbox = document.getElementById(
"historyDays");
362 var checkbox = document.getElementById(
"rememberHistoryDays");
365 if (mirror.value ===
null || mirror.value != pref.value ||
366 (mirror.value == pref.value && mirror.value == 0) )
367 mirror.value = pref.value ? pref.value : pref.defaultValue;
369 checkbox.checked = (pref.value > 0);
370 textbox.disabled = !checkbox.checked;
378 onchangeHistoryDaysCheck:
function ()
380 var
pref = document.getElementById(
"browser.history_expire_days");
381 var mirror = document.getElementById(
"browser.history_expire_days.mirror");
382 var textbox = document.getElementById(
"historyDays");
383 var checkbox = document.getElementById(
"rememberHistoryDays");
385 if (!this._autoStartPrivateBrowsing)
386 pref.value = checkbox.checked ? mirror.value : 0;
387 textbox.disabled = !checkbox.checked;
395 onkeyupHistoryDaysText:
function ()
397 var textbox = document.getElementById(
"historyDays");
398 var checkbox = document.getElementById(
"rememberHistoryDays");
400 checkbox.checked = textbox.value != 0;
408 readDownloadRetention:
function ()
410 var
pref = document.getElementById(
"browser.download.manager.retention");
411 return (pref.value == 2);
418 writeDownloadRetention:
function ()
420 var checkbox = document.getElementById(
"rememberDownloads");
421 return checkbox.checked ? 2 : 0;
447 readAcceptCookies:
function ()
449 var
pref = document.getElementById(
"network.cookie.cookieBehavior");
450 var acceptThirdParty = document.getElementById(
"acceptThirdParty");
451 var keepUntil = document.getElementById(
"keepUntil");
452 var
menu = document.getElementById(
"keepCookiesUntil");
455 var acceptCookies = (pref.value != 2);
457 acceptThirdParty.disabled = !acceptCookies;
458 keepUntil.disabled = menu.disabled = this._autoStartPrivateBrowsing || !acceptCookies;
460 return acceptCookies;
463 readAcceptThirdPartyCookies:
function ()
465 var
pref = document.getElementById(
"network.cookie.cookieBehavior");
466 return pref.value == 0;
473 writeAcceptCookies:
function ()
475 var accept = document.getElementById(
"acceptCookies");
476 var acceptThirdParty = document.getElementById(
"acceptThirdParty");
480 acceptThirdParty.checked =
true;
482 return accept.checked ? (acceptThirdParty.checked ? 0 : 1) : 2;
485 writeAcceptThirdPartyCookies:
function ()
487 var accept = document.getElementById(
"acceptCookies");
488 var acceptThirdParty = document.getElementById(
"acceptThirdParty");
489 return accept.checked ? (acceptThirdParty.checked ? 0 : 1) : 2;
495 showCookieExceptions:
function ()
497 var bundlePreferences = document.getElementById(
"bundlePreferences");
498 var params = { blockVisible :
true,
499 sessionVisible :
true,
502 permissionType :
"cookie",
503 windowTitle : bundlePreferences.getString(
"cookiepermissionstitle"),
504 introText : bundlePreferences.getString(
"cookiepermissionstext") };
505 document.documentElement.openWindow(
"Browser:Permissions",
506 "chrome://browser/content/preferences/permissions.xul",
513 showCookies:
function (aCategory)
515 document.documentElement.openWindow(
"Browser:Cookies",
516 "chrome://browser/content/preferences/cookies.xul",
533 showClearPrivateDataSettings:
function ()
535 document.documentElement.openSubDialog(
"chrome://browser/content/preferences/sanitize.xul",
544 clearPrivateDataNow:
function (aClearEverything)
546 var
ts = document.getElementById(
"privacy.sanitize.timeSpan");
547 var timeSpanOrig = ts.value;
548 if (aClearEverything)
551 const Cc = Components.classes,
Ci = Components.interfaces;
552 var glue =
Cc[
"@mozilla.org/browser/browserglue;1"]
553 .getService(
Ci.nsIBrowserGlue);
557 if (aClearEverything)
558 ts.value = timeSpanOrig;
565 _updateSanitizeSettingsButton:
function () {
566 var settingsButton = document.getElementById(
"clearDataSettings");
567 var sanitizeOnShutdownPref = document.getElementById(
"privacy.sanitize.sanitizeOnShutdown");
569 settingsButton.disabled = !sanitizeOnShutdownPref.value;
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe