toolkit/devtools/gcli/commands/paintflashing.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     5 "use strict";
     7 const { Cc, Ci, Cu } = require("chrome");
     8 const TargetFactory = require("resource://gre/modules/devtools/Loader.jsm").devtools.TargetFactory;
    10 const Telemetry = require("devtools/shared/telemetry");
    11 const telemetry = new Telemetry();
    13 const EventEmitter = require("devtools/toolkit/event-emitter");
    14 const eventEmitter = new EventEmitter();
    16 const gcli = require("gcli/index");
    18 function onPaintFlashingChanged(context) {
    19   let tab = context.environment.chromeWindow.gBrowser.selectedTab;
    20   eventEmitter.emit("changed", tab);
    21   function fireChange() {
    22     eventEmitter.emit("changed", tab);
    23   }
    24   let target = TargetFactory.forTab(tab);
    25   target.off("navigate", fireChange);
    26   target.once("navigate", fireChange);
    28   let window = context.environment.window;
    29   let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
    30                      .getInterface(Ci.nsIDOMWindowUtils);
    31   if (wUtils.paintFlashing) {
    32     telemetry.toolOpened("paintflashing");
    33   } else {
    34     telemetry.toolClosed("paintflashing");
    35   }
    36 }
    38 exports.items = [
    39   {
    40     name: "paintflashing",
    41     description: gcli.lookup("paintflashingDesc")
    42   },
    43   {
    44     name: "paintflashing on",
    45     description: gcli.lookup("paintflashingOnDesc"),
    46     manual: gcli.lookup("paintflashingManual"),
    47     params: [{
    48       group: "options",
    49       params: [
    50         {
    51           type: "boolean",
    52           name: "chrome",
    53           get hidden() gcli.hiddenByChromePref(),
    54           description: gcli.lookup("paintflashingChromeDesc"),
    55         }
    56       ]
    57     }],
    58     exec: function(args, context) {
    59       let window = args.chrome ?
    60                   context.environment.chromeWindow :
    61                   context.environment.window;
    63       window.QueryInterface(Ci.nsIInterfaceRequestor)
    64             .getInterface(Ci.nsIDOMWindowUtils)
    65             .paintFlashing = true;
    66       onPaintFlashingChanged(context);
    67     }
    68   },
    69   {
    70     name: "paintflashing off",
    71     description: gcli.lookup("paintflashingOffDesc"),
    72     manual: gcli.lookup("paintflashingManual"),
    73     params: [{
    74       group: "options",
    75       params: [
    76         {
    77           type: "boolean",
    78           name: "chrome",
    79           get hidden() gcli.hiddenByChromePref(),
    80           description: gcli.lookup("paintflashingChromeDesc"),
    81         }
    82       ]
    83     }],
    84     exec: function(args, context) {
    85       let window = args.chrome ?
    86                   context.environment.chromeWindow :
    87                   context.environment.window;
    89       window.QueryInterface(Ci.nsIInterfaceRequestor)
    90             .getInterface(Ci.nsIDOMWindowUtils)
    91             .paintFlashing = false;
    92       onPaintFlashingChanged(context);
    93     }
    94   },
    95   {
    96     name: "paintflashing toggle",
    97     hidden: true,
    98     buttonId: "command-button-paintflashing",
    99     buttonClass: "command-button command-button-invertable",
   100     state: {
   101       isChecked: function(aTarget) {
   102         if (aTarget.isLocalTab) {
   103           let window = aTarget.tab.linkedBrowser.contentWindow;
   104           let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
   105                               getInterface(Ci.nsIDOMWindowUtils);
   106           return wUtils.paintFlashing;
   107         } else {
   108           throw new Error("Unsupported target");
   109         }
   110       },
   111       onChange: function(aTarget, aChangeHandler) {
   112         eventEmitter.on("changed", aChangeHandler);
   113       },
   114       offChange: function(aTarget, aChangeHandler) {
   115         eventEmitter.off("changed", aChangeHandler);
   116       },
   117     },
   118     tooltipText: gcli.lookup("paintflashingTooltip"),
   119     description: gcli.lookup("paintflashingToggleDesc"),
   120     manual: gcli.lookup("paintflashingManual"),
   121     exec: function(args, context) {
   122       let window = context.environment.window;
   123       let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
   124                    getInterface(Ci.nsIDOMWindowUtils);
   125       wUtils.paintFlashing = !wUtils.paintFlashing;
   126       onPaintFlashingChanged(context);
   127     }
   128   }
   129 ];

mercurial