tor-browser

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

RequestBlockingContextMenu.js (1915B)


      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 "use strict";
      6 
      7 const {
      8  L10N,
      9 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
     10 
     11 loader.lazyRequireGetter(
     12  this,
     13  "showMenu",
     14  "resource://devtools/client/shared/components/menu/utils.js",
     15  true
     16 );
     17 
     18 class RequestBlockingContextMenu {
     19  constructor(props) {
     20    this.props = props;
     21  }
     22 
     23  createMenu(contextMenuOptions) {
     24    const {
     25      removeAllBlockedUrls,
     26      disableAllBlockedUrls,
     27      enableAllBlockedUrls,
     28    } = this.props;
     29 
     30    const { disableDisableAllBlockedUrls, disableEnableAllBlockedUrls } =
     31      contextMenuOptions;
     32 
     33    const menu = [
     34      {
     35        id: "request-blocking-enable-all",
     36        label: L10N.getStr(
     37          "netmonitor.requestBlockingMenu.enableAllBlockedUrls"
     38        ),
     39        accesskey: "",
     40        disabled: disableEnableAllBlockedUrls,
     41        visible: true,
     42        click: () => enableAllBlockedUrls(),
     43      },
     44      {
     45        id: "request-blocking-disable-all",
     46        label: L10N.getStr(
     47          "netmonitor.requestBlockingMenu.disableAllBlockedUrls"
     48        ),
     49        accesskey: "",
     50        disabled: disableDisableAllBlockedUrls,
     51        visible: true,
     52        click: () => disableAllBlockedUrls(),
     53      },
     54      {
     55        id: "request-blocking-remove-all",
     56        label: L10N.getStr(
     57          "netmonitor.requestBlockingMenu.removeAllBlockedUrls"
     58        ),
     59        accesskey: "",
     60        visible: true,
     61        click: () => removeAllBlockedUrls(),
     62      },
     63    ];
     64 
     65    return menu;
     66  }
     67 
     68  open(event, contextMenuOptions) {
     69    const menu = this.createMenu(contextMenuOptions);
     70 
     71    showMenu(menu, {
     72      screenX: event.screenX,
     73      screenY: event.screenY,
     74    });
     75  }
     76 }
     77 
     78 module.exports = RequestBlockingContextMenu;