[tbb-commits] [tor-browser] 04/81: Bug 1768907 - Part 1: Make browser.privatebrowsing.autostart a static pref. r=handyman, necko-reviewers

gitolite role git at cupani.torproject.org
Tue Oct 18 16:11:58 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch tor-browser-102.4.0esr-12.0-1
in repository tor-browser.

commit 99c9c2dadb327182f33d16395660405691b94ce7
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Thu Sep 22 00:26:17 2022 +0000

    Bug 1768907 - Part 1: Make browser.privatebrowsing.autostart a static pref. r=handyman,necko-reviewers
    
    Differential Revision: https://phabricator.services.mozilla.com/D157843
---
 docshell/base/CanonicalBrowsingContext.cpp           | 3 ++-
 extensions/auth/nsHttpNegotiateAuth.cpp              | 6 ++----
 modules/libpref/init/StaticPrefList.yaml             | 6 ++++++
 modules/libpref/init/all.js                          | 3 ---
 netwerk/protocol/http/nsHttpNTLMAuth.cpp             | 6 ++----
 toolkit/components/windowwatcher/nsWindowWatcher.cpp | 5 +++--
 widget/windows/nsWindow.cpp                          | 3 ++-
 xpfe/appshell/nsAppShellService.cpp                  | 3 ++-
 8 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp
index 86f8c5d7eef9..63f1ede7635b 100644
--- a/docshell/base/CanonicalBrowsingContext.cpp
+++ b/docshell/base/CanonicalBrowsingContext.cpp
@@ -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"
@@ -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) {
diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp
index fedf40026e1b..d04c7af7aa72 100644
--- a/extensions/auth/nsHttpNegotiateAuth.cpp
+++ b/extensions/auth/nsHttpNegotiateAuth.cpp
@@ -50,6 +50,7 @@
 #include "mozilla/net/HttpAuthUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/net/DNS.h"
+#include "mozilla/StaticPrefs_browser.h"
 
 using mozilla::Base64Decode;
 
@@ -100,10 +101,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;
     }
   }
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
index 34f47f3e51cd..221962598cd3 100644
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1314,6 +1314,12 @@
   value: 5000
   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
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index db545cd135c5..94726098b214 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4400,9 +4400,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.
diff --git a/netwerk/protocol/http/nsHttpNTLMAuth.cpp b/netwerk/protocol/http/nsHttpNTLMAuth.cpp
index 30de77d7ca19..f48b2ef0caa5 100644
--- a/netwerk/protocol/http/nsHttpNTLMAuth.cpp
+++ b/netwerk/protocol/http/nsHttpNTLMAuth.cpp
@@ -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 {
@@ -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;
     }
   }
diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
index 0f8f1560e734..9a71f9329e7b 100644
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -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"
@@ -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();
@@ -1127,7 +1128,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
     }
 
     bool autoPrivateBrowsing =
-        Preferences::GetBool("browser.privatebrowsing.autostart");
+        StaticPrefs::browser_privatebrowsing_autostart();
 
     if (!autoPrivateBrowsing &&
         (chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)) {
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
index ff4a1aacf06d..8ea99aa0b87d 100644
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -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"
@@ -1050,7 +1051,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
   }
 
   if (aInitData->mIsPrivate) {
-    if (Preferences::GetBool("browser.privacySegmentation.enabled", false)) {
+    if (!StaticPrefs::browser_privatebrowsing_autostart()) {
       RefPtr<IPropertyStore> pPropStore;
       if (!FAILED(SHGetPropertyStoreForWindow(mWnd, IID_IPropertyStore,
                                               getter_AddRefs(pPropStore)))) {
diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp
index adf8d764ad49..384b636d421a 100644
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -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"
@@ -722,7 +723,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

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list