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 // Use the <code>chrome.notifications</code> API to create rich notifications | 5 // Use the <code>chrome.notifications</code> API to create rich notifications |
6 // using templates and show these notifications to users in the system tray. | 6 // using templates and show these notifications to users in the system tray. |
7 namespace notifications { | 7 namespace notifications { |
8 [noinline_doc] enum TemplateType { | 8 [noinline_doc] enum TemplateType { |
9 // icon, title, message, expandedMessage, up to two buttons | 9 // icon, title, message, expandedMessage, up to two buttons |
10 basic, | 10 basic, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 callback UpdateCallback = void (boolean wasUpdated); | 117 callback UpdateCallback = void (boolean wasUpdated); |
118 | 118 |
119 callback ClearCallback = void (boolean wasCleared); | 119 callback ClearCallback = void (boolean wasCleared); |
120 | 120 |
121 callback GetAllCallback = void (object notifications); | 121 callback GetAllCallback = void (object notifications); |
122 | 122 |
123 callback PermissionLevelCallback = void (PermissionLevel level); | 123 callback PermissionLevelCallback = void (PermissionLevel level); |
124 | 124 |
125 interface Functions { | 125 interface Functions { |
126 // Creates and displays a notification. | 126 // Creates and displays a notification. |
127 // |notificationId|: Identifier of the notification. If it is empty, this | 127 // |notificationId|: Identifier of the notification. If not set or empty, an |
128 // method generates an id. If it matches an existing notification, this | 128 // ID will automatically be generated. If it matches an existing |
129 // method first clears that notification before proceeding with the create | 129 // notification, this method first clears that notification before |
130 // operation. | 130 // proceeding with the create operation. |
| 131 // |
| 132 // The <code>notificationId</code> parameter is required before Chrome 42. |
131 // |options|: Contents of the notification. | 133 // |options|: Contents of the notification. |
132 // |callback|: Returns the notification id (either supplied or generated) | 134 // |callback|: Returns the notification id (either supplied or generated) |
133 // that represents the created notification. | 135 // that represents the created notification. |
134 static void create(DOMString notificationId, | 136 // |
| 137 // The callback is required before Chrome 42. |
| 138 static void create(optional DOMString notificationId, |
135 NotificationOptions options, | 139 NotificationOptions options, |
136 CreateCallback callback); | 140 optional CreateCallback callback); |
137 | 141 |
138 // Updates an existing notification. | 142 // Updates an existing notification. |
139 // |notificationId|: The id of the notification to be updated. This is | 143 // |notificationId|: The id of the notification to be updated. This is |
140 // returned by $(ref:notifications.create) method. | 144 // returned by $(ref:notifications.create) method. |
141 // |options|: Contents of the notification to update to. | 145 // |options|: Contents of the notification to update to. |
142 // |callback|: Called to indicate whether a matching notification existed. | 146 // |callback|: Called to indicate whether a matching notification existed. |
| 147 // |
| 148 // The callback is required before Chrome 42. |
143 static void update(DOMString notificationId, | 149 static void update(DOMString notificationId, |
144 NotificationOptions options, | 150 NotificationOptions options, |
145 UpdateCallback callback); | 151 optional UpdateCallback callback); |
146 | 152 |
147 // Clears the specified notification. | 153 // Clears the specified notification. |
148 // |notificationId|: The id of the notification to be cleared. This is | 154 // |notificationId|: The id of the notification to be cleared. This is |
149 // returned by $(ref:notifications.create) method. | 155 // returned by $(ref:notifications.create) method. |
150 // |callback|: Called to indicate whether a matching notification existed. | 156 // |callback|: Called to indicate whether a matching notification existed. |
151 static void clear(DOMString notificationId, ClearCallback callback); | 157 // |
| 158 // The callback is required before Chrome 42. |
| 159 static void clear(DOMString notificationId, |
| 160 optional ClearCallback callback); |
152 | 161 |
153 // Retrieves all the notifications. | 162 // Retrieves all the notifications. |
154 // |callback|: Returns the set of notification_ids currently in the system. | 163 // |callback|: Returns the set of notification_ids currently in the system. |
155 static void getAll(GetAllCallback callback); | 164 static void getAll(GetAllCallback callback); |
156 | 165 |
157 // Retrieves whether the user has enabled notifications from this app | 166 // Retrieves whether the user has enabled notifications from this app |
158 // or extension. | 167 // or extension. |
159 // |callback|: Returns the current permission level. | 168 // |callback|: Returns the current permission level. |
160 static void getPermissionLevel(PermissionLevelCallback callback); | 169 static void getPermissionLevel(PermissionLevelCallback callback); |
161 }; | 170 }; |
162 | 171 |
163 interface Events { | 172 interface Events { |
164 // The notification closed, either by the system or by user action. | 173 // The notification closed, either by the system or by user action. |
165 static void onClosed(DOMString notificationId, boolean byUser); | 174 static void onClosed(DOMString notificationId, boolean byUser); |
166 | 175 |
167 // The user clicked in a non-button area of the notification. | 176 // The user clicked in a non-button area of the notification. |
168 static void onClicked(DOMString notificationId); | 177 static void onClicked(DOMString notificationId); |
169 | 178 |
170 // The user pressed a button in the notification. | 179 // The user pressed a button in the notification. |
171 static void onButtonClicked(DOMString notificationId, long buttonIndex); | 180 static void onButtonClicked(DOMString notificationId, long buttonIndex); |
172 | 181 |
173 // The user changes the permission level. | 182 // The user changes the permission level. |
174 static void onPermissionLevelChanged(PermissionLevel level); | 183 static void onPermissionLevelChanged(PermissionLevel level); |
175 | 184 |
176 // The user clicked on a link for the app's notification settings. | 185 // The user clicked on a link for the app's notification settings. |
177 static void onShowSettings(); | 186 static void onShowSettings(); |
178 }; | 187 }; |
179 | 188 |
180 }; | 189 }; |
OLD | NEW |