toolkit/components/help/content/contextHelp.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 # Set the default content pack to the Mozilla content pack. Use the
     6 # setHelpFileURI function to set this value.
     7 var helpFileURI;
     9 # openHelp - Opens up the Mozilla Help Viewer with the specified
    10 #    topic and content pack.
    11 # see http://www.mozilla.org/projects/help-viewer/content_packs.html
    12 function openHelp(topic, contentPack)
    13 {
    14 # helpFileURI is the content pack to use in this function. If contentPack is defined,
    15 # use that and set the helpFileURI to that value so that it will be the default.
    16   helpFileURI = contentPack || helpFileURI;
    18 # Try to find previously opened help.
    19   var topWindow = locateHelpWindow(helpFileURI);
    21   if ( topWindow ) {
    22 # Open topic in existing window.
    23     topWindow.focus();
    24     topWindow.displayTopic(topic);
    25   } else {
    26 # Open topic in new window.
    27     const params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
    28                              .createInstance(Components.interfaces.nsIDialogParamBlock);
    29     params.SetNumberStrings(2);
    30     params.SetString(0, helpFileURI);
    31     params.SetString(1, topic);
    32     const ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
    33                          .getService(Components.interfaces.nsIWindowWatcher);
    34 #ifdef XP_WIN
    35 #define HELP_ALWAYS_RAISED_TOGGLE
    36 #endif
    37 #ifdef HELP_ALWAYS_RAISED_TOGGLE
    38     ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,alwaysRaised,dialog=no", params);
    39 #else
    40     ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,dialog=no", params);
    41 #endif
    42   }
    43 }
    45 # setHelpFileURI - Sets the default content pack to use in the Help Viewer
    46 function setHelpFileURI(rdfURI)
    47 {
    48   helpFileURI = rdfURI;
    49 }
    51 # Locate existing help window for this content pack.
    52 function locateHelpWindow(contentPack) {
    53     const windowManagerInterface = Components
    54         .classes['@mozilla.org/appshell/window-mediator;1'].getService()
    55         .QueryInterface(Components.interfaces.nsIWindowMediator);
    56     const iterator = windowManagerInterface.getEnumerator("mozilla:help");
    57     var topWindow = null;
    58     var aWindow;
    60 # Loop through help windows looking for one with selected content
    61 # pack.
    62     while (iterator.hasMoreElements()) {
    63         aWindow = iterator.getNext();
    64         if (!aWindow.closed && aWindow.getHelpFileURI() == contentPack) {
    65             topWindow = aWindow;
    66         }
    67     }
    68     return topWindow;
    69 }

mercurial