File: nsINotificationStorage.idl

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (116 lines) | stat: -rw-r--r-- 3,911 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "domstubs.idl"

[scriptable, uuid(6b782346-49ec-41dd-8165-171506f8d4f4)]
interface nsINotificationActionStorageEntry : nsISupports {
  readonly attribute AString name;
  readonly attribute AString title;
};

[scriptable, uuid(c772e1b9-d4b0-4e23-8481-4a8b7dbbfe92)]
interface nsINotificationStorageEntry : nsISupports {
  readonly attribute AString id;
  readonly attribute AString title;
  readonly attribute ACString dir;
  readonly attribute AString lang;
  readonly attribute AString body;
  readonly attribute AString tag;
  readonly attribute AString icon;
  readonly attribute boolean requireInteraction;
  readonly attribute boolean silent;
  readonly attribute AString dataSerialized;
  readonly attribute Array<nsINotificationActionStorageEntry> actions;
  readonly attribute AString serviceWorkerRegistrationScope;
};

[scriptable, function, uuid(c1622232-259c-43b0-b52e-89c39dcd9796)]
interface nsINotificationStorageCallback : nsISupports
{
  /**
   * Callback function used to pass single notification back
   * into C++ land for getNotifications() return data.
   *
   * @param aEntry: the stored notification entries
   */
  void done(in Array<nsINotificationStorageEntry> aEntries);
};

/**
 * Interface for notification persistence layer.
 */
[scriptable, uuid(17f85e52-fe57-440e-9ba1-5c312ca02b95)]
interface nsINotificationStorage : nsISupports
{

  /**
   * Add/replace a notification to the persistence layer.
   *
   * @param aOrigin: the origin of this notification
   * @param aScope: the ServiceWorker registration scope, or empty if unscoped.
   * @param aEntry: the notification data to store
   */
  void put(in AString aOrigin,
           in nsINotificationStorageEntry aEntry,
           in AString aScope);

  /**
   * Retrieve a list of notifications.
   *
   * @param origin: the origin for which to fetch notifications from
   * @param scope: Used to limit for the specific scope.
   *               Pass an empty string for unscoped notifications.
   *               (See bug 1881812 for potential spec changes to how notifications
   *               are associated with ServiceWorker registrations.)
   * @param tag: used to fetch only a specific tag
   * @param callback: nsINotificationStorageCallback, used for
   *                  returning notifications objects
   */
  void get(in AString origin,
           in AString scope,
           in AString tag,
           in nsINotificationStorageCallback aCallback);

  /**
   * Retrieve a notification by ID.
   *
   * @param origin: the origin/app for which to fetch notifications from
   * @param tag: used to fetch only a specific tag
   */
  Promise getById(in AUTF8String origin, in AString id);

  /**
   * Remove a notification from storage.
   *
   * @param origin: the origin to delete the notification from
   * @param id: the uuid for the notification to delete
   */
  void delete(in AString origin,
              in AString id);

  /**
   * Remove all notifications from storage, except the ones in `ids`.
   *
   * This can be used to clean up old notifications that are not known to the
   * system notification backend anymore. It's needed because the backend can
   * discard notifications while Firefox is not running.
   *
   * No `origin` parameter because:
   *
   * 1. This should affect all known origins
   * 2. The IDs are unique and should not collide between origins
   *
   * @param ids: the ids for the notifications to not delete
   */
  void deleteAllExcept(in Array<AString> ids);
};

%{C++
#define NS_NOTIFICATION_STORAGE_CONTRACTID "@mozilla.org/notificationStorage;1"
%}

%{C++
#define NS_MEMORY_NOTIFICATION_STORAGE_CONTRACTID "@mozilla.org/memoryNotificationStorage;1"
%}