OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 [nodoc] namespace experimental.notification { | 5 [nodoc] namespace experimental.notification { |
6 enum TemplateType { | 6 enum TemplateType { |
7 // icon, title, message | 7 // icon, title, message |
8 simple, | 8 simple, |
9 | 9 |
10 // icon, title, message, expandedMessage, up to two buttons | 10 // icon, title, message, expandedMessage, up to two buttons |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 NotificationButton[]? buttons; | 58 NotificationButton[]? buttons; |
59 | 59 |
60 // Secondary notification content. | 60 // Secondary notification content. |
61 DOMString? expandedMessage; | 61 DOMString? expandedMessage; |
62 | 62 |
63 // Image thumbnail for image-type notifications. | 63 // Image thumbnail for image-type notifications. |
64 DOMString? imageUrl; | 64 DOMString? imageUrl; |
65 | 65 |
66 // Items for multi-item notifications. | 66 // Items for multi-item notifications. |
67 NotificationItem[]? items; | 67 NotificationItem[]? items; |
| 68 |
| 69 // Object specifying user data for the notification. Values that cannot be |
| 70 // serialized (functions, etc) will be ignored. |
| 71 object? userData; |
68 }; | 72 }; |
69 | 73 |
70 callback CreateCallback = void (DOMString notificationId); | 74 callback CreateCallback = void (DOMString notificationId); |
71 | 75 |
72 callback UpdateCallback = void (boolean wasUpdated); | 76 callback UpdateCallback = void (boolean wasUpdated); |
73 | 77 |
74 callback ClearCallback = void (boolean wasCleared); | 78 callback ClearCallback = void (boolean wasCleared); |
75 | 79 |
| 80 // |useData| is NotificationOptions.userData that was passed to create/update |
| 81 // call, if was specified, null otherwise. |
| 82 callback GetCallback = void (object userData); |
| 83 |
| 84 // |notifications| is a map from all notifications IDs of all notifications |
| 85 // to their userData objects, if were specified, otherwise, nulls. |
| 86 callback GetAllCallback = void (object notifications); |
| 87 |
76 interface Functions { | 88 interface Functions { |
77 // Creates and displays a notification having the contents in |options|, | 89 // Creates and displays a notification having the contents in |options|, |
78 // identified by the id |notificationId|. If |notificationId| is empty, | 90 // identified by the id |notificationId|. If |notificationId| is empty, |
79 // |create| generates an id. If |notificationId| matches an existing | 91 // |create| generates an id. If |notificationId| matches an existing |
80 // notification, |create| first clears that notification before proceeding | 92 // notification, |create| first clears that notification before proceeding |
81 // with the create operation. |callback| returns the notification id | 93 // with the create operation. |callback| returns the notification id |
82 // (either supplied or generated) that represents the created notification. | 94 // (either supplied or generated) that represents the created notification. |
83 static void create(DOMString notificationId, | 95 static void create(DOMString notificationId, |
84 NotificationOptions options, | 96 NotificationOptions options, |
85 CreateCallback callback); | 97 CreateCallback callback); |
86 | 98 |
87 // Updates an existing notification having the id |notificationId| and the | 99 // Updates an existing notification having the id |notificationId| and the |
88 // options |options|. |callback| indicates whether a matching notification | 100 // options |options|. |callback| indicates whether a matching notification |
89 // existed. | 101 // existed. |
90 static void update(DOMString notificationId, | 102 static void update(DOMString notificationId, |
91 NotificationOptions options, | 103 NotificationOptions options, |
92 UpdateCallback callback); | 104 UpdateCallback callback); |
93 | 105 |
94 // Given a |notificationId| returned by the |create| method, clears the | 106 // Given a |notificationId| returned by the |create| method, clears the |
95 // corresponding notification. |callback| indicates whether a matching | 107 // corresponding notification. |callback| indicates whether a matching |
96 // notification existed. | 108 // notification existed. |
97 static void clear(DOMString notificationId, ClearCallback callback); | 109 static void clear(DOMString notificationId, ClearCallback callback); |
| 110 |
| 111 static void clearAll(); |
| 112 |
| 113 static void get(DOMString notificationId, GetCallback callback); |
| 114 |
| 115 // Returns to |callback| ids and user data of all locally created |
| 116 // notifications. |
| 117 static void getAll(GetAllCallback callback); |
98 }; | 118 }; |
99 | 119 |
100 interface Events { | 120 interface Events { |
101 // The system displayed the notification. Not all created notifications are | 121 // The system displayed the notification. Not all created notifications are |
102 // displayed; for example, a low-priority notification might simply appear | 122 // displayed; for example, a low-priority notification might simply appear |
103 // in the message center without interrupting the user. | 123 // in the message center without interrupting the user. |
104 static void onDisplayed(DOMString notificationId); | 124 static void onDisplayed(DOMString notificationId); |
105 | 125 |
106 // The notification closed, either by the system or by user action. | 126 // The notification closed, either by the system or by user action. |
107 static void onClosed(DOMString notificationId, boolean byUser); | 127 static void onClosed(DOMString notificationId, |
| 128 boolean byUser, |
| 129 object userData); |
108 | 130 |
109 // The user clicked in a non-button area of the notification. | 131 // The user clicked in a non-button area of the notification. |
110 static void onClicked(DOMString notificationId); | 132 static void onClicked(DOMString notificationId, |
| 133 object userData); |
111 | 134 |
112 // The user pressed a button in the notification. | 135 // The user pressed a button in the notification. |
113 static void onButtonClicked(DOMString notificationId, long buttonIndex); | 136 static void onButtonClicked(DOMString notificationId, |
| 137 long buttonIndex, |
| 138 object userData); |
114 }; | 139 }; |
115 | 140 |
116 }; | 141 }; |
OLD | NEW |