Skip to content

Commit

Permalink
Bug 1768907 - Part 1: Make browser.privatebrowsing.autostart a static…
Browse files Browse the repository at this point in the history
… pref. r=handyman,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D157843
  • Loading branch information
PieroV committed Sep 22, 2022
1 parent 93d6b11 commit aa21b01
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#endif
#include "mozilla/net/DocumentLoadListener.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_docshell.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/Telemetry.h"
Expand Down Expand Up @@ -100,7 +101,7 @@ static void DecreasePrivateCount() {
("%s: Private browsing context count %d -> %d", __func__,
gNumberOfPrivateContexts + 1, gNumberOfPrivateContexts));
if (!gNumberOfPrivateContexts &&
!mozilla::Preferences::GetBool("browser.privatebrowsing.autostart")) {
!mozilla::StaticPrefs::browser_privatebrowsing_autostart()) {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
Expand Down
6 changes: 2 additions & 4 deletions extensions/auth/nsHttpNegotiateAuth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "mozilla/net/HttpAuthUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/net/DNS.h"
#include "mozilla/StaticPrefs_browser.h"

using mozilla::Base64Decode;

Expand Down Expand Up @@ -91,10 +92,7 @@ static bool TestNotInPBMode(nsIHttpAuthenticableChannel* authChannel,
// When the "Never remember history" option is set, all channels are
// set PB mode flag, but here we want to make an exception, users
// want their credentials go out.
bool dontRememberHistory;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.privatebrowsing.autostart",
&dontRememberHistory)) &&
dontRememberHistory) {
if (mozilla::StaticPrefs::browser_privatebrowsing_autostart()) {
return true;
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,12 @@
value: 3600
mirror: always

# Whether to start the private browsing mode at application startup
- name: browser.privatebrowsing.autostart
type: bool
value: false
mirror: always

# Force usage of in-memory (rather than file on disk) media cache for video streaming when private browsing
- name: browser.privatebrowsing.forceMediaMemoryCache
type: bool
Expand Down
3 changes: 0 additions & 3 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4357,9 +4357,6 @@ pref("dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", false
pref("dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", false, locked);
#endif

// Whether to start the private browsing mode at application startup
pref("browser.privatebrowsing.autostart", false);

// Whether sites require the open-protocol-handler permission to open a
//preferred external application for a protocol. If a site doesn't have
// permission we will show a prompt.
Expand Down
6 changes: 2 additions & 4 deletions netwerk/protocol/http/nsHttpNTLMAuth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "mozilla/net/HttpAuthUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/net/DNS.h"
#include "mozilla/StaticPrefs_browser.h"

namespace mozilla {
namespace net {
Expand Down Expand Up @@ -102,10 +103,7 @@ static bool CanUseDefaultCredentials(nsIHttpAuthenticableChannel* channel,
return true;
}

bool dontRememberHistory;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.privatebrowsing.autostart",
&dontRememberHistory)) &&
!dontRememberHistory) {
if (!StaticPrefs::browser_privatebrowsing_autostart()) {
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions toolkit/components/windowwatcher/nsWindowWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "mozilla/NullPrincipal.h"
#include "mozilla/Preferences.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_full_screen_api.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Storage.h"
Expand Down Expand Up @@ -494,7 +495,7 @@ nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,

bool isFissionWindow = FissionAutostart();
bool isPrivateBrowsingWindow =
Preferences::GetBool("browser.privatebrowsing.autostart");
StaticPrefs::browser_privatebrowsing_autostart();

nsCOMPtr<nsPIDOMWindowOuter> parentWindowOuter;
RefPtr<BrowsingContext> parentBC = aOpenWindowInfo->GetParent();
Expand Down Expand Up @@ -1166,7 +1167,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
targetBC->OriginAttributesRef()));

bool autoPrivateBrowsing =
Preferences::GetBool("browser.privatebrowsing.autostart");
StaticPrefs::browser_privatebrowsing_autostart();

if (!autoPrivateBrowsing &&
(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)) {
Expand Down
3 changes: 2 additions & 1 deletion widget/windows/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/SwipeTracker.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/TimeStamp.h"
Expand Down Expand Up @@ -1107,7 +1108,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
// we choose to make it look like regular Firefox in terms of the icon
// it uses (which also means we shouldn't use the Private Browsing
// AUMID).
!Preferences::GetBool("browser.privatebrowsing.autostart", false)) {
!StaticPrefs::browser_privatebrowsing_autostart()) {
RefPtr<IPropertyStore> pPropStore;
if (!FAILED(SHGetPropertyStoreForWindow(mWnd, IID_IPropertyStore,
getter_AddRefs(pPropStore)))) {
Expand Down
3 changes: 2 additions & 1 deletion xpfe/appshell/nsAppShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StartupTimeline.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/intl/LocaleService.h"
#include "mozilla/dom/BrowsingContext.h"
Expand Down Expand Up @@ -719,7 +720,7 @@ nsresult nsAppShellService::JustCreateTopWindow(

// Enforce the Private Browsing autoStart pref first.
bool isPrivateBrowsingWindow =
Preferences::GetBool("browser.privatebrowsing.autostart");
StaticPrefs::browser_privatebrowsing_autostart();

if (aChromeMask & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) {
// Caller requested a private window
Expand Down

0 comments on commit aa21b01

Please sign in to comment.