tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SessionStoreFunctions.sys.mjs (2019B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
      2 * This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 import { SessionStore } from "resource:///modules/sessionstore/SessionStore.sys.mjs";
      6 
      7 export class SessionStoreFunctions {
      8  UpdateSessionStore(
      9    aBrowser,
     10    aBrowsingContext,
     11    aPermanentKey,
     12    aEpoch,
     13    aCollectSHistory,
     14    aData
     15  ) {
     16    return SessionStoreFuncInternal.updateSessionStore(
     17      aBrowser,
     18      aBrowsingContext,
     19      aPermanentKey,
     20      aEpoch,
     21      aCollectSHistory,
     22      aData
     23    );
     24  }
     25 
     26  UpdateSessionStoreForStorage(
     27    aBrowser,
     28    aBrowsingContext,
     29    aPermanentKey,
     30    aEpoch,
     31    aData
     32  ) {
     33    return SessionStoreFuncInternal.updateSessionStoreForStorage(
     34      aBrowser,
     35      aBrowsingContext,
     36      aPermanentKey,
     37      aEpoch,
     38      aData
     39    );
     40  }
     41 }
     42 
     43 var SessionStoreFuncInternal = {
     44  updateSessionStore: function SSF_updateSessionStore(
     45    aBrowser,
     46    aBrowsingContext,
     47    aPermanentKey,
     48    aEpoch,
     49    aCollectSHistory,
     50    aData
     51  ) {
     52    let { formdata, scroll } = aData;
     53 
     54    if (formdata) {
     55      aData.formdata = formdata.toJSON();
     56    }
     57 
     58    if (scroll) {
     59      aData.scroll = scroll.toJSON();
     60    }
     61 
     62    SessionStore.updateSessionStoreFromTablistener(
     63      aBrowser,
     64      aBrowsingContext,
     65      aPermanentKey,
     66      {
     67        data: aData,
     68        epoch: aEpoch,
     69        sHistoryNeeded: aCollectSHistory,
     70      }
     71    );
     72  },
     73 
     74  updateSessionStoreForStorage: function SSF_updateSessionStoreForStorage(
     75    aBrowser,
     76    aBrowsingContext,
     77    aPermanentKey,
     78    aEpoch,
     79    aData
     80  ) {
     81    SessionStore.updateSessionStoreFromTablistener(
     82      aBrowser,
     83      aBrowsingContext,
     84      aPermanentKey,
     85      { data: { storage: aData }, epoch: aEpoch },
     86      true
     87    );
     88  },
     89 };
     90 
     91 SessionStoreFunctions.prototype.QueryInterface = ChromeUtils.generateQI([
     92  "nsISessionStoreFunctions",
     93 ]);