|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 #include "nsISupports.idl" |
|
8 #include "nsIObserver.idl" |
|
9 |
|
10 interface nsIPrincipal; |
|
11 |
|
12 [scriptable, uuid(160e87e1-d57d-456b-b6ea-17826f6ea7a8)] |
|
13 interface nsIAlertsService : nsISupports |
|
14 { |
|
15 /** |
|
16 * Displays a sliding notification window. |
|
17 * |
|
18 * @param imageUrl A URL identifying the image to put in the alert. |
|
19 * The OS X implemenation limits the amount of time it |
|
20 * will wait for an icon to load to six seconds. After |
|
21 * that time the alert will show with no icon. |
|
22 * @param title The title for the alert. |
|
23 * @param text The contents of the alert. |
|
24 * @param textClickable If true, causes the alert text to look like a link |
|
25 * and notifies the listener when user attempts to |
|
26 * click the alert text. |
|
27 * @param cookie A blind cookie the alert will pass back to the |
|
28 * consumer during the alert listener callbacks. |
|
29 * @param alertListener Used for callbacks. May be null if the caller |
|
30 * doesn't care about callbacks. |
|
31 * @param name The name of the notification. This is currently only |
|
32 * used on Android and OS X. On Android the name is |
|
33 * hashed and used as a notification ID. Notifications |
|
34 * will replace previous notifications with the same name. |
|
35 * @param dir Bidi override for the title. Valid values are |
|
36 * "auto", "ltr" or "rtl". Only available on supported |
|
37 * platforms. |
|
38 * @param lang Language of title and text of the alert. Only available |
|
39 * on supported platforms. |
|
40 * @throws NS_ERROR_NOT_AVAILABLE If the notification cannot be displayed. |
|
41 * |
|
42 * The following arguments will be passed to the alertListener's observe() |
|
43 * method: |
|
44 * subject - null |
|
45 * topic - "alertfinished" when the alert goes away |
|
46 * "alertclickcallback" when the text is clicked |
|
47 * "alertshow" when the alert is shown |
|
48 * data - the value of the cookie parameter passed to showAlertNotification. |
|
49 * |
|
50 * @note Depending on current circumstances (if the user's in a fullscreen |
|
51 * application, for instance), the alert might not be displayed at all. |
|
52 * In that case, if an alert listener is passed in it will receive the |
|
53 * "alertfinished" notification immediately. |
|
54 */ |
|
55 void showAlertNotification(in AString imageUrl, |
|
56 in AString title, |
|
57 in AString text, |
|
58 [optional] in boolean textClickable, |
|
59 [optional] in AString cookie, |
|
60 [optional] in nsIObserver alertListener, |
|
61 [optional] in AString name, |
|
62 [optional] in AString dir, |
|
63 [optional] in AString lang, |
|
64 [optional] in nsIPrincipal principal); |
|
65 |
|
66 /** |
|
67 * Close alerts created by the service. |
|
68 * |
|
69 * @param name The name of the notification to close. If no name |
|
70 * is provided then only a notification created with |
|
71 * no name (if any) will be closed. |
|
72 */ |
|
73 void closeAlert([optional] in AString name, |
|
74 [optional] in nsIPrincipal principal); |
|
75 }; |
|
76 |
|
77 [scriptable, uuid(df1bd4b0-3a8c-40e6-806a-203f38b0bd9f)] |
|
78 interface nsIAlertsProgressListener : nsISupports |
|
79 { |
|
80 /** |
|
81 * Called to notify the alert service that progress has occurred for the |
|
82 * given notification previously displayed with showAlertNotification(). |
|
83 * |
|
84 * @param name The name of the notification displaying the |
|
85 * progress. On Android the name is hashed and used |
|
86 * as a notification ID. |
|
87 * @param progress Numeric value in the range 0 to progressMax |
|
88 * indicating the current progress. |
|
89 * @param progressMax Numeric value indicating the maximum progress. |
|
90 * @param text The contents of the alert. If not provided, |
|
91 * the percentage will be displayed. |
|
92 */ |
|
93 void onProgress(in AString name, |
|
94 in long long progress, |
|
95 in long long progressMax, |
|
96 [optional] in AString text); |
|
97 |
|
98 /** |
|
99 * Called to cancel and hide the given notification previously displayed |
|
100 * with showAlertNotification(). |
|
101 * |
|
102 * @param name The name of the notification. |
|
103 */ |
|
104 void onCancel(in AString name); |
|
105 }; |
|
106 |