diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js')
-rw-r--r-- | toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js b/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js new file mode 100644 index 000000000..5c1c27874 --- /dev/null +++ b/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js @@ -0,0 +1,68 @@ +/* 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/. */ + +const Ci = Components.interfaces; +const Cu = Components.utils; + +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); + +function PrivateBrowsingTrackingProtectionWhitelist() { + // The list of URIs explicitly excluded from tracking protection. + this._allowlist = []; + + Services.obs.addObserver(this, "last-pb-context-exited", true); +} + +PrivateBrowsingTrackingProtectionWhitelist.prototype = { + classID: Components.ID("{a319b616-c45d-4037-8d86-01c592b5a9af}"), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrivateBrowsingTrackingProtectionWhitelist, + Ci.nsIObserver, + Ci.nsISupportsWeakReference, + Ci.nsISupports]), + _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) { + if (this._allowlist.indexOf(uri.spec) === -1) { + this._allowlist.push(uri.spec); + } + }, + + /** + * Remove the provided URI from the list of allowed tracking sites. + * + * @param uri nsIURI + * The URI to add to the list. + */ + removeFromAllowList(uri) { + let index = this._allowlist.indexOf(uri.spec); + if (index !== -1) { + this._allowlist.splice(index, 1); + } + }, + + /** + * Check if the provided URI exists in the list of allowed tracking sites. + * + * @param uri nsIURI + * The URI to add to the list. + */ + existsInAllowList(uri) { + return this._allowlist.indexOf(uri.spec) !== -1; + }, + + observe: function (subject, topic, data) { + if (topic == "last-pb-context-exited") { + this._allowlist = []; + } + } +}; + +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PrivateBrowsingTrackingProtectionWhitelist]); |