addon-sdk/source/lib/sdk/l10n/prefs.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/. */
     4 "use strict";
     6 const { on } = require("../system/events");
     7 const core = require("./core");
     8 const { id: jetpackId} = require('../self');
    10 const OPTIONS_DISPLAYED = "addon-options-displayed";
    12 function onOptionsDisplayed({ subject: document, data: addonId }) {
    13   if (addonId !== jetpackId)
    14     return;
    15   let query = 'setting[data-jetpack-id="' + jetpackId + '"][pref-name], ' +
    16               'button[data-jetpack-id="' + jetpackId + '"][pref-name]';
    17   let nodes = document.querySelectorAll(query);
    18   for (let node of nodes) {
    19     let name = node.getAttribute("pref-name");
    20     if (node.tagName == "setting") {
    21       let desc = core.get(name + "_description");
    22       if (desc)
    23         node.setAttribute("desc", desc);
    24       let title = core.get(name + "_title");
    25       if (title)
    26         node.setAttribute("title", title);
    28       for (let item of node.querySelectorAll("menuitem, radio")) {
    29           let key = name + "_options." + item.getAttribute("label");
    30           let label = core.get(key);
    31           if (label)
    32             item.setAttribute("label", label);
    33       }
    34     }
    35     else if (node.tagName == "button") {
    36       let label = core.get(name + "_label");
    37       if (label)
    38         node.setAttribute("label", label);
    39     }
    40   }
    41 }
    42 on(OPTIONS_DISPLAYED, onOptionsDisplayed);

mercurial