1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.notifications</code> API to create rich notifications
// using templates and show these notifications to users in the system tray.
namespace notifications {
enum TemplateType {
// Contains an icon, title, message, expandedMessage, and up to two
// buttons.
basic,
// Contains an icon, title, message, expandedMessage, image, and up
// to two buttons.
[deprecated="The image is not visible for Mac OS X users."]
image,
// Contains an icon, title, message, items, and up to two buttons.
// Users on Mac OS X only see the first item.
list,
// Contains an icon, title, message, progress, and up to two buttons.
progress
};
enum PermissionLevel {
// Specifies that the user has elected to show notifications
// from the app or extension. This is the default at install time.
granted,
// Specifies that the user has elected not to show notifications
// from the app or extension.
denied
};
dictionary NotificationItem {
// Title of one item of a list notification.
DOMString title;
// Additional details about this item.
DOMString message;
};
[nodoc] dictionary NotificationBitmap {
long width;
long height;
ArrayBuffer? data;
};
dictionary NotificationButton {
DOMString title;
[deprecated="Button icons not visible for Mac OS X users."]
DOMString? iconUrl;
[nodoc] NotificationBitmap? iconBitmap;
};
dictionary NotificationOptions {
// Which type of notification to display.
// <em>Required for $(ref:notifications.create)</em> method.
TemplateType? type;
// A URL to the sender's avatar, app icon, or a thumbnail for image
// notifications.
//
// URLs can be a data URL, a blob URL, or a URL relative to a resource
// within this extension's .crx file
// <aside class="note"><b>Note:</b>This value is required for the
// $(ref:notifications.create)<code>()</code> method.</aside>
DOMString? iconUrl;
[nodoc] NotificationBitmap? iconBitmap;
// A URL to the app icon mask. URLs have the same restrictions as
// $(ref:notifications.NotificationOptions.iconUrl iconUrl).
//
// The app icon mask should be in alpha channel, as only the alpha channel
// of the image will be considered.
[deprecated="The app icon mask is not visible for Mac OS X users."]
DOMString? appIconMaskUrl;
[nodoc] NotificationBitmap? appIconMaskBitmap;
// Title of the notification (e.g. sender name for email).
// <aside class="note"><b>Note:</b>This value is required for the
// $(ref:notifications.create)<code>()</code> method.</aside>
DOMString? title;
// Main notification content.
// <aside class="note"><b>Note:</b>This value is required for the
// $(ref:notifications.create)<code>()</code> method.</aside>
DOMString? message;
// Alternate notification content with a lower-weight font.
DOMString? contextMessage;
// Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero
// is default. On platforms that don't support a notification center
// (Windows, Linux & Mac), -2 and -1 result in an error as notifications
// with those priorities will not be shown at all.
long? priority;
// A timestamp associated with the notification, in milliseconds past the
// epoch (e.g. <code>Date.now() + n</code>).
double? eventTime;
// Text and icons for up to two notification action buttons.
NotificationButton[]? buttons;
// Secondary notification content.
[nodoc] DOMString? expandedMessage;
// A URL to the image thumbnail for image-type notifications.
// URLs have the same restrictions as
// $(ref:notifications.NotificationOptions.iconUrl iconUrl).
[deprecated="The image is not visible for Mac OS X users."]
DOMString? imageUrl;
[nodoc] NotificationBitmap? imageBitmap;
// Items for multi-item notifications. Users on Mac OS X only see the first
// item.
NotificationItem[]? items;
// Current progress ranges from 0 to 100.
long? progress;
[deprecated="This UI hint is ignored as of Chrome 67"]
boolean? isClickable;
// Indicates that the notification should remain visible on screen until the
// user activates or dismisses the notification. This defaults to false.
boolean? requireInteraction;
// Indicates that no sounds or vibrations should be made when the
// notification is being shown. This defaults to false.
boolean? silent;
};
callback CreateCallback = void (DOMString notificationId);
callback UpdateCallback = void (boolean wasUpdated);
callback ClearCallback = void (boolean wasCleared);
callback GetAllCallback = void (object notifications);
callback PermissionLevelCallback = void (PermissionLevel level);
interface Functions {
// Creates and displays a notification.
// |notificationId|: Identifier of the notification. If not set or empty, an
// ID will automatically be generated. If it matches an existing
// notification, this method first clears that notification before
// proceeding with the create operation. The identifier may not be longer
// than 500 characters.
//
// The <code>notificationId</code> parameter is required before Chrome 42.
// |options|: Contents of the notification.
// |callback|: Returns the notification id (either supplied or generated)
// that represents the created notification.
//
// The callback is required before Chrome 42.
static void create(
optional DOMString notificationId,
NotificationOptions options,
optional CreateCallback callback);
// Updates an existing notification.
// |notificationId|: The id of the notification to be updated. This is
// returned by $(ref:notifications.create) method.
// |options|: Contents of the notification to update to.
// |callback|: Called to indicate whether a matching notification existed.
//
// The callback is required before Chrome 42.
static void update(
DOMString notificationId,
NotificationOptions options,
optional UpdateCallback callback);
// Clears the specified notification.
// |notificationId|: The id of the notification to be cleared. This is
// returned by $(ref:notifications.create) method.
// |callback|: Called to indicate whether a matching notification existed.
//
// The callback is required before Chrome 42.
static void clear(
DOMString notificationId,
optional ClearCallback callback);
// Retrieves all the notifications of this app or extension.
// |callback|: Returns the set of notification_ids currently in the system.
static void getAll(GetAllCallback callback);
// Retrieves whether the user has enabled notifications from this app
// or extension.
// |callback|: Returns the current permission level.
static void getPermissionLevel(
PermissionLevelCallback callback);
};
interface Events {
// The notification closed, either by the system or by user action.
static void onClosed(DOMString notificationId, boolean byUser);
// The user clicked in a non-button area of the notification.
static void onClicked(DOMString notificationId);
// The user pressed a button in the notification.
static void onButtonClicked(DOMString notificationId, long buttonIndex);
// The user changes the permission level. As of Chrome 47, only ChromeOS
// has UI that dispatches this event.
static void onPermissionLevelChanged(PermissionLevel level);
// The user clicked on a link for the app's notification settings. As of
// Chrome 47, only ChromeOS has UI that dispatches this event.
// As of Chrome 65, that UI has been removed from ChromeOS, too.
[deprecated="Custom notification settings button is no longer supported."]
static void onShowSettings();
};
};
|