diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index cd46b678ad5..36e6b70b619 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1218,7 +1218,7 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) { focusElement(content); if (gURLBar) - gURLBar.setAttribute("emptytext", gURLBar.getAttribute("delayedemptytext")); + gURLBar.setAttribute("emptytext", gURLBarEmptyText.value); gNavToolbox.customizeDone = BrowserToolboxCustomizeDone; gNavToolbox.customizeChange = BrowserToolboxCustomizeChange; @@ -1233,6 +1233,8 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) { gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton, false); + gPrefService.addObserver(gURLBarEmptyText.domain, gURLBarEmptyText, false); + var homeButton = document.getElementById("home-button"); gHomeButton.updateTooltip(homeButton); gHomeButton.updatePersonalToolbarStyle(homeButton); @@ -1401,6 +1403,7 @@ function BrowserShutdown() gPrefService.removeObserver(gAutoHideTabbarPrefListener.domain, gAutoHideTabbarPrefListener); gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton); + gPrefService.removeObserver(gURLBarEmptyText.domain, gURLBarEmptyText); } catch (ex) { Components.utils.reportError(ex); } @@ -3290,7 +3293,7 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) { if (aToolboxChanged) { gURLBar = document.getElementById("urlbar"); if (gURLBar) - gURLBar.emptyText = gURLBar.getAttribute("delayedemptytext"); + gURLBar.emptyText = gURLBarEmptyText.value; gProxyFavIcon = document.getElementById("page-proxy-favicon"); gHomeButton.updateTooltip(); @@ -6952,9 +6955,8 @@ let gPrivateBrowsingUI = { if (this._privateBrowsingAutoStarted) { // Disable the menu item in auto-start mode - let pbMenuItem = document.getElementById("privateBrowsingItem"); - if (pbMenuItem) - pbMenuItem.setAttribute("disabled", "true"); + document.getElementById("privateBrowsingItem") + .setAttribute("disabled", "true"); document.getElementById("Tools:PrivateBrowsing") .setAttribute("disabled", "true"); } @@ -6994,15 +6996,19 @@ let gPrivateBrowsingUI = { docElement.setAttribute("browsingmode", "normal"); } + // Enable the menu item in after exiting the auto-start mode + document.getElementById("privateBrowsingItem") + .removeAttribute("disabled"); + document.getElementById("Tools:PrivateBrowsing") + .removeAttribute("disabled"); + this._privateBrowsingAutoStarted = false; }, _setPBMenuTitle: function PBUI__setPBMenuTitle(aMode) { let pbMenuItem = document.getElementById("privateBrowsingItem"); - if (pbMenuItem) { - pbMenuItem.setAttribute("label", pbMenuItem.getAttribute(aMode + "label")); - pbMenuItem.setAttribute("accesskey", pbMenuItem.getAttribute(aMode + "accesskey")); - } + pbMenuItem.setAttribute("label", pbMenuItem.getAttribute(aMode + "label")); + pbMenuItem.setAttribute("accesskey", pbMenuItem.getAttribute(aMode + "accesskey")); }, toggleMode: function PBUI_toggleMode() { @@ -7019,3 +7025,37 @@ let gPrivateBrowsingUI = { return this._privateBrowsingService.privateBrowsingEnabled; } }; + +let gURLBarEmptyText = { + domain: "browser.urlbar.", + + observe: function UBET_observe(aSubject, aTopic, aPrefName) { + if (aTopic == "nsPref:changed") { + switch (aPrefName) { + case "browser.urlbar.autocomplete.enabled": + case "browser.urlbar.default.behavior": + gURLBar.emptyText = this.value; + break; + } + } + }, + + get value UBET_get_value() { + let type = "none"; + if (gPrefService.getBoolPref("browser.urlbar.autocomplete.enabled")) { + // Bottom 2 bits of default.behavior specify history/bookmark + switch (gPrefService.getIntPref("browser.urlbar.default.behavior") & 3) { + case 0: + type = "bookmarkhistory"; + break; + case 1: + type = "history"; + break; + case 2: + type = "bookmark"; + break; + } + } + return gURLBar.getAttribute(type + "emptytext"); + } +}; diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 5011fc0db9a..50e985c6e5b 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -350,7 +350,10 @@ 0; + this.onchangeHistoryDaysCheck(); + document.getElementById("rememberDownloads").checked = disabled ? false : + this.readDownloadRetention(); + document.getElementById("rememberForms").checked = disabled ? false : + document.getElementById("browser.formfill.enable").value; + + if (!disabled) { + // adjust the Settings button for sanitizeOnShutdown + this._updateSanitizeSettingsButton(); + } + } + }, + + // PRIVATE BROWSING + + /** + * Install the observer for the auto-start private browsing mode pref. + */ + initAutoStartPrivateBrowsingObserver: function PPP_initAutoStartPrivateBrowsingObserver() + { + let prefService = document.getElementById("privacyPreferences") + .service + .QueryInterface(Components.interfaces.nsIPrefBranch2); + prefService.addObserver("browser.privatebrowsing.autostart", + this.autoStartPrivateBrowsingObserver, + true); + }, + + autoStartPrivateBrowsingObserver: + { + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver, + Components.interfaces.nsISupportsWeakReference]), + + observe: function PPP_observe(aSubject, aTopic, aData) + { + let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"]. + getService(Components.interfaces.nsIPrivateBrowsingService); + + // Toggle the private browsing mode without switching the session + let prefValue = document.getElementById("browser.privatebrowsing.autostart").value; + let keepCurrentSession = document.getElementById("browser.privatebrowsing.keep_current_session"); + keepCurrentSession.value = true; + // If activating from within the private browsing mode, reset the + // private session + if (prefValue && privateBrowsingService.privateBrowsingEnabled) + privateBrowsingService.privateBrowsingEnabled = false; + privateBrowsingService.privateBrowsingEnabled = prefValue; + keepCurrentSession.reset(); + } }, // HISTORY @@ -155,7 +377,8 @@ var gPrivacyPane = { var textbox = document.getElementById("historyDays"); var checkbox = document.getElementById("rememberHistoryDays"); - pref.value = checkbox.checked ? mirror.value : 0; + if (!this._autoStartPrivateBrowsing) + pref.value = checkbox.checked ? mirror.value : 0; textbox.disabled = !checkbox.checked; }, @@ -226,7 +449,8 @@ var gPrivacyPane = { // enable the rest of the UI for anything other than "disable all cookies" var acceptCookies = (pref.value != 2); - keepUntil.disabled = menu.disabled = acceptThirdParty.disabled = !acceptCookies; + acceptThirdParty.disabled = !acceptCookies; + keepUntil.disabled = menu.disabled = this._autoStartPrivateBrowsing || !acceptCookies; return acceptCookies; }, @@ -307,7 +531,28 @@ var gPrivacyPane = { "", null); }, - + + /** + * 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); + glue.sanitize(window || null); + + // reset the timeSpan pref + if (aClearEverything) + ts.value = timeSpanOrig; + }, + /** * Enables or disables the "Settings..." button depending * on the privacy.sanitize.sanitizeOnShutdown preference value diff --git a/browser/components/preferences/privacy.xul b/browser/components/preferences/privacy.xul index 30b1a611b28..3e8efd61b9b 100644 --- a/browser/components/preferences/privacy.xul +++ b/browser/components/preferences/privacy.xul @@ -49,7 +49,8 @@ ]> + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml"> + + + + + @@ -112,6 +126,144 @@ + + + + + + + + + + + + + + + + + + &rememberDescription.label; + + &rememberActions.pre.label;&rememberActions.clearHistory.label;&rememberActions.middle.label;&rememberActions.removeCookies.label;&rememberActions.post.label; + + + + + + + + + &dontrememberDescription.label; + + &dontrememberActions.pre.label;&dontrememberActions.clearHistory.label;&dontrememberActions.post.label; + + + + + + + + + + + + + + + + + + + + +