| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 it is empty, this |
| 128 // method generates an id. If it matches an existing notification, this | 128 // method generates an id. If it matches an existing notification, this |
| 129 // method first clears that notification before proceeding with the create | 129 // method first clears that notification before proceeding with the create |
| 130 // operation. | 130 // operation. |
| 131 // |options|: Contents of the notification. | 131 // |options|: Contents of the notification. |
| 132 // |callback|: Returns the notification id (either supplied or generated) | 132 // |callback|: Returns the notification id (either supplied or generated) |
| 133 // that represents the created notification. | 133 // that represents the created notification. |
| 134 static void create(DOMString notificationId, | 134 static void create(DOMString notificationId, |
| 135 NotificationOptions options, | 135 NotificationOptions options, |
| 136 CreateCallback callback); | 136 optional CreateCallback callback); |
| 137 | 137 |
| 138 // Updates an existing notification. | 138 // Updates an existing notification. |
| 139 // |notificationId|: The id of the notification to be updated. This is | 139 // |notificationId|: The id of the notification to be updated. This is |
| 140 // returned by $(ref:notifications.create) method. | 140 // returned by $(ref:notifications.create) method. |
| 141 // |options|: Contents of the notification to update to. | 141 // |options|: Contents of the notification to update to. |
| 142 // |callback|: Called to indicate whether a matching notification existed. | 142 // |callback|: Called to indicate whether a matching notification existed. |
| 143 static void update(DOMString notificationId, | 143 static void update(DOMString notificationId, |
| 144 NotificationOptions options, | 144 NotificationOptions options, |
| 145 UpdateCallback callback); | 145 optional UpdateCallback callback); |
| 146 | 146 |
| 147 // Clears the specified notification. | 147 // Clears the specified notification. |
| 148 // |notificationId|: The id of the notification to be cleared. This is | 148 // |notificationId|: The id of the notification to be cleared. This is |
| 149 // returned by $(ref:notifications.create) method. | 149 // returned by $(ref:notifications.create) method. |
| 150 // |callback|: Called to indicate whether a matching notification existed. | 150 // |callback|: Called to indicate whether a matching notification existed. |
| 151 static void clear(DOMString notificationId, ClearCallback callback); | 151 static void clear(DOMString notificationId, |
| 152 optional ClearCallback callback); |
| 152 | 153 |
| 153 // Retrieves all the notifications. | 154 // Retrieves all the notifications. |
| 154 // |callback|: Returns the set of notification_ids currently in the system. | 155 // |callback|: Returns the set of notification_ids currently in the system. |
| 155 static void getAll(GetAllCallback callback); | 156 static void getAll(GetAllCallback callback); |
| 156 | 157 |
| 157 // Retrieves whether the user has enabled notifications from this app | 158 // Retrieves whether the user has enabled notifications from this app |
| 158 // or extension. | 159 // or extension. |
| 159 // |callback|: Returns the current permission level. | 160 // |callback|: Returns the current permission level. |
| 160 static void getPermissionLevel(PermissionLevelCallback callback); | 161 static void getPermissionLevel(PermissionLevelCallback callback); |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 interface Events { | 164 interface Events { |
| 164 // The notification closed, either by the system or by user action. | 165 // The notification closed, either by the system or by user action. |
| 165 static void onClosed(DOMString notificationId, boolean byUser); | 166 static void onClosed(DOMString notificationId, boolean byUser); |
| 166 | 167 |
| 167 // The user clicked in a non-button area of the notification. | 168 // The user clicked in a non-button area of the notification. |
| 168 static void onClicked(DOMString notificationId); | 169 static void onClicked(DOMString notificationId); |
| 169 | 170 |
| 170 // The user pressed a button in the notification. | 171 // The user pressed a button in the notification. |
| 171 static void onButtonClicked(DOMString notificationId, long buttonIndex); | 172 static void onButtonClicked(DOMString notificationId, long buttonIndex); |
| 172 | 173 |
| 173 // The user changes the permission level. | 174 // The user changes the permission level. |
| 174 static void onPermissionLevelChanged(PermissionLevel level); | 175 static void onPermissionLevelChanged(PermissionLevel level); |
| 175 | 176 |
| 176 // The user clicked on a link for the app's notification settings. | 177 // The user clicked on a link for the app's notification settings. |
| 177 static void onShowSettings(); | 178 static void onShowSettings(); |
| 178 }; | 179 }; |
| 179 | 180 |
| 180 }; | 181 }; |
| OLD | NEW |