addon-sdk/source/examples/reddit-panel/lib/main.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 var { data } = require("sdk/self");
     7 var { ToggleButton } = require("sdk/ui");
     9 var base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
    10                 "AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
    11                 "N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
    12                 "bWRR9AAAAABJRU5ErkJggg%3D%3D";
    14 var reddit_panel = require("sdk/panel").Panel({
    15   width: 240,
    16   height: 320,
    17   contentURL: "http://www.reddit.com/.mobile?keep_extension=True",
    18   contentScriptFile: [data.url("jquery-1.4.4.min.js"),
    19                       data.url("panel.js")],
    20   onHide: handleHide
    21 });
    23 reddit_panel.port.on("click", function(url) {
    24   require("sdk/tabs").open(url);
    25 });
    27 let button = ToggleButton({
    28   id: "open-reddit-btn",
    29   label: "Reddit",
    30   icon: base64png,
    31   onChange: handleChange
    32 });
    34 exports.main = function(options, callbacks) {
    35   // If you run cfx with --static-args='{"quitWhenDone":true}' this program
    36   // will automatically quit Firefox when it's done.
    37   if (options.staticArgs.quitWhenDone)
    38     callbacks.quit();
    39 };
    41 function handleChange(state) {
    42   if (state.checked) {
    43     reddit_panel.show({ position: button });
    44   }
    45 }
    47 function handleHide() {
    48   button.state('window', { checked: false });
    49 }

mercurial