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 18 matching lines...) Expand all Loading... |
29 }; | 29 }; |
30 | 30 |
31 dictionary NotificationItem { | 31 dictionary NotificationItem { |
32 // Title of one item of a list notification. | 32 // Title of one item of a list notification. |
33 DOMString title; | 33 DOMString title; |
34 | 34 |
35 // Additional details about this item. | 35 // Additional details about this item. |
36 DOMString message; | 36 DOMString message; |
37 }; | 37 }; |
38 | 38 |
39 [nodoc] dictionary NotificationBitmap { | 39 // Contains an array of RGBA bitmap data, 32 bits per channel. |data| |
40 long width; | 40 // should therefore have a length equal to 4 * width * height. |
41 long height; | 41 dictionary BitmapData { |
42 ArrayBuffer? data; | 42 ArrayBuffer data; |
| 43 double width; |
| 44 double height; |
| 45 }; |
| 46 |
| 47 dictionary ImageRepresentation { |
| 48 // The pixel ratio for which this bitmap is intended. |
| 49 double density; |
| 50 |
| 51 // A URL from which the image will be downloaded. |
| 52 (DOMString or BitmapData) src; |
43 }; | 53 }; |
44 | 54 |
45 dictionary NotificationButton { | 55 dictionary NotificationButton { |
46 DOMString title; | 56 DOMString title; |
| 57 |
| 58 // The icon used with the button. Useful for giving users immediate context
, |
| 59 // but title must provide all necessary information about the action to be |
| 60 // taken. Either an icon URL or a spec must be provided. |
47 DOMString? iconUrl; | 61 DOMString? iconUrl; |
48 [nodoc] NotificationBitmap? iconBitmap; | 62 ImageRepresentation[]? iconReps; |
49 }; | 63 }; |
50 | 64 |
51 dictionary NotificationOptions { | 65 dictionary NotificationOptions { |
52 // Which type of notification to display. | 66 // Which type of notification to display. |
53 // <em>Required for $(ref:notifications.create)</em> method. | 67 // <em>Required for $(ref:notifications.create)</em> method. |
54 TemplateType? type; | 68 TemplateType? type; |
55 | 69 |
56 // Sender's avatar, app icon, or a thumbnail for image notifications. | 70 // Sender's avatar, app icon, or a thumbnail for image notifications. This |
57 // <em>Required for $(ref:notifications.create)</em> method. | 71 // image in the notification is most useful when it provides specific |
| 72 // context, such as an avatar, or contact photo. |
| 73 // Either an iconUrl or an ImageRepresentation must be provided. |
58 DOMString? iconUrl; | 74 DOMString? iconUrl; |
59 [nodoc] NotificationBitmap? iconBitmap; | 75 ImageRepresentation[]? iconReps; |
60 | 76 |
61 // Title of the notification (e.g. sender name for email). | 77 // Title of the notification (e.g. sender name for email). |
62 // <em>Required for $(ref:notifications.create)</em> method. | 78 // <em>Required for $(ref:notifications.create)</em> method. |
63 DOMString? title; | 79 DOMString? title; |
64 | 80 |
65 // Main notification content. | 81 // Main notification content. |
66 // <em>Required for $(ref:notifications.create)</em> method. | 82 // <em>Required for $(ref:notifications.create)</em> method. |
67 DOMString? message; | 83 DOMString? message; |
68 | 84 |
69 // Alternate notification content with a lower-weight font. | 85 // Alternate notification content with a lower-weight font. |
70 DOMString? contextMessage; | 86 DOMString? contextMessage; |
71 | 87 |
72 // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero | 88 // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero |
73 // is default. | 89 // is default. |
74 long? priority; | 90 long? priority; |
75 | 91 |
76 // A timestamp associated with the notification, in milliseconds past the | 92 // A timestamp associated with the notification, in milliseconds past the |
77 // epoch (e.g. <code>Date.now() + n</code>). | 93 // epoch (e.g. <code>Date.now() + n</code>). |
78 double? eventTime; | 94 double? eventTime; |
79 | 95 |
80 // Text and icons for up to two notification action buttons. | 96 // Text and icons for up to two notification action buttons. |
81 NotificationButton[]? buttons; | 97 NotificationButton[]? buttons; |
82 | 98 |
83 // Secondary notification content. | 99 // Secondary notification content. This field is deprecated and unused. |
84 [nodoc] DOMString? expandedMessage; | 100 [deprecated] DOMString? expandedMessage; |
85 | 101 |
86 // Image thumbnail for image-type notifications. | 102 // Image thumbnail for image-type notifications. This field will be rendere
d |
| 103 // in a very prominent position at a larger size than the icon. Either an |
| 104 // imageUrl or an imageSpec must be provided. |
87 DOMString? imageUrl; | 105 DOMString? imageUrl; |
88 [nodoc] NotificationBitmap? imageBitmap; | 106 ImageRepresentation[]? imageReps; |
89 | 107 |
90 // Items for multi-item notifications. | 108 // Items for multi-item notifications. |
91 NotificationItem[]? items; | 109 NotificationItem[]? items; |
92 | 110 |
93 // Current progress ranges from 0 to 100. | 111 // Current progress ranges from 0 to 100. |
94 long? progress; | 112 long? progress; |
95 | 113 |
96 // Whether to show UI indicating that the app will visibly respond to | 114 // Whether to show UI indicating that the app will visibly respond to |
97 // clicks on the body of a notification. | 115 // clicks on the body of a notification. |
98 boolean? isClickable; | 116 boolean? isClickable; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 static void onButtonClicked(DOMString notificationId, long buttonIndex); | 175 static void onButtonClicked(DOMString notificationId, long buttonIndex); |
158 | 176 |
159 // The user changes the permission level. | 177 // The user changes the permission level. |
160 static void onPermissionLevelChanged(PermissionLevel level); | 178 static void onPermissionLevelChanged(PermissionLevel level); |
161 | 179 |
162 // The user clicked on a link for the app's notification settings. | 180 // The user clicked on a link for the app's notification settings. |
163 static void onShowSettings(); | 181 static void onShowSettings(); |
164 }; | 182 }; |
165 | 183 |
166 }; | 184 }; |
OLD | NEW |