toolkit/mozapps/extensions/content/about.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 // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 "use strict";
     9 function init() {
    10   var addon = window.arguments[0];
    11   var extensionsStrings = document.getElementById("extensionsStrings");
    13   document.documentElement.setAttribute("addontype", addon.type);
    15   if (addon.iconURL) {
    16     var extensionIcon = document.getElementById("extensionIcon");
    17     extensionIcon.src = addon.iconURL;
    18   }
    20   document.title = extensionsStrings.getFormattedString("aboutWindowTitle", [addon.name]);
    21   var extensionName = document.getElementById("extensionName");
    22   extensionName.textContent = addon.name;
    24   var extensionVersion = document.getElementById("extensionVersion");
    25   if (addon.version)
    26     extensionVersion.setAttribute("value", extensionsStrings.getFormattedString("aboutWindowVersionString", [addon.version]));
    27   else
    28     extensionVersion.hidden = true;
    30   var extensionDescription = document.getElementById("extensionDescription");
    31   if (addon.description)
    32     extensionDescription.textContent = addon.description;
    33   else
    34     extensionDescription.hidden = true;
    36   var numDetails = 0;
    38   var extensionCreator = document.getElementById("extensionCreator");
    39   if (addon.creator) {
    40     extensionCreator.setAttribute("value", addon.creator);
    41     numDetails++;
    42   } else {
    43     extensionCreator.hidden = true;
    44     var extensionCreatorLabel = document.getElementById("extensionCreatorLabel");
    45     extensionCreatorLabel.hidden = true;
    46   }
    48   var extensionHomepage = document.getElementById("extensionHomepage");
    49   var homepageURL = addon.homepageURL;
    50   if (homepageURL) {
    51     extensionHomepage.setAttribute("homepageURL", homepageURL);
    52     extensionHomepage.setAttribute("tooltiptext", homepageURL);
    53     numDetails++;
    54   } else {
    55     extensionHomepage.hidden = true;
    56   }
    58   numDetails += appendToList("extensionDevelopers", "developersBox", addon.developers);
    59   numDetails += appendToList("extensionTranslators", "translatorsBox", addon.translators);
    60   numDetails += appendToList("extensionContributors", "contributorsBox", addon.contributors);
    62   if (numDetails == 0) {
    63     var groove = document.getElementById("groove");
    64     groove.hidden = true;
    65     var extensionDetailsBox = document.getElementById("extensionDetailsBox");
    66     extensionDetailsBox.hidden = true;
    67   }
    69   var acceptButton = document.documentElement.getButton("accept");
    70   acceptButton.label = extensionsStrings.getString("aboutWindowCloseButton");
    72   setTimeout(sizeToContent, 0);
    73 }
    75 function appendToList(aHeaderId, aNodeId, aItems) {
    76   var header = document.getElementById(aHeaderId);
    77   var node = document.getElementById(aNodeId);
    79   if (!aItems || aItems.length == 0) {
    80     header.hidden = true;
    81     return 0;
    82   }
    84   for (let currentItem of aItems) {
    85     var label = document.createElement("label");
    86     label.textContent = currentItem;
    87     label.setAttribute("class", "contributor");
    88     node.appendChild(label);
    89   }
    91   return aItems.length;
    92 }
    94 function loadHomepage(aEvent) {
    95   window.close();
    96   openURL(aEvent.target.getAttribute("homepageURL"));
    97 }

mercurial