nsINotificationStorage.idl 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. #include "domstubs.idl"
  5. [scriptable, uuid(c1622232-259c-43b0-b52e-89c39dcd9796)]
  6. interface nsINotificationStorageCallback : nsISupports
  7. {
  8. /**
  9. * Callback function used to pass single notification back
  10. * into C++ land for Notification.get return data.
  11. *
  12. * @param id: a uuid for this notification
  13. * @param title: the notification title
  14. * @param dir: the notification direction,
  15. * possible values are "ltr", "rtl", "auto"
  16. * @param lang: the notification language
  17. * @param body: the notification body
  18. * @param tag: the notification tag
  19. */
  20. void handle(in DOMString id,
  21. in DOMString title,
  22. in DOMString dir,
  23. in DOMString lang,
  24. in DOMString body,
  25. in DOMString tag,
  26. in DOMString icon,
  27. in DOMString data,
  28. in DOMString behavior,
  29. in DOMString serviceWorkerRegistrationScope);
  30. /**
  31. * Callback function used to notify C++ the we have returned
  32. * all notification objects for this Notification.get call.
  33. */
  34. void done();
  35. };
  36. /**
  37. * Interface for notification persistence layer.
  38. */
  39. [scriptable, uuid(17f85e52-fe57-440e-9ba1-5c312ca02b95)]
  40. interface nsINotificationStorage : nsISupports
  41. {
  42. /**
  43. * Add/replace a notification to the persistence layer.
  44. *
  45. * @param origin: the origin/app of this notification
  46. * @param id: a uuid for this notification
  47. * @param title: the notification title
  48. * @param dir: the notification direction,
  49. * possible values are "ltr", "rtl", "auto"
  50. * @param lang: the notification language
  51. * @param body: the notification body
  52. * @param tag: notification tag, will replace any existing
  53. * notifications with same origin/tag pair
  54. * @param alertName: the alert identifier as used by system app.
  55. * Stored in the database to avoid re-computing
  56. * it. Built from origin and tag or id depending
  57. * whether there is a tag defined.
  58. * @param registrationID: Opaque string that identifies the service worker
  59. * registration this Notification is associated with.
  60. * May be empty. Only set for Notifications created by
  61. * showNotification().
  62. */
  63. void put(in DOMString origin,
  64. in DOMString id,
  65. in DOMString title,
  66. in DOMString dir,
  67. in DOMString lang,
  68. in DOMString body,
  69. in DOMString tag,
  70. in DOMString icon,
  71. in DOMString alertName,
  72. in DOMString data,
  73. in DOMString behavior,
  74. in DOMString serviceWorkerRegistrationScope);
  75. /**
  76. * Retrieve a list of notifications.
  77. *
  78. * @param origin: the origin/app for which to fetch notifications from
  79. * @param tag: used to fetch only a specific tag
  80. * @param callback: nsINotificationStorageCallback, used for
  81. * returning notifications objects
  82. */
  83. void get(in DOMString origin,
  84. in DOMString tag,
  85. in nsINotificationStorageCallback aCallback);
  86. /**
  87. * Retrieve a notification by ID.
  88. *
  89. * @param origin: the origin/app for which to fetch notifications.
  90. * @param id: the id of the notification.
  91. * @param callback: nsINotificationStorageCallback whose Handle method will
  92. * be called *at most once* if the notification with that ID is found. Not
  93. * called if that ID is not found. Done() will be called right after
  94. * Handle().
  95. */
  96. void getByID(in DOMString origin,
  97. in DOMString id,
  98. in nsINotificationStorageCallback aCallback);
  99. /**
  100. * Remove a notification from storage.
  101. *
  102. * @param origin: the origin/app to delete the notification from
  103. * @param id: the uuid for the notification to delete
  104. */
  105. void delete(in DOMString origin,
  106. in DOMString id);
  107. /**
  108. * Notifications are not supposed to be persistent, according to spec, at
  109. * least for now. But we want to be able to have this behavior on B2G. Thus,
  110. * this method will check if the origin sending the notifications is a valid
  111. * registered app with a manifest or not. Hence, a webpage that has none
  112. * will have its notification sent and available (via Notification.get())
  113. * during the life time of the page.
  114. *
  115. * @param origin: Origin from which the notification is sent.
  116. *
  117. * @return boolean
  118. */
  119. boolean canPut(in DOMString origin);
  120. };
  121. %{C++
  122. #define NS_NOTIFICATION_STORAGE_CONTRACTID "@mozilla.org/notificationStorage;1"
  123. %}