nsIDOMStorageManager.idl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include "nsISupports.idl"
  6. interface nsIDOMStorage;
  7. interface nsIPrincipal;
  8. interface mozIDOMWindow;
  9. /**
  10. * General purpose interface that has two implementations, for localStorage
  11. * resp. sessionStorage with "@mozilla.org/dom/localStorage-manager;1" resp.
  12. * "@mozilla.org/dom/sessionStorage-manager;1" contract IDs.
  13. */
  14. [scriptable, uuid(a20c742e-3ed1-44fb-b897-4080a75b1662)]
  15. interface nsIDOMStorageManager : nsISupports
  16. {
  17. /**
  18. * This starts async preloading of a storage cache for scope
  19. * defined by the principal.
  20. */
  21. void precacheStorage(in nsIPrincipal aPrincipal);
  22. /**
  23. * Returns instance of DOM storage object for given principal.
  24. * A new object is always returned and it is ensured there is
  25. * a storage for the scope created.
  26. *
  27. * @param aWindow
  28. * The parent window.
  29. * @param aPrincipal
  30. * Principal to bound storage to.
  31. * @param aDocumentURI
  32. * URL of the demanding document, used for DOM storage event only.
  33. * @param aPrivate
  34. * Whether the demanding document is running in Private Browsing mode or not.
  35. */
  36. nsIDOMStorage createStorage(in mozIDOMWindow aWindow,
  37. in nsIPrincipal aPrincipal,
  38. in DOMString aDocumentURI,
  39. [optional] in bool aPrivate);
  40. /**
  41. * Returns instance of DOM storage object for given principal.
  42. * If there is no storage managed for the scope, then null is returned and
  43. * no object is created. Otherwise, an object (new) for the existing storage
  44. * scope is returned.
  45. *
  46. * @param aWindow
  47. * The parent window.
  48. * @param aPrincipal
  49. * Principal to bound storage to.
  50. * @param aPrivate
  51. * Whether the demanding document is running in Private Browsing mode or not.
  52. */
  53. nsIDOMStorage getStorage(in mozIDOMWindow aWindow,
  54. in nsIPrincipal aPrincipal,
  55. [optional] in bool aPrivate);
  56. /**
  57. * Clones given storage into this storage manager.
  58. *
  59. * @param aStorageToCloneFrom
  60. * The storage to copy all items from into this manager. Manager will then
  61. * return a new and independent object that contains snapshot of data from
  62. * the moment this method was called. Modification to this new object will
  63. * not affect the original storage content we cloned from and vice versa.
  64. */
  65. void cloneStorage(in nsIDOMStorage aStorageToCloneFrom);
  66. /**
  67. * Returns true if the storage belongs to the given principal and is managed
  68. * (i.e. has been created and is cached) by this storage manager.
  69. *
  70. * @param aPrincipal
  71. * Principal to check the storage against.
  72. * @param aStorage
  73. * The storage object to examine.
  74. *
  75. * @result
  76. * true when the storage object is bound with the principal and is managed
  77. * by this storage manager.
  78. * false otherwise
  79. */
  80. bool checkStorage(in nsIPrincipal aPrincipal,
  81. in nsIDOMStorage aStorage);
  82. /**
  83. * @deprecated
  84. *
  85. * Returns instance of localStorage object for aURI's origin.
  86. * This method ensures there is always only a single instance
  87. * for a single origin.
  88. *
  89. * Currently just forwards to the createStorage method of this
  90. * interface.
  91. *
  92. * Extension developers are strongly encouraged to use getStorage
  93. * or createStorage method instead.
  94. */
  95. nsIDOMStorage getLocalStorageForPrincipal(in nsIPrincipal aPrincipal,
  96. in DOMString aDocumentURI,
  97. [optional] in bool aPrivate);
  98. };