tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IPPOptOutHelper.sys.mjs (1021B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
      6 
      7 const lazy = {};
      8 
      9 ChromeUtils.defineESModuleGetters(lazy, {
     10  IPProtectionService:
     11    "moz-src:///browser/components/ipprotection/IPProtectionService.sys.mjs",
     12 });
     13 
     14 const OPTED_OUT_PREF = "browser.ipProtection.optedOut";
     15 
     16 /**
     17 * This class monitors the optedOut pref and if it sees an opted-out state, it
     18 * sets the state on IPProtectionService
     19 */
     20 class IPPOptedOutHelperSingleton {
     21  constructor() {
     22    XPCOMUtils.defineLazyPreferenceGetter(
     23      this,
     24      "optedOut",
     25      OPTED_OUT_PREF,
     26      false,
     27      () => {
     28        lazy.IPProtectionService.updateState();
     29      }
     30    );
     31  }
     32 
     33  init() {}
     34 
     35  uninit() {}
     36 
     37  initOnStartupCompleted() {}
     38 }
     39 
     40 const IPPOptOutHelper = new IPPOptedOutHelperSingleton();
     41 
     42 export { IPPOptOutHelper };