OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 namespace experimental.notification { | |
6 enum TemplateType { | |
7 // icon, title, message | |
8 simple, | |
9 | |
10 // icon, title, message, expandedMessage, up to two buttons | |
11 basic, | |
12 | |
13 // icon, title, message, expandedMessage, image, up to two buttons | |
14 image, | |
15 | |
16 // icon, title, message, items, up to two buttons | |
17 list | |
18 }; | |
19 | |
20 dictionary NotificationItem { | |
21 // Title of one item of a list notification. | |
22 DOMString title; | |
23 | |
24 // Additional details about this item. | |
25 DOMString message; | |
26 }; | |
27 | |
28 dictionary NotificationButton { | |
29 DOMString title; | |
30 DOMString? iconUrl; | |
31 }; | |
32 | |
33 dictionary NotificationOptions { | |
34 // Which type of notification to display. | |
35 TemplateType templateType; | |
36 | |
37 // Sender's avatar, app icon, or a thumbnail for image notifications. | |
38 DOMString iconUrl; | |
39 | |
40 // Title of the notification (e.g. sender name for email). | |
41 DOMString title; | |
42 | |
43 // Main notification content. | |
44 DOMString message; | |
45 | |
46 // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero | |
47 // is default. | |
48 long? priority; | |
49 | |
50 // A timestamp associated with the notification, in milliseconds past the | |
51 // epoch (e.g. <code>Date.now() + n</code>). | |
52 double? eventTime; | |
53 | |
54 // Smaller version of the icon. | |
55 DOMString? secondIconUrl; | |
56 | |
57 // Text and icons of notification action buttons. | |
58 NotificationButton[]? buttons; | |
59 | |
60 // Secondary notification content. | |
61 DOMString? expandedMessage; | |
62 | |
63 // Image thumbnail for image-type notifications. | |
64 DOMString? imageUrl; | |
65 | |
66 // Items for multi-item notifications. | |
67 NotificationItem[]? items; | |
68 }; | |
69 | |
70 callback CreateCallback = void (DOMString notificationId); | |
71 | |
72 callback UpdateCallback = void (boolean wasUpdated); | |
73 | |
74 callback ClearCallback = void (boolean wasCleared); | |
75 | |
76 interface Functions { | |
77 // Creates and displays a notification having the contents in |options|, | |
78 // identified by the id |notificationId|. If |notificationId| is empty, | |
79 // |create| generates an id. If |notificationId| matches an existing | |
80 // notification, |create| first clears that notification before proceeding | |
81 // with the create operation. |callback| returns the notification id | |
82 // (either supplied or generated) that represents the created notification. | |
83 static void create(DOMString notificationId, | |
84 NotificationOptions options, | |
85 CreateCallback callback); | |
86 | |
87 // Updates an existing notification having the id |notificationId| and the | |
88 // options |options|. |callback| indicates whether a matching notification | |
89 // existed. | |
90 static void update(DOMString notificationId, | |
91 NotificationOptions options, | |
92 UpdateCallback callback); | |
93 | |
94 // Given a |notificationId| returned by the |create| method, clears the | |
95 // corresponding notification. |callback| indicates whether a matching | |
96 // notification existed. | |
97 static void clear(DOMString notificationId, ClearCallback callback); | |
98 }; | |
99 | |
100 interface Events { | |
101 // The system displayed the notification. Not all created notifications are | |
102 // displayed; for example, a low-priority notification might simply appear | |
103 // in the message center without interrupting the user. | |
104 static void onDisplayed(DOMString notificationId); | |
105 | |
106 // The notification closed, either by the system or by user action. | |
107 static void onClosed(DOMString notificationId, boolean byUser); | |
108 | |
109 // The user clicked in a non-button area of the notification. | |
110 static void onClicked(DOMString notificationId); | |
111 | |
112 // The user pressed a button in the notification. | |
113 static void onButtonClicked(DOMString notificationId, long buttonIndex); | |
114 }; | |
115 | |
116 }; | |
OLD | NEW |