addon-sdk/source/lib/sdk/places/history.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 module.metadata = {
     8   "stability": "unstable",
     9   "engines": {
    10     "Firefox": "*"
    11   }
    12 };
    14 /*
    15  * Requiring hosts so they can subscribe to client messages
    16  */
    17 require('./host/host-bookmarks');
    18 require('./host/host-tags');
    19 require('./host/host-query');
    21 const { Cc, Ci } = require('chrome');
    22 const { Class } = require('../core/heritage');
    23 const { events, send } = require('../addon/events');
    24 const { defer, reject, all } = require('../core/promise');
    25 const { uuid } = require('../util/uuid');
    26 const { flatten } = require('../util/array');
    27 const { has, extend, merge, pick } = require('../util/object');
    28 const { emit } = require('../event/core');
    29 const { defer: async } = require('../lang/functional');
    30 const { EventTarget } = require('../event/target');
    31 const {
    32   urlQueryParser, createQuery, createQueryOptions
    33 } = require('./utils');
    35 /*
    36  * Constant used by nsIHistoryQuery; 0 is a history query
    37  * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryQueryOptions
    38  */
    39 const HISTORY_QUERY = 0;
    41 let search = function query (queries, options) {
    42   queries = [].concat(queries);
    43   let emitter = EventTarget();
    44   let queryObjs = queries.map(createQuery.bind(null, HISTORY_QUERY));
    45   let optionsObj = createQueryOptions(HISTORY_QUERY, options);
    47   // Can remove after `Promise.jsm` is implemented in Bug 881047,
    48   // which will guarantee next tick execution
    49   async(() => {
    50     send('sdk-places-query', {
    51       query: queryObjs,
    52       options: optionsObj
    53     }).then(results => {
    54       results.map(item => emit(emitter, 'data', item));
    55       emit(emitter, 'end', results);
    56     }, reason => {
    57       emit(emitter, 'error', reason);
    58       emit(emitter, 'end', []);
    59     });
    60   })();
    62   return emitter;
    63 };
    64 exports.search = search;

mercurial