Bug 1484876 - Part 5: Merge the PrivateBrowsingTrackingProtectionWhitelist service with PrivateBrowsingUtils.jsm; r=johannh
☠☠ backed out by 41ebcb085bb0 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 21 Aug 2018 10:03:58 -0400
changeset 432828 b1cb63d8c8bb98823dab57773d150178f19e694b
parent 432827 cd2ced68989568aaadd21e09d7d68664cf43e91d
child 432829 e80737d6af552187ffeb8099c8d6fd936febed5e
push id34488
push usernerli@mozilla.com
push dateWed, 22 Aug 2018 16:28:54 +0000
treeherdermozilla-central@d6e4d3e69d4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1484876
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484876 - Part 5: Merge the PrivateBrowsingTrackingProtectionWhitelist service with PrivateBrowsingUtils.jsm; r=johannh
browser/installer/package-manifest.in
mobile/android/installer/package-manifest.in
toolkit/components/moz.build
toolkit/components/privatebrowsing/PrivateBrowsing.manifest
toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js
toolkit/components/privatebrowsing/moz.build
toolkit/components/privatebrowsing/nsIPrivateBrowsingTrackingProtectionWhitelist.idl
toolkit/modules/PrivateBrowsingUtils.jsm
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -383,20 +383,16 @@
 @RESPATH@/actors/*
 
 ; Safe Browsing
 @RESPATH@/components/nsURLClassifier.manifest
 @RESPATH@/components/nsUrlClassifierHashCompleter.js
 @RESPATH@/components/nsUrlClassifierListManager.js
 @RESPATH@/components/nsUrlClassifierLib.js
 
-; Private Browsing
-@RESPATH@/components/PrivateBrowsing.manifest
-@RESPATH@/components/PrivateBrowsingTrackingProtectionWhitelist.js
-
 ; Security Reports
 @RESPATH@/components/SecurityReporter.manifest
 @RESPATH@/components/SecurityReporter.js
 
 ; ANGLE GLES-on-D3D rendering library
 #ifdef MOZ_ANGLE_RENDERER
 @BINPATH@/libEGL.dll
 @BINPATH@/libGLESv2.dll
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -248,20 +248,16 @@
 @BINPATH@/actors/*
 
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
 @BINPATH@/components/nsUrlClassifierHashCompleter.js
 @BINPATH@/components/nsUrlClassifierListManager.js
 @BINPATH@/components/nsUrlClassifierLib.js
 
-; Private Browsing
-@BINPATH@/components/PrivateBrowsing.manifest
-@BINPATH@/components/PrivateBrowsingTrackingProtectionWhitelist.js
-
 ; Security Reports
 @BINPATH@/components/SecurityReporter.manifest
 @BINPATH@/components/SecurityReporter.js
 
 ; [Browser Chrome Files]
 @BINPATH@/chrome/toolkit@JAREXT@
 @BINPATH@/chrome/toolkit.manifest
 
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -44,17 +44,16 @@ DIRS += [
     'mozintl',
     'mozprotocol',
     'osfile',
     'parentalcontrols',
     'passwordmgr',
     'perf',
     'perfmonitoring',
     'places',
-    'privatebrowsing',
     'processsingleton',
     'promiseworker',
     'prompts',
     'protobuf',
     'reader',
     'remotebrowserutils',
     'remotepagemanager',
     'reflect',
deleted file mode 100644
--- a/toolkit/components/privatebrowsing/PrivateBrowsing.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component {a319b616-c45d-4037-8d86-01c592b5a9af} PrivateBrowsingTrackingProtectionWhitelist.js
-contract @mozilla.org/pbm-tp-whitelist;1 {a319b616-c45d-4037-8d86-01c592b5a9af}
deleted file mode 100644
--- a/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js
+++ /dev/null
@@ -1,45 +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/. */
-
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-function PrivateBrowsingTrackingProtectionWhitelist() {
-  Services.obs.addObserver(this, "last-pb-context-exited", true);
-}
-
-PrivateBrowsingTrackingProtectionWhitelist.prototype = {
-  classID: Components.ID("{a319b616-c45d-4037-8d86-01c592b5a9af}"),
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIPrivateBrowsingTrackingProtectionWhitelist, Ci.nsIObserver, Ci.nsISupportsWeakReference]),
-  _xpcom_factory: XPCOMUtils.generateSingletonFactory(PrivateBrowsingTrackingProtectionWhitelist),
-
-  /**
-   * Add the provided URI to the list of allowed tracking sites.
-   *
-   * @param uri nsIURI
-   *        The URI to add to the list.
-   */
-  addToAllowList(uri) {
-    Services.perms.add(uri, "trackingprotection-pb", Ci.nsIPermissionManager.ALLOW_ACTION,
-                       Ci.nsIPermissionManager.EXPIRE_SESSION);
-  },
-
-  /**
-   * Remove the provided URI from the list of allowed tracking sites.
-   *
-   * @param uri nsIURI
-   *        The URI to add to the list.
-   */
-  removeFromAllowList(uri) {
-    Services.perms.remove(uri, "trackingprotection-pb");
-  },
-
-  observe(subject, topic, data) {
-    if (topic == "last-pb-context-exited") {
-      Services.perms.removeByType("trackingprotection-pb");
-    }
-  }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PrivateBrowsingTrackingProtectionWhitelist]);
deleted file mode 100644
--- a/toolkit/components/privatebrowsing/moz.build
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-with Files('**'):
-    BUG_COMPONENT = ('Core', 'DOM: Security')
-
-XPIDL_SOURCES += [
-    'nsIPrivateBrowsingTrackingProtectionWhitelist.idl',
-]
-
-XPIDL_MODULE = 'privatebrowsing'
-
-EXTRA_COMPONENTS += [
-    'PrivateBrowsing.manifest',
-    'PrivateBrowsingTrackingProtectionWhitelist.js',
-]
deleted file mode 100644
--- a/toolkit/components/privatebrowsing/nsIPrivateBrowsingTrackingProtectionWhitelist.idl
+++ /dev/null
@@ -1,38 +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/. */
-
-#include "nsISupports.idl"
-
-interface nsIURI;
-
-/**
- * The Private Browsing Tracking Protection service checks a URI against an
- * in-memory list of tracking sites.
- */
-[scriptable, uuid(c77ddfac-6cd6-43a9-84e8-91682a1a7b18)]
-interface nsIPrivateBrowsingTrackingProtectionWhitelist : nsISupports
-{
-  /**
-   * Add a URI to the list of allowed tracking sites in Private Browsing mode
-   * (essentially a tracking whitelist). This operation will cause the URI to
-   * be registered if it does not currently exist. If it already exists, then
-   * the operation is essentially a no-op.
-   *
-   * @param uri         the uri to add to the list
-   */
-  void addToAllowList(in nsIURI uri);
-
-  /**
-   * Remove a URI from the list of allowed tracking sites in Private Browsing
-   * mode (the tracking whitelist). If the URI is not already in the list,
-   * then the operation is essentially a no-op.
-   *
-   * @param uri         the uri to remove from the list
-   */
-  void removeFromAllowList(in nsIURI uri);
-};
-
-%{ C++
-#define NS_PBTRACKINGPROTECTIONWHITELIST_CONTRACTID "@mozilla.org/pbm-tp-whitelist;1"
-%}
--- a/toolkit/modules/PrivateBrowsingUtils.jsm
+++ b/toolkit/modules/PrivateBrowsingUtils.jsm
@@ -2,19 +2,50 @@
  * 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 EXPORTED_SYMBOLS = ["PrivateBrowsingUtils"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gPBMTPWhitelist",
-                                   "@mozilla.org/pbm-tp-whitelist;1",
-                                   "nsIPrivateBrowsingTrackingProtectionWhitelist");
+function PrivateBrowsingContentBlockingAllowList() {
+  Services.obs.addObserver(this, "last-pb-context-exited", true);
+}
+
+PrivateBrowsingContentBlockingAllowList.prototype = {
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
+
+  /**
+   * Add the provided URI to the list of allowed tracking sites.
+   *
+   * @param uri nsIURI
+   *        The URI to add to the list.
+   */
+  addToAllowList(uri) {
+    Services.perms.add(uri, "trackingprotection-pb", Ci.nsIPermissionManager.ALLOW_ACTION,
+                       Ci.nsIPermissionManager.EXPIRE_SESSION);
+  },
+
+  /**
+   * Remove the provided URI from the list of allowed tracking sites.
+   *
+   * @param uri nsIURI
+   *        The URI to remove from the list.
+   */
+  removeFromAllowList(uri) {
+    Services.perms.remove(uri, "trackingprotection-pb");
+  },
+
+  observe(subject, topic, data) {
+    if (topic == "last-pb-context-exited") {
+      Services.perms.removeByType("trackingprotection-pb");
+    }
+  }
+};
 
 const kAutoStartPref = "browser.privatebrowsing.autostart";
 
 // This will be set to true when the PB mode is autostarted from the command
 // line for the current session.
 var gTemporaryAutoStartMode = false;
 
 var PrivateBrowsingUtils = {
@@ -51,22 +82,27 @@ var PrivateBrowsingUtils = {
     }
     return this.privacyContextFromWindow(aBrowser.contentWindow).usePrivateBrowsing;
   },
 
   privacyContextFromWindow: function pbu_privacyContextFromWindow(aWindow) {
     return aWindow.docShell.QueryInterface(Ci.nsILoadContext);
   },
 
+  get _pbCBAllowList() {
+    delete this._pbCBAllowList;
+    return this._pbCBAllowList = new PrivateBrowsingContentBlockingAllowList();
+  },
+
   addToTrackingAllowlist(aURI) {
-    gPBMTPWhitelist.addToAllowList(aURI);
+    this._pbCBAllowList.addToAllowList(aURI);
   },
 
   removeFromTrackingAllowlist(aURI) {
-    gPBMTPWhitelist.removeFromAllowList(aURI);
+    this._pbCBAllowList.removeFromAllowList(aURI);
   },
 
   get permanentPrivateBrowsing() {
     try {
       return gTemporaryAutoStartMode ||
              Services.prefs.getBoolPref(kAutoStartPref);
     } catch (e) {
       // The pref does not exist