mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 722983 - Fix the back-end handling of permanent private browsing mode through the per-window private browsing APIs; r=jdm
--HG-- extra : rebase_source : 31358b29c5b3c5f6921598ea3246aede62ca78db
This commit is contained in:
parent
da91f5d5f5
commit
b9acc431b5
@ -33,7 +33,7 @@ browser.jar:
|
||||
content/browser/preferences/permissions.js
|
||||
* content/browser/preferences/preferences.xul
|
||||
content/browser/preferences/privacy.xul
|
||||
content/browser/preferences/privacy.js
|
||||
* content/browser/preferences/privacy.js
|
||||
content/browser/preferences/sanitize.xul
|
||||
content/browser/preferences/security.xul
|
||||
content/browser/preferences/security.js
|
||||
|
@ -222,18 +222,22 @@ var gPrivacyPane = {
|
||||
|
||||
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;
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
|
||||
// If activating from within the private browsing mode, reset the
|
||||
// private session
|
||||
if (prefValue && privateBrowsingService.privateBrowsingEnabled)
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
privateBrowsingService.privateBrowsingEnabled = prefValue;
|
||||
#endif
|
||||
|
||||
keepCurrentSession.reset();
|
||||
}
|
||||
},
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#ifdef USEWEAKREFS
|
||||
#include "nsIWeakReference.h"
|
||||
@ -898,8 +899,10 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
||||
}
|
||||
|
||||
if (windowIsNew) {
|
||||
// See if the caller has requested a private browsing window.
|
||||
// See if the caller has requested a private browsing window, or if all
|
||||
// windows should be private.
|
||||
bool isPrivateBrowsingWindow =
|
||||
Preferences::GetBool("browser.privatebrowsing.autostart") ||
|
||||
!!(chromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW);
|
||||
// Otherwise, propagate the privacy status of the parent window, if
|
||||
// available, to the child.
|
||||
|
@ -4,6 +4,10 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ["PrivateBrowsingUtils"];
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const kAutoStartPref = "browser.components.autostart";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
@ -17,7 +21,7 @@ var PrivateBrowsingUtils = {
|
||||
|
||||
get permanentPrivateBrowsing() {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
return false; // permanent PB is not supported for now
|
||||
return Services.prefs.getBoolPref(kAutoStart, false);
|
||||
#else
|
||||
try {
|
||||
return Cc["@mozilla.org/privatebrowsing;1"].
|
||||
@ -29,3 +33,20 @@ var PrivateBrowsingUtils = {
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
function autoStartObserver(aSubject, aTopic, aData) {
|
||||
var newValue = Services.prefs.getBoolPref(kAutoStart);
|
||||
var windowsEnum = Services.wm.getEnumerator(null);
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
var window = windowsEnum.getNext();
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext)
|
||||
.usePrivateBrowsing = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
Services.prefs.addObserver(kAutoStartPref, autoStartObserver, false);
|
||||
#endif
|
||||
|
||||
|
@ -354,18 +354,26 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ensure that we propagate any existing private browsing status
|
||||
// from the parent, even if it will not actually be used
|
||||
// as a parent value.
|
||||
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(aParent);
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(domWin);
|
||||
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(webNav);
|
||||
// Enforce the Private Browsing autoStart pref first.
|
||||
bool isPrivateBrowsingWindow =
|
||||
Preferences::GetBool("browser.privatebrowsing.autostart");
|
||||
if (!isPrivateBrowsingWindow) {
|
||||
// Ensure that we propagate any existing private browsing status
|
||||
// from the parent, even if it will not actually be used
|
||||
// as a parent value.
|
||||
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(aParent);
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(domWin);
|
||||
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(webNav);
|
||||
if (parentContext) {
|
||||
isPrivateBrowsingWindow = parentContext->UsePrivateBrowsing();
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> newDomWin =
|
||||
do_GetInterface(NS_ISUPPORTS_CAST(nsIBaseWindow*, window));
|
||||
nsCOMPtr<nsIWebNavigation> newWebNav = do_GetInterface(newDomWin);
|
||||
nsCOMPtr<nsILoadContext> thisContext = do_GetInterface(newWebNav);
|
||||
if (parentContext && thisContext) {
|
||||
thisContext->SetUsePrivateBrowsing(parentContext->UsePrivateBrowsing());
|
||||
if (thisContext) {
|
||||
thisContext->SetUsePrivateBrowsing(isPrivateBrowsingWindow);
|
||||
}
|
||||
|
||||
window.swap(*aResult); // transfer reference
|
||||
|
Loading…
Reference in New Issue
Block a user