webkit_notifications.js (5293B)
1 /* 2 * Copyright 2010 The Closure Compiler Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 /** 17 * @fileoverview Definitions for W3C's Notifications specification. 18 * @externs 19 */ 20 21 /** 22 * @typedef {{dir: (string|undefined), lang: (string|undefined), 23 * body: (string|undefined), tag: (string|undefined), 24 * icon: (string|undefined)}} 25 * @see http://notifications.spec.whatwg.org/#notificationoptions 26 */ 27 var NotificationOptions; 28 29 /** @interface */ 30 var NotificationOptionsInterface_; 31 /** @type {string} */ NotificationOptionsInterface_.prototype.dir; 32 /** @type {string} */ NotificationOptionsInterface_.prototype.lang; 33 /** @type {string} */ NotificationOptionsInterface_.prototype.body; 34 /** @type {string} */ NotificationOptionsInterface_.prototype.tag; 35 /** @type {string} */ NotificationOptionsInterface_.prototype.icon; 36 37 /** 38 * @param {string} title 39 * @param {NotificationOptions=} opt_options 40 * @constructor 41 * @implements {EventTarget} 42 * @see http://notifications.spec.whatwg.org/#notification 43 */ 44 function Notification(title, opt_options) {} 45 46 /** 47 * @type {string} 48 */ 49 Notification.permission; 50 51 /** 52 * @param {NotificationPermissionCallback=} opt_callback 53 */ 54 Notification.requestPermission = function(opt_callback) {}; 55 56 /** 57 * @param {boolean=} opt_useCapture 58 * @override 59 */ 60 Notification.prototype.addEventListener = 61 function(type, listener, opt_useCapture) {}; 62 63 /** 64 * @param {boolean=} opt_useCapture 65 * @override 66 */ 67 Notification.prototype.removeEventListener = 68 function(type, listener, opt_useCapture) {}; 69 70 /** @override */ 71 Notification.prototype.dispatchEvent = function(evt) {}; 72 73 /** 74 * The ID used by clients to uniquely identify notifications to eliminate 75 * duplicate notifications. 76 * @type {string} 77 * @deprecated Use NotificationOptions.tag instead. 78 */ 79 Notification.prototype.replaceId; 80 81 /** 82 * The string used by clients to specify the directionality (rtl/ltr) of the 83 * notification. 84 * @type {string} 85 * @deprecated Use NotificationOptions.titleDir and bodyDir instead. 86 */ 87 Notification.prototype.dir; 88 89 /** 90 * Displays the notification. 91 */ 92 Notification.prototype.show = function() {}; 93 94 /** 95 * Prevents the notification from being displayed, or closes it if it is already 96 * displayed. 97 */ 98 Notification.prototype.cancel = function() {}; 99 100 /** 101 * Prevents the notification from being displayed, or closes it if it is already 102 * displayed. 103 */ 104 Notification.prototype.close = function() {}; 105 106 /** 107 * An event handler called when notification is closed. 108 * @type {?function(Event)} 109 */ 110 Notification.prototype.onclose; 111 112 /** 113 * An event handler called if the notification could not be displayed due to 114 * an error (i.e. resource could not be loaded). 115 * @type {?function(Event)} 116 */ 117 Notification.prototype.onerror; 118 119 /** 120 * An event handler called when the notification has become visible. 121 * @type {?function(Event)} 122 * @deprecated Use onshow instead. 123 */ 124 Notification.prototype.ondisplay; 125 126 /** 127 * An event handler called when the notification has become visible. 128 * @type {?function(Event)} 129 */ 130 Notification.prototype.onshow; 131 132 /** 133 * An event handler called when the notification has been clicked on. 134 * @type {?function(Event)} 135 */ 136 Notification.prototype.onclick; 137 138 /** 139 * @constructor 140 */ 141 window.Notification = Notification; 142 143 /** 144 * @type {string} 145 */ 146 window.Notification.permission; 147 148 /** 149 * @param {NotificationPermissionCallback=} opt_callback 150 */ 151 window.Notification.requestPermission = function(opt_callback) {}; 152 153 /** 154 * @typedef {function(string)} 155 * @see http://notifications.spec.whatwg.org/#notificationpermissioncallback 156 */ 157 var NotificationPermissionCallback; 158 159 /** 160 * @constructor 161 * @see http://dev.w3.org/2006/webapi/WebNotifications/publish/#dialog-if 162 * @deprecated Use Notification instead. 163 */ 164 function NotificationCenter() {} 165 166 /** 167 * Creates a text+icon notification and displays it to the user. 168 * @param {string} iconUrl 169 * @param {string} title 170 * @param {string} body 171 * @return {Notification} 172 */ 173 NotificationCenter.prototype.createNotification = 174 function(iconUrl, title, body) {}; 175 176 /** 177 * Creates an HTML notification and displays it to the user. 178 * @param {string} url 179 * @return {Notification} 180 */ 181 NotificationCenter.prototype.createHTMLNotification = function(url) {}; 182 183 /** 184 * Checks if the user has permission to display notifications. 185 * @return {number} 186 */ 187 NotificationCenter.prototype.checkPermission = function() {}; 188 189 /** 190 * Requests permission from the user to display notifications. 191 * @param {Function=} opt_callback 192 * @return {void} 193 */ 194 NotificationCenter.prototype.requestPermission = function(opt_callback) {}; 195 196 /** 197 * WebKit browsers expose the NotificationCenter API through 198 * window.webkitNotifications. 199 * @type {NotificationCenter} 200 */ 201 Window.prototype.webkitNotifications;