summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/schemas/notifications.json
blob: 30ba8a2765d6001ba0cee09e07f790a9cb64b7b2 (plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace": "notifications",
    "permissions": ["notifications"],
    "types": [
      {
        "id": "TemplateType",
        "type": "string",
        "enum": ["basic", "image", "list", "progress"]
      },
      {
        "id": "PermissionLevel",
        "type": "string",
        "enum": ["granted", "denied"]
      },
      {
        "id": "NotificationItem",
        "type": "object",
        "properties": {
          "title": {
            "description": "Title of one item of a list notification.",
            "type": "string"
          },
          "message": {
            "description": "Additional details about this item.",
            "type": "string"
          }
        }
      },
      {
        "id": "CreateNotificationOptions",
        "type": "object",
        "properties": {
          "type": {
            "description": "Which type of notification to display.",
            "$ref": "TemplateType"
          },
          "iconUrl": {
            "optional": true,
            "description": "A URL to the sender's avatar, app icon, or a thumbnail for image notifications.",
            "type": "string"
          },
          "appIconMaskUrl": {
            "optional": true,
            "description": "A URL to the app icon mask.",
            "type": "string"
          },
          "title": {
            "description": "Title of the notification (e.g. sender name for email).",
            "type": "string"
          },
          "message": {
            "description": "Main notification content.",
            "type": "string"
          },
          "contextMessage": {
            "optional": true,
            "description": "Alternate notification content with a lower-weight font.",
            "type": "string"
          },
          "priority": {
            "optional": true,
            "description": "Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default.",
            "type": "integer",
            "minimum": -2,
            "maximum": 2
          },
          "eventTime": {
            "optional": true,
            "description": "A timestamp associated with the notification, in milliseconds past the epoch.",
            "type": "number"
          },
          "buttons": {
            "unsupported": true,
            "optional": true,
            "description": "Text and icons for up to two notification action buttons.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "iconUrl": {
                  "optional": true,
                  "type": "string"
                }
              }
            }
          },
          "imageUrl": {
            "optional": true,
            "description": "A URL to the image thumbnail for image-type notifications.",
            "type": "string"
          },
          "items": {
            "optional": true,
            "description": "Items for multi-item notifications.",
            "type": "array",
            "items": { "$ref": "NotificationItem" }
          },
          "progress": {
            "optional": true,
            "description": "Current progress ranges from 0 to 100.",
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "isClickable": {
            "optional": true,
            "description": "Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.",
            "type": "boolean"
          }
        }
      },
      {
        "id": "UpdateNotificationOptions",
        "type": "object",
        "properties": {
          "type": {
            "optional": true,
            "description": "Which type of notification to display.",
            "$ref": "TemplateType"
          },
          "iconUrl": {
            "optional": true,
            "description": "A URL to the sender's avatar, app icon, or a thumbnail for image notifications.",
            "type": "string"
          },
          "appIconMaskUrl": {
            "optional": true,
            "description": "A URL to the app icon mask.",
            "type": "string"
          },
          "title": {
            "optional": true,
            "description": "Title of the notification (e.g. sender name for email).",
            "type": "string"
          },
          "message": {
            "optional": true,
            "description": "Main notification content.",
            "type": "string"
          },
          "contextMessage": {
            "optional": true,
            "description": "Alternate notification content with a lower-weight font.",
            "type": "string"
          },
          "priority": {
            "optional": true,
            "description": "Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default.",
            "type": "integer",
            "minimum": -2,
            "maximum": 2
          },
          "eventTime": {
            "optional": true,
            "description": "A timestamp associated with the notification, in milliseconds past the epoch.",
            "type": "number"
          },
          "buttons": {
            "unsupported": true,
            "optional": true,
            "description": "Text and icons for up to two notification action buttons.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "iconUrl": {
                  "optional": true,
                  "type": "string"
                }
              }
            }
          },
          "imageUrl": {
            "optional": true,
            "description": "A URL to the image thumbnail for image-type notifications.",
            "type": "string"
          },
          "items": {
            "optional": true,
            "description": "Items for multi-item notifications.",
            "type": "array",
            "items": { "$ref": "NotificationItem" }
          },
          "progress": {
            "optional": true,
            "description": "Current progress ranges from 0 to 100.",
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "isClickable": {
            "optional": true,
            "description": "Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.",
            "type": "boolean"
          }
        }
      }
    ],
    "functions": [
      {
        "name": "create",
        "type": "function",
        "description": "Creates and displays a notification.",
        "async": "callback",
        "parameters": [
          {
            "optional": true,
            "type": "string",
            "name": "notificationId",
            "description": "Identifier of the notification. If it is empty, this method generates an id. If it matches an existing notification, this method first clears that notification before proceeding with the create operation."
          },
          {
            "$ref": "CreateNotificationOptions",
            "name": "options",
            "description": "Contents of the notification."
          },
          {
            "optional": true,
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "notificationId",
                "type": "string",
                "description": "The notification id (either supplied or generated) that represents the created notification."
              }
            ]
          }
        ]
      },
      {
        "name": "update",
        "unsupported": true,
        "type": "function",
        "description": "Updates an existing notification.",
        "async": "callback",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The id of the notification to be updated."
          },
          {
            "$ref": "UpdateNotificationOptions",
            "name": "options",
            "description": "Contents of the notification to update to."
          },
          {
            "optional": true,
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "wasUpdated",
                "type": "boolean",
                "description": "Indicates whether a matching notification existed."
              }
            ]
          }
        ]
      },
      {
        "name": "clear",
        "type": "function",
        "description": "Clears an existing notification.",
        "async": "callback",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The id of the notification to be updated."
          },
          {
            "optional": true,
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "wasCleared",
                "type": "boolean",
                "description": "Indicates whether a matching notification existed."
              }
            ]
          }
        ]
      },
      {
        "name": "getAll",
        "type": "function",
        "description": "Retrieves all the notifications.",
        "async": "callback",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "notifications",
                "type": "object",
                "additionalProperties": { "$ref": "CreateNotificationOptions" },
                "description": "The set of notifications currently in the system."
              }
            ]
          }
        ]
      },
      {
        "name": "getPermissionLevel",
        "unsupported": true,
        "type": "function",
        "description": "Retrieves whether the user has enabled notifications from this app or extension.",
        "async": "callback",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "level",
                "$ref": "PermissionLevel",
                "description": "The current permission level."
              }
            ]
          }
        ]
      }
    ],
    "events": [
      {
        "name": "onClosed",
        "type": "function",
        "description": "Fired when the notification closed, either by the system or by user action.",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The notificationId of the closed notification."
          },
          {
            "type": "boolean",
            "name": "byUser",
            "description": "True if the notification was closed by the user."
          }
        ]
      },
      {
        "name": "onClicked",
        "type": "function",
        "description": "Fired when the user clicked in a non-button area of the notification.",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The notificationId of the clicked notification."
          }
        ]
      },
      {
        "name": "onButtonClicked",
        "type": "function",
        "description": "Fired when the  user pressed a button in the notification.",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The notificationId of the clicked notification."
          },
          {
            "type": "number",
            "name": "buttonIndex",
            "description": "The index of the button clicked by the user."
          }
        ]
      },
      {
        "name": "onPermissionLevelChanged",
        "unsupported": true,
        "type": "function",
        "description": "Fired when the user changes the permission level.",
        "parameters": [
          {
            "$ref": "PermissionLevel",
            "name": "level",
            "description": "The new permission level."
          }
        ]
      },
      {
        "name": "onShowSettings",
        "unsupported": true,
        "type": "function",
        "description": "Fired when the user clicked on a link for the app's notification settings.",
        "parameters": []
      },
      {
        "name": "onShown",
        "type": "function",
        "description": "Fired when the notification is shown.",
        "parameters": [
          {
            "type": "string",
            "name": "notificationId",
            "description": "The notificationId of the shown notification."
          }
        ]
      }
    ]
  }
]