tor-browser

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

nsINotificationStorage.idl (3912B)


      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 
      5 #include "domstubs.idl"
      6 
      7 [scriptable, uuid(6b782346-49ec-41dd-8165-171506f8d4f4)]
      8 interface nsINotificationActionStorageEntry : nsISupports {
      9  readonly attribute AString name;
     10  readonly attribute AString title;
     11 };
     12 
     13 [scriptable, uuid(c772e1b9-d4b0-4e23-8481-4a8b7dbbfe92)]
     14 interface nsINotificationStorageEntry : nsISupports {
     15  readonly attribute AString id;
     16  readonly attribute AString title;
     17  readonly attribute ACString dir;
     18  readonly attribute AString lang;
     19  readonly attribute AString body;
     20  readonly attribute AString tag;
     21  readonly attribute ACString icon;
     22  readonly attribute boolean requireInteraction;
     23  readonly attribute boolean silent;
     24  readonly attribute AString dataSerialized;
     25  readonly attribute Array<nsINotificationActionStorageEntry> actions;
     26  readonly attribute AString serviceWorkerRegistrationScope;
     27 };
     28 
     29 [scriptable, function, uuid(c1622232-259c-43b0-b52e-89c39dcd9796)]
     30 interface nsINotificationStorageCallback : nsISupports
     31 {
     32  /**
     33   * Callback function used to pass single notification back
     34   * into C++ land for getNotifications() return data.
     35   *
     36   * @param aEntry: the stored notification entries
     37   */
     38  void done(in Array<nsINotificationStorageEntry> aEntries);
     39 };
     40 
     41 /**
     42 * Interface for notification persistence layer.
     43 */
     44 [scriptable, uuid(17f85e52-fe57-440e-9ba1-5c312ca02b95)]
     45 interface nsINotificationStorage : nsISupports
     46 {
     47 
     48  /**
     49   * Add/replace a notification to the persistence layer.
     50   *
     51   * @param aOrigin: the origin of this notification
     52   * @param aScope: the ServiceWorker registration scope, or empty if unscoped.
     53   * @param aEntry: the notification data to store
     54   */
     55  void put(in AString aOrigin,
     56           in nsINotificationStorageEntry aEntry,
     57           in AString aScope);
     58 
     59  /**
     60   * Retrieve a list of notifications.
     61   *
     62   * @param origin: the origin for which to fetch notifications from
     63   * @param scope: Used to limit for the specific scope.
     64   *               Pass an empty string for unscoped notifications.
     65   *               (See bug 1881812 for potential spec changes to how notifications
     66   *               are associated with ServiceWorker registrations.)
     67   * @param tag: used to fetch only a specific tag
     68   * @param callback: nsINotificationStorageCallback, used for
     69   *                  returning notifications objects
     70   */
     71  void get(in AString origin,
     72           in AString scope,
     73           in AString tag,
     74           in nsINotificationStorageCallback aCallback);
     75 
     76  /**
     77   * Retrieve a notification by ID.
     78   *
     79   * @param origin: the origin/app for which to fetch notifications from
     80   * @param tag: used to fetch only a specific tag
     81   */
     82  Promise getById(in AUTF8String origin, in AString id);
     83 
     84  /**
     85   * Remove a notification from storage.
     86   *
     87   * @param origin: the origin to delete the notification from
     88   * @param id: the uuid for the notification to delete
     89   */
     90  void delete(in AString origin,
     91              in AString id);
     92 
     93  /**
     94   * Remove all notifications from storage, except the ones in `ids`.
     95   *
     96   * This can be used to clean up old notifications that are not known to the
     97   * system notification backend anymore. It's needed because the backend can
     98   * discard notifications while Firefox is not running.
     99   *
    100   * No `origin` parameter because:
    101   *
    102   * 1. This should affect all known origins
    103   * 2. The IDs are unique and should not collide between origins
    104   *
    105   * @param ids: the ids for the notifications to not delete
    106   */
    107  void deleteAllExcept(in Array<AString> ids);
    108 };
    109 
    110 %{C++
    111 #define NS_NOTIFICATION_STORAGE_CONTRACTID "@mozilla.org/notificationStorage;1"
    112 %}
    113 
    114 %{C++
    115 #define NS_MEMORY_NOTIFICATION_STORAGE_CONTRACTID "@mozilla.org/memoryNotificationStorage;1"
    116 %}