From 50ad087351df7de9d92cb5e7b2176d9bde36fcb7 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 7 Oct 2021 21:38:26 +0000 Subject: [PATCH 1/3] Issue #1721 - Implement GlobalPrivacyControl (and get rid of failed DoNotTrack) --- dom/base/Navigator.cpp | 18 +++--------------- dom/base/Navigator.h | 2 +- dom/base/nsContentUtils.cpp | 10 +++++----- dom/base/nsContentUtils.h | 6 +++--- dom/interfaces/base/nsIDOMNavigator.idl | 1 - dom/webidl/Navigator.webidl | 8 +++++--- dom/webidl/WorkerNavigator.webidl | 1 + dom/workers/WorkerNavigator.h | 6 ++++++ modules/libpref/init/all.js | 4 ++-- netwerk/protocol/http/nsHttpAtomList.h | 2 +- netwerk/protocol/http/nsHttpChannel.cpp | 15 +++++---------- netwerk/protocol/http/nsHttpChannel.h | 2 +- netwerk/protocol/http/nsHttpHandler.cpp | 12 ++++++------ netwerk/protocol/http/nsHttpHandler.h | 4 ++-- 14 files changed, 41 insertions(+), 50 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index febe1f1a3a..a636a31ecb 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -632,22 +632,10 @@ Navigator::GetBuildID(nsAString& aBuildID) return NS_OK; } -NS_IMETHODIMP -Navigator::GetDoNotTrack(nsAString &aResult) +bool +Navigator::GlobalPrivacyControl() { - bool doNotTrack = nsContentUtils::DoNotTrackEnabled(); - if (!doNotTrack) { - nsCOMPtr loadContext = do_GetInterface(mWindow); - doNotTrack = loadContext && loadContext->UseTrackingProtection(); - } - - if (doNotTrack) { - aResult.AssignLiteral("1"); - } else { - aResult.AssignLiteral("unspecified"); - } - - return NS_OK; + return nsContentUtils::GPCEnabled(); } bool diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 5738cd2b5a..3a0c9cc45f 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -131,7 +131,7 @@ public: nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv); nsPluginArray* GetPlugins(ErrorResult& aRv); Permissions* GetPermissions(ErrorResult& aRv); - // The XPCOM GetDoNotTrack is ok + bool GlobalPrivacyControl(); Geolocation* GetGeolocation(ErrorResult& aRv); static void AppName(nsAString& aAppName, bool aUsePrefOverriddenValue); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 69534f9149..29cc1bce47 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -309,7 +309,7 @@ bool nsContentUtils::sFragmentParsingActive = false; bool nsContentUtils::sDOMWindowDumpEnabled; #endif -bool nsContentUtils::sDoNotTrackEnabled = false; +bool nsContentUtils::sGPCEnabled = false; mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump"); @@ -626,8 +626,8 @@ nsContentUtils::Init() "browser.dom.window.dump.enabled"); #endif - Preferences::AddBoolVarCache(&sDoNotTrackEnabled, - "privacy.donottrackheader.enabled", false); + Preferences::AddBoolVarCache(&sGPCEnabled, + "privacy.GPCheader.enabled", false); Preferences::AddBoolVarCache(&sUseActivityCursor, "ui.use_activity_cursor", false); @@ -7337,9 +7337,9 @@ nsContentUtils::DOMWindowDumpEnabled() } bool -nsContentUtils::DoNotTrackEnabled() +nsContentUtils::GPCEnabled() { - return nsContentUtils::sDoNotTrackEnabled; + return nsContentUtils::sGPCEnabled; } mozilla::LogModule* diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index a60b102c53..6e9f23054a 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2432,9 +2432,9 @@ public: static bool DOMWindowDumpEnabled(); /** - * Returns true if the privacy.donottrackheader.enabled pref is set. + * Returns true if the privacy.GPCheader.enabled pref is set. */ - static bool DoNotTrackEnabled(); + static bool GPCEnabled(); /** * Returns a LogModule that dump calls from content script are logged to. @@ -2971,7 +2971,7 @@ private: #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP)) static bool sDOMWindowDumpEnabled; #endif - static bool sDoNotTrackEnabled; + static bool sGPCEnabled; static mozilla::LazyLogModule sDOMDumpLog; }; diff --git a/dom/interfaces/base/nsIDOMNavigator.idl b/dom/interfaces/base/nsIDOMNavigator.idl index 5fd16b8aeb..d4a06c21dc 100644 --- a/dom/interfaces/base/nsIDOMNavigator.idl +++ b/dom/interfaces/base/nsIDOMNavigator.idl @@ -22,5 +22,4 @@ interface nsIDOMNavigator : nsISupports readonly attribute DOMString productSub; readonly attribute DOMString userAgent; readonly attribute DOMString buildID; - readonly attribute DOMString doNotTrack; }; diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 37c853da94..eacb6c9443 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -30,6 +30,7 @@ Navigator implements NavigatorContentUtils; Navigator implements NavigatorStorageUtils; Navigator implements NavigatorConcurrentHardware; Navigator implements NavigatorStorage; +Navigator implements NavigatorGlobalPrivacyControl; [NoInterfaceObject, Exposed=(Window,Worker)] interface NavigatorID { @@ -111,9 +112,10 @@ partial interface Navigator { readonly attribute PluginArray plugins; }; -// http://www.w3.org/TR/tracking-dnt/ sort of -partial interface Navigator { - readonly attribute DOMString doNotTrack; +// https://globalprivacycontrol.github.io/gpc-spec/ +[NoInterfaceObject, Exposed=(Window,Worker)] +interface NavigatorGlobalPrivacyControl { + readonly attribute boolean globalPrivacyControl; }; // http://www.w3.org/TR/geolocation-API/#geolocation_interface diff --git a/dom/webidl/WorkerNavigator.webidl b/dom/webidl/WorkerNavigator.webidl index 44d1e29f68..fc3fd603c6 100644 --- a/dom/webidl/WorkerNavigator.webidl +++ b/dom/webidl/WorkerNavigator.webidl @@ -12,3 +12,4 @@ WorkerNavigator implements NavigatorLanguage; WorkerNavigator implements NavigatorOnLine; WorkerNavigator implements NavigatorConcurrentHardware; WorkerNavigator implements NavigatorStorage; +WorkerNavigator implements NavigatorGlobalPrivacyControl; diff --git a/dom/workers/WorkerNavigator.h b/dom/workers/WorkerNavigator.h index 5617b7351d..f845ac12f5 100644 --- a/dom/workers/WorkerNavigator.h +++ b/dom/workers/WorkerNavigator.h @@ -8,6 +8,7 @@ #include "Workers.h" #include "RuntimeService.h" +#include "nsContentUtils.h" #include "nsString.h" #include "nsWrapperCache.h" #include "mozilla/dom/StorageManager.h" @@ -100,6 +101,11 @@ public: mOnline = aOnline; } + bool GlobalPrivacyControl() const + { + return nsContentUtils::GPCEnabled(); + } + void SetLanguages(const nsTArray& aLanguages); uint64_t HardwareConcurrency() const; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index b7d915996e..9b89ae314c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1231,8 +1231,8 @@ pref("content.sink.pending_event_mode", 0); // 2 = openAbused pref("privacy.popups.disable_from_plugins", 2); -// send "do not track" HTTP header, disabled by default -pref("privacy.donottrackheader.enabled", false); +// Send "Sec-GPC" HTTP header, disabled by default +pref("privacy.GPCheader.enabled", false); // Enforce tracking protection in all modes pref("privacy.trackingprotection.enabled", false); // Enforce tracking protection in Private Browsing mode diff --git a/netwerk/protocol/http/nsHttpAtomList.h b/netwerk/protocol/http/nsHttpAtomList.h index 2ac6ee7cf3..c8a01f9ccb 100644 --- a/netwerk/protocol/http/nsHttpAtomList.h +++ b/netwerk/protocol/http/nsHttpAtomList.h @@ -45,11 +45,11 @@ HTTP_ATOM(Date, "Date") HTTP_ATOM(DAV, "DAV") HTTP_ATOM(Depth, "Depth") HTTP_ATOM(Destination, "Destination") -HTTP_ATOM(DoNotTrack, "DNT") HTTP_ATOM(ETag, "Etag") HTTP_ATOM(Expect, "Expect") HTTP_ATOM(Expires, "Expires") HTTP_ATOM(From, "From") +HTTP_ATOM(GlobalPrivacyControl, "Sec-GPC") HTTP_ATOM(Host, "Host") HTTP_ATOM(If, "If") HTTP_ATOM(If_Match, "If-Match") diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index a3a5c6530c..1bf57a0d3b 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -5711,7 +5711,7 @@ nsHttpChannel::BeginConnect() mRequestHead.SetOrigin(scheme, host, port); SetOriginHeader(); - SetDoNotTrack(); + SetGPC(); NeckoOriginAttributes originAttributes; NS_GetOriginAttributes(this, originAttributes); @@ -8051,18 +8051,13 @@ nsHttpChannel::SetOriginHeader() } void -nsHttpChannel::SetDoNotTrack() +nsHttpChannel::SetGPC() { /** - * 'DoNotTrack' header should be added if 'privacy.donottrackheader.enabled' - * is true or tracking protection is enabled. See bug 1258033. + * 'Sec-GPC: 1' header should be added if 'privacy.GPCheader.enabled' is true. */ - nsCOMPtr loadContext; - NS_QueryNotificationCallbacks(this, loadContext); - - if ((loadContext && loadContext->UseTrackingProtection()) || - nsContentUtils::DoNotTrackEnabled()) { - mRequestHead.SetHeader(nsHttp::DoNotTrack, + if (nsContentUtils::GPCEnabled()) { + mRequestHead.SetHeader(nsHttp::GlobalPrivacyControl, NS_LITERAL_CSTRING("1"), false); } diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 62cf0e470b..2681f34764 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -453,7 +453,7 @@ private: void SetPushedStream(Http2PushedStreamWrapper *stream); void SetOriginHeader(); - void SetDoNotTrack(); + void SetGPC(); private: nsCOMPtr mProxyRequest; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index a1ba6d3634..a4e481fcac 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -87,7 +87,7 @@ #define HTTP_PREF_PREFIX "network.http." #define INTL_ACCEPT_LANGUAGES "intl.accept_languages" #define BROWSER_PREF_PREFIX "browser.cache." -#define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled" +#define GPC_HEADER_ENABLED "privacy.GPCheader.enabled" #define H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" #define ALLOW_EXPERIMENTS "network.allow-experiments" #define SAFE_HINT_HEADER_VALUE "safeHint.enabled" @@ -181,7 +181,7 @@ nsHttpHandler::nsHttpHandler() , mAcceptLanguagesIsDirty(true) , mPromptTempRedirect(true) , mEnablePersistentHttpsCaching(false) - , mDoNotTrackEnabled(false) + , mGPCEnabled(false) , mSafeHintEnabled(false) , mParentalControlEnabled(false) , mHandlerActive(false) @@ -279,7 +279,7 @@ nsHttpHandler::Init() prefBranch->AddObserver(UA_PREF_PREFIX, this, true); prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true); prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true); - prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true); + prefBranch->AddObserver(GPC_HEADER_ENABLED, this, true); prefBranch->AddObserver(H2MANDATORY_SUITE, this, true); prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true); prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true); @@ -1497,11 +1497,11 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) // Tracking options // - if (PREF_CHANGED(DONOTTRACK_HEADER_ENABLED)) { + if (PREF_CHANGED(GPC_HEADER_ENABLED)) { cVar = false; - rv = prefs->GetBoolPref(DONOTTRACK_HEADER_ENABLED, &cVar); + rv = prefs->GetBoolPref(GPC_HEADER_ENABLED, &cVar); if (NS_SUCCEEDED(rv)) { - mDoNotTrackEnabled = cVar; + mGPCEnabled = cVar; } } // Hint option diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index c3f6290095..caeabf81de 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -515,8 +515,8 @@ private: // Persistent HTTPS caching flag bool mEnablePersistentHttpsCaching; - // For broadcasting tracking preference - bool mDoNotTrackEnabled; + // For broadcasting Global Privacy Control preference + bool mGPCEnabled; // for broadcasting safe hint; bool mSafeHintEnabled; From 591a887bf3b30ed366fa6738e02acdc5ce491d98 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 7 Oct 2021 23:20:53 +0000 Subject: [PATCH 2/3] [Pale-Moon] Issue MoonchildProductions/UXP#1721 - Implement GlobalPrivacyControl Front-end and locale changes for GPC in preferences as well as migration. Also bumps the back-end pointer to pick up the platform changes necessary. --- .../palemoon/components/nsBrowserGlue.js | 10 ++++++- .../components/preferences/privacy.xul | 26 +++++++++---------- .../chrome/browser/preferences/privacy.dtd | 8 +++--- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/application/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js index 055fb40575..958475a29e 100644 --- a/application/palemoon/components/nsBrowserGlue.js +++ b/application/palemoon/components/nsBrowserGlue.js @@ -1284,7 +1284,7 @@ BrowserGlue.prototype = { }, _migrateUI: function() { - const UI_VERSION = 24; + const UI_VERSION = 26; const BROWSER_DOCURL = "chrome://browser/content/browser.xul#"; let currentUIVersion = 0; try { @@ -1558,6 +1558,14 @@ BrowserGlue.prototype = { Services.prefs.clearUserPref("dom.abortController.enabled"); } + if (currentUIVersion < 26) { + // DoNotTrack is now GPC. Carry across user preference. + if (Services.prefs.prefHasUserValue("privacy.donottrackheader.enabled")) { + let DNTEnabled = Services.prefs.getBoolPref("privacy.donottrackheader.enabled"); + Services.prefs.setBoolPref("privacy.GPCheader.enabled", DNTEnabled); + Services.prefs.clearUserPref("privacy.donottrackheader.enabled"); + } + } // Clear out dirty storage if (this._dirty) { diff --git a/application/palemoon/components/preferences/privacy.xul b/application/palemoon/components/preferences/privacy.xul index 50b89f1620..e5175422dc 100644 --- a/application/palemoon/components/preferences/privacy.xul +++ b/application/palemoon/components/preferences/privacy.xul @@ -22,9 +22,9 @@ - - + @@ -216,18 +216,18 @@ - - - &tracking.label; + + + &dataPrivacy.label; - + - diff --git a/application/palemoon/locales/en-US/chrome/browser/preferences/privacy.dtd b/application/palemoon/locales/en-US/chrome/browser/preferences/privacy.dtd index 37f8b78c0d..1e395694ce 100644 --- a/application/palemoon/locales/en-US/chrome/browser/preferences/privacy.dtd +++ b/application/palemoon/locales/en-US/chrome/browser/preferences/privacy.dtd @@ -2,11 +2,11 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - + - - - + + + From 6cefc52d328c14932bb315d8432d0065795cfddb Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 18 Oct 2021 16:19:08 +0000 Subject: [PATCH 3/3] [Basilisk] Issue #2 - Remove Safebrowsing and TrackingProtection from the FE This resolves #2 --- application/basilisk/app/profile/basilisk.js | 12 - .../basilisk/base/content/blockedSite.xhtml | 196 ---------------- .../basilisk/base/content/browser-doctype.inc | 4 - .../base/content/browser-safebrowsing.js | 48 ---- .../content/browser-trackingprotection.js | 130 ----------- application/basilisk/base/content/browser.js | 20 -- .../basilisk/base/content/global-scripts.inc | 4 - .../base/content/report-phishing-overlay.xul | 35 --- .../basilisk/base/content/tab-content.js | 5 - application/basilisk/base/jar.mn | 9 - .../components/about/AboutRedirector.cpp | 9 - .../basilisk/components/build/nsModule.cpp | 3 - .../controlcenter/content/panel.inc.xul | 31 --- .../components/preferences/blocklists.js | 209 ------------------ .../components/preferences/blocklists.xul | 56 ----- .../components/preferences/donottrack.xul | 43 ---- .../preferences/in-content/privacy.js | 139 ------------ .../preferences/in-content/privacy.xul | 65 ------ .../preferences/in-content/security.js | 78 ------- .../preferences/in-content/security.xul | 42 ---- .../basilisk/components/preferences/jar.mn | 7 - .../content/aboutPrivateBrowsing.js | 48 ---- .../content/aboutPrivateBrowsing.xhtml | 15 -- application/basilisk/confvars.sh | 1 - .../basilisk/installer/package-manifest.in | 10 - .../chrome/browser/aboutPrivateBrowsing.dtd | 4 - .../locales/en-US/chrome/browser/browser.dtd | 27 --- .../en-US/chrome/browser/browser.properties | 3 - .../chrome/browser/preferences/donottrack.dtd | 13 -- .../preferences/preferences.properties | 2 - .../chrome/browser/preferences/privacy.dtd | 25 --- .../phishing-afterload-warning-message.dtd | 32 --- .../browser/safebrowsing/report-phishing.dtd | 13 -- application/basilisk/locales/jar.mn | 10 - .../shared/incontentprefs/preferences.inc.css | 7 - .../configurations/ControlCenter.jsm | 34 --- 36 files changed, 1389 deletions(-) delete mode 100644 application/basilisk/base/content/blockedSite.xhtml delete mode 100644 application/basilisk/base/content/browser-safebrowsing.js delete mode 100644 application/basilisk/base/content/browser-trackingprotection.js delete mode 100644 application/basilisk/base/content/report-phishing-overlay.xul delete mode 100644 application/basilisk/components/preferences/blocklists.js delete mode 100644 application/basilisk/components/preferences/blocklists.xul delete mode 100644 application/basilisk/components/preferences/donottrack.xul delete mode 100644 application/basilisk/locales/en-US/chrome/browser/preferences/donottrack.dtd delete mode 100644 application/basilisk/locales/en-US/chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd delete mode 100644 application/basilisk/locales/en-US/chrome/browser/safebrowsing/report-phishing.dtd diff --git a/application/basilisk/app/profile/basilisk.js b/application/basilisk/app/profile/basilisk.js index df27da5089..5fe10b2016 100644 --- a/application/basilisk/app/profile/basilisk.js +++ b/application/basilisk/app/profile/basilisk.js @@ -944,10 +944,6 @@ pref("services.sync.prefs.sync.browser.link.open_newwindow", true); pref("services.sync.prefs.sync.browser.newtabpage.enabled", true); pref("services.sync.prefs.sync.browser.newtabpage.pinned", true); pref("services.sync.prefs.sync.browser.offline-apps.notify", true); -#ifdef MOZ_SAFE_BROWSING -pref("services.sync.prefs.sync.browser.safebrowsing.phishing.enabled", true); -pref("services.sync.prefs.sync.browser.safebrowsing.malware.enabled", true); -#endif pref("services.sync.prefs.sync.browser.search.update", true); pref("services.sync.prefs.sync.browser.sessionstore.restore_on_demand", true); pref("services.sync.prefs.sync.browser.startup.homepage", true); @@ -992,8 +988,6 @@ pref("services.sync.prefs.sync.privacy.clearOnShutdown.sessions", true); pref("services.sync.prefs.sync.privacy.clearOnShutdown.siteSettings", true); pref("services.sync.prefs.sync.privacy.donottrackheader.enabled", true); pref("services.sync.prefs.sync.privacy.sanitize.sanitizeOnShutdown", true); -pref("services.sync.prefs.sync.privacy.trackingprotection.enabled", true); -pref("services.sync.prefs.sync.privacy.trackingprotection.pbmode.enabled", true); pref("services.sync.prefs.sync.security.OCSP.enabled", true); pref("services.sync.prefs.sync.security.OCSP.require", true); pref("services.sync.prefs.sync.security.default_personal_cert", true); @@ -1202,12 +1196,6 @@ pref("browser.cache.frecency_experiment", -1); // Enable GMP support in the addon manager. pref("media.gmp-provider.enabled", true); -#ifdef NIGHTLY_BUILD -pref("privacy.trackingprotection.ui.enabled", true); -#else -pref("privacy.trackingprotection.ui.enabled", false); -#endif - #ifndef RELEASE_OR_BETA // At the moment, autostart.2 is used, while autostart.1 is unused. // We leave it here set to false to reset users' defaults and allow diff --git a/application/basilisk/base/content/blockedSite.xhtml b/application/basilisk/base/content/blockedSite.xhtml deleted file mode 100644 index 10a4b33e84..0000000000 --- a/application/basilisk/base/content/blockedSite.xhtml +++ /dev/null @@ -1,196 +0,0 @@ - - - - %htmlDTD; - - %globalDTD; - - %brandDTD; - - %blockedSiteDTD; -]> - - - - - - - - - - - - -
- - -
-

&safeb.blocked.phishingPage.title2;

-

&safeb.blocked.malwarePage.title;

-

&safeb.blocked.unwantedPage.title;

-
- -
- - -
-

&safeb.blocked.phishingPage.shortDesc2;

-

&safeb.blocked.malwarePage.shortDesc;

-

&safeb.blocked.unwantedPage.shortDesc;

-
- - -
-

&safeb.blocked.phishingPage.longDesc2;

-

&safeb.blocked.malwarePage.longDesc;

-

&safeb.blocked.unwantedPage.longDesc;

-
- - -
- - -
- -
-
-
- -
-
- - - - diff --git a/application/basilisk/base/content/browser-doctype.inc b/application/basilisk/base/content/browser-doctype.inc index 30d70ccea2..14f5f80bda 100644 --- a/application/basilisk/base/content/browser-doctype.inc +++ b/application/basilisk/base/content/browser-doctype.inc @@ -13,10 +13,6 @@ %customizeToolbarDTD; %placesDTD; -#ifdef MOZ_SAFE_BROWSING - -%safebrowsingDTD; -#endif %aboutHomeDTD; #ifdef MOZ_SERVICES_SYNC diff --git a/application/basilisk/base/content/browser-safebrowsing.js b/application/basilisk/base/content/browser-safebrowsing.js deleted file mode 100644 index 430d84f132..0000000000 --- a/application/basilisk/base/content/browser-safebrowsing.js +++ /dev/null @@ -1,48 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var gSafeBrowsing = { - - setReportPhishingMenu: function() { - // In order to detect whether or not we're at the phishing warning - // page, we have to check the documentURI instead of the currentURI. - // This is because when the DocShell loads an error page, the - // currentURI stays at the original target, while the documentURI - // will point to the internal error page we loaded instead. - var docURI = gBrowser.selectedBrowser.documentURI; - var isPhishingPage = - docURI && docURI.spec.startsWith("about:blocked?e=deceptiveBlocked"); - - // Show/hide the appropriate menu item. - document.getElementById("menu_HelpPopup_reportPhishingtoolmenu") - .hidden = isPhishingPage; - document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu") - .hidden = !isPhishingPage; - - var broadcasterId = isPhishingPage - ? "reportPhishingErrorBroadcaster" - : "reportPhishingBroadcaster"; - - var broadcaster = document.getElementById(broadcasterId); - if (!broadcaster) - return; - - // Now look at the currentURI to learn which page we were trying - // to browse to. - let uri = gBrowser.currentURI; - if (uri && (uri.schemeIs("http") || uri.schemeIs("https"))) - broadcaster.removeAttribute("disabled"); - else - broadcaster.setAttribute("disabled", true); - }, - - /** - * Used to report a phishing page or a false positive - * @param name String One of "Phish", "Error", "Malware" or "MalwareError" - * @return String the report phishing URL. - */ - getReportURL: function(name) { - return SafeBrowsing.getReportURL(name, gBrowser.currentURI); - } -} diff --git a/application/basilisk/base/content/browser-trackingprotection.js b/application/basilisk/base/content/browser-trackingprotection.js deleted file mode 100644 index 17b1e4f989..0000000000 --- a/application/basilisk/base/content/browser-trackingprotection.js +++ /dev/null @@ -1,130 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var TrackingProtection = { - // If the user ignores the doorhanger, we stop showing it after some time. - PREF_ENABLED_GLOBALLY: "privacy.trackingprotection.enabled", - PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled", - enabledGlobally: false, - enabledInPrivateWindows: false, - container: null, - content: null, - icon: null, - activeTooltipText: null, - disabledTooltipText: null, - - init() { - let $ = selector => document.querySelector(selector); - this.container = $("#tracking-protection-container"); - this.content = $("#tracking-protection-content"); - this.icon = $("#tracking-protection-icon"); - - this.updateEnabled(); - Services.prefs.addObserver(this.PREF_ENABLED_GLOBALLY, this, false); - Services.prefs.addObserver(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, this, false); - - this.activeTooltipText = - gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"); - this.disabledTooltipText = - gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"); - }, - - uninit() { - Services.prefs.removeObserver(this.PREF_ENABLED_GLOBALLY, this); - Services.prefs.removeObserver(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, this); - }, - - observe() { - this.updateEnabled(); - }, - - get enabled() { - return this.enabledGlobally || - (this.enabledInPrivateWindows && - PrivateBrowsingUtils.isWindowPrivate(window)); - }, - - updateEnabled() { - this.enabledGlobally = - Services.prefs.getBoolPref(this.PREF_ENABLED_GLOBALLY); - this.enabledInPrivateWindows = - Services.prefs.getBoolPref(this.PREF_ENABLED_IN_PRIVATE_WINDOWS); - this.container.hidden = !this.enabled; - }, - - onSecurityChange(state, isSimulated) { - if (!this.enabled) { - return; - } - - // Only animate the shield if the event was not fired directly from - // the tabbrowser (due to a browser change). - if (isSimulated) { - this.icon.removeAttribute("animate"); - } else { - this.icon.setAttribute("animate", "true"); - } - - let isBlocking = state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT; - let isAllowing = state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT; - - if (isBlocking) { - this.icon.setAttribute("tooltiptext", this.activeTooltipText); - this.icon.setAttribute("state", "blocked-tracking-content"); - this.content.setAttribute("state", "blocked-tracking-content"); - } else if (isAllowing) { - this.icon.setAttribute("tooltiptext", this.disabledTooltipText); - this.icon.setAttribute("state", "loaded-tracking-content"); - this.content.setAttribute("state", "loaded-tracking-content"); - } else { - this.icon.removeAttribute("tooltiptext"); - this.icon.removeAttribute("state"); - this.content.removeAttribute("state"); - } - }, - - disableForCurrentPage() { - // Convert document URI into the format used by - // nsChannelClassifier::ShouldEnableTrackingProtection. - // Any scheme turned into https is correct. - let normalizedUrl = Services.io.newURI( - "https://" + gBrowser.selectedBrowser.currentURI.hostPort, - null, null); - - // Add the current host in the 'trackingprotection' consumer of - // the permission manager using a normalized URI. This effectively - // places this host on the tracking protection allowlist. - if (PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) { - PrivateBrowsingUtils.addToTrackingAllowlist(normalizedUrl); - } else { - Services.perms.add(normalizedUrl, - "trackingprotection", Services.perms.ALLOW_ACTION); - } - - // Hide the control center. - document.getElementById("identity-popup").hidePopup(); - - BrowserReload(); - }, - - enableForCurrentPage() { - // Remove the current host from the 'trackingprotection' consumer - // of the permission manager. This effectively removes this host - // from the tracking protection allowlist. - let normalizedUrl = Services.io.newURI( - "https://" + gBrowser.selectedBrowser.currentURI.hostPort, - null, null); - - if (PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) { - PrivateBrowsingUtils.removeFromTrackingAllowlist(normalizedUrl); - } else { - Services.perms.remove(normalizedUrl, "trackingprotection"); - } - - // Hide the control center. - document.getElementById("identity-popup").hidePopup(); - - BrowserReload(); - }, -}; diff --git a/application/basilisk/base/content/browser.js b/application/basilisk/base/content/browser.js index ea0061e17a..39739497bd 100644 --- a/application/basilisk/base/content/browser.js +++ b/application/basilisk/base/content/browser.js @@ -50,11 +50,6 @@ Cu.import("resource://gre/modules/NotificationDB.jsm"); ["webrtcUI", "resource:///modules/webrtcUI.jsm", ] ].forEach(([name, resource]) => XPCOMUtils.defineLazyModuleGetter(this, name, resource)); -#ifdef MOZ_SAFE_BROWSING - XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing", - "resource://gre/modules/SafeBrowsing.jsm"); -#endif - // lazy service getters [ ["Favicons", "@mozilla.org/browser/favicon-service;1", "mozIAsyncFavicons"], @@ -959,7 +954,6 @@ var gBrowserInit = { BrowserOnClick.init(); FeedHandler.init(); AboutPrivateBrowsingListener.init(); - TrackingProtection.init(); RefreshBlocker.init(); CaptivePortalWatcher.init(); @@ -1168,11 +1162,6 @@ var gBrowserInit = { } } -#ifdef MOZ_SAFE_BROWSING - // Bug 778855 - Perf regression if we do this here. To be addressed in bug 779008. - setTimeout(function() { SafeBrowsing.init(); }, 2000); -#endif - Services.obs.addObserver(gIdentityHandler, "perm-changed", false); Services.obs.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false); Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false); @@ -1442,8 +1431,6 @@ var gBrowserInit = { FeedHandler.uninit(); - TrackingProtection.uninit(); - RefreshBlocker.uninit(); CaptivePortalWatcher.uninit(); @@ -4188,7 +4175,6 @@ var XULBrowserWindow = { uri = Services.uriFixup.createExposableURI(uri); } catch (e) {} gIdentityHandler.updateIdentity(this._state, uri); - TrackingProtection.onSecurityChange(this._state, aIsSimulated); }, // simulate all change notifications after switching tabs @@ -7625,12 +7611,6 @@ var AboutPrivateBrowsingListener = { msg => { OpenBrowserWindow({private: true}); }); - window.messageManager.addMessageListener( - "AboutPrivateBrowsing:ToggleTrackingProtection", - msg => { - const PREF = "privacy.trackingprotection.pbmode.enabled"; - Services.prefs.setBoolPref(PREF, !Services.prefs.getBoolPref(PREF)); - }); } }; diff --git a/application/basilisk/base/content/global-scripts.inc b/application/basilisk/base/content/global-scripts.inc index 6edb112140..d97485697f 100644 --- a/application/basilisk/base/content/global-scripts.inc +++ b/application/basilisk/base/content/global-scripts.inc @@ -22,13 +22,9 @@