tor-browser

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

nsIDOMStorageManager.idl (4981B)


      1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 
      6 #include "nsISupports.idl"
      7 
      8 interface nsIPrincipal;
      9 interface mozIDOMWindow;
     10 
     11 webidl Storage;
     12 
     13 %{C++
     14 namespace mozilla {
     15 namespace dom {
     16 class SessionStorageCache;
     17 }  // namespace dom
     18 }  // namespace mozilla
     19 %}
     20 
     21 native SessionStorageCacheAddRefed(RefPtr<mozilla::dom::SessionStorageCache>);
     22 
     23 /**
     24 * General purpose interface that has two implementations, for localStorage
     25 * with "@mozilla.org/dom/localStorage-manager;1".
     26 */
     27 [scriptable, uuid(a20c742e-3ed1-44fb-b897-4080a75b1662)]
     28 interface nsIDOMStorageManager : nsISupports
     29 {
     30  /**
     31   * This starts async preloading of a storage cache for scope
     32   * defined by the principal and storage principal.
     33   *
     34   * Because of how multi-e10s support was implemented in bug 1285898, the
     35   * StorageCache instance can no longer use a timer to keep itself alive.  So a
     36   * Storage instance is returned if precaching believes the storage principal may
     37   * have localStorage data.  (Previously the StorageCache would be brought into
     38   * existence and kept alive by the timer so that it could be returned if a
     39   * call to createStorage was made due to a request by the page.)
     40   */
     41  Storage precacheStorage(in nsIPrincipal aPrincipal,
     42                          in nsIPrincipal aStoragePrincipal);
     43 
     44  /**
     45   * Returns instance of DOM storage object for given principal.
     46   * A new object is always returned and it is ensured there is
     47   * a storage for the scope created.
     48   *
     49   * @param aWindow
     50   *    The parent window.
     51   * @param aPrincipal
     52   *    Principal to bound storage to.
     53   * @param aStoragePrincipal
     54   *    StoragePrincipal to bound storage to.
     55   * @param aDocumentURI
     56   *    URL of the demanding document, used for DOM storage event only.
     57   * @param aPrivate
     58   *    Whether the demanding document is running in Private Browsing mode or not.
     59   */
     60  Storage createStorage(in mozIDOMWindow aWindow,
     61                        in nsIPrincipal aPrincipal,
     62                        in nsIPrincipal aStoragePrincipal,
     63                        in AString aDocumentURI,
     64                        [optional] in boolean aPrivate);
     65  /**
     66   * DEPRECATED.  The only good reason to use this was if you were writing a
     67   * test and wanted to hackily determine if a preload happened.  That's now
     68   * covered by `nsILocalStorageManager.isPreloaded` and you should use that if
     69   * that's what you want.  If LSNG is in use, this will throw.
     70   *
     71   * Returns instance of DOM storage object for given principal.
     72   * If there is no storage managed for the scope, then null is returned and
     73   * no object is created.  Otherwise, an object (new) for the existing storage
     74   * scope is returned.
     75   *
     76   * @param aWindow
     77   *    The parent window.
     78   * @param aPrincipal
     79   *    Principal to bound storage to.
     80   * @param aStoragePrincipal
     81   *    StoragePrincipal to bound storage to.
     82   * @param aPrivate
     83   *    Whether the demanding document is running in Private Browsing mode or not.
     84   */
     85  Storage getStorage(in mozIDOMWindow aWindow,
     86                     in nsIPrincipal aPrincipal,
     87                     in nsIPrincipal aStoragePrincipal,
     88                     [optional] in boolean aPrivate);
     89 
     90  /**
     91   * Clones given storage into this storage manager.
     92   *
     93   * @param aStorageToCloneFrom
     94   *    The storage to copy all items from into this manager.  Manager will then
     95   *    return a new and independent object that contains snapshot of data from
     96   *    the moment this method was called.  Modification to this new object will
     97   *    not affect the original storage content we cloned from and vice versa.
     98   */
     99  void cloneStorage(in Storage aStorageToCloneFrom);
    100 
    101  /**
    102   * Returns true if the storage belongs to the given principal and is managed
    103   * (i.e. has been created and is cached) by this storage manager.
    104   *
    105   * @param aPrincipal
    106   *    Principal to check the storage against.
    107   * @param aStorage
    108   *    The storage object to examine.
    109   *
    110   * @result
    111   *    true when the storage object is bound with the principal and is managed
    112   *         by this storage manager.
    113   *    false otherwise
    114   */
    115  boolean checkStorage(in nsIPrincipal aPrincipal,
    116                       in Storage aStorage);
    117 };
    118 
    119 [uuid(b3bfbbd0-e738-4cbf-b0f0-b65f25265e82)]
    120 interface nsIDOMSessionStorageManager : nsIDOMStorageManager {
    121  /**
    122   * Returns a SessionStorageCache object for the principal scope.
    123   *
    124   * @param aPrincipal
    125   *    Principal to bound storage to.
    126   * @param aStoragePrincipal
    127   *    StoragePrincipal to bound storage to.
    128   */
    129   [noscript]
    130   SessionStorageCacheAddRefed getSessionStorageCache(in nsIPrincipal aPrincipal,
    131                                                      in nsIPrincipal aStoragePrincipal);
    132 };