1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/alerts/nsIAlertsService.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,106 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +#include "nsISupports.idl" 1.11 +#include "nsIObserver.idl" 1.12 + 1.13 +interface nsIPrincipal; 1.14 + 1.15 +[scriptable, uuid(160e87e1-d57d-456b-b6ea-17826f6ea7a8)] 1.16 +interface nsIAlertsService : nsISupports 1.17 +{ 1.18 + /** 1.19 + * Displays a sliding notification window. 1.20 + * 1.21 + * @param imageUrl A URL identifying the image to put in the alert. 1.22 + * The OS X implemenation limits the amount of time it 1.23 + * will wait for an icon to load to six seconds. After 1.24 + * that time the alert will show with no icon. 1.25 + * @param title The title for the alert. 1.26 + * @param text The contents of the alert. 1.27 + * @param textClickable If true, causes the alert text to look like a link 1.28 + * and notifies the listener when user attempts to 1.29 + * click the alert text. 1.30 + * @param cookie A blind cookie the alert will pass back to the 1.31 + * consumer during the alert listener callbacks. 1.32 + * @param alertListener Used for callbacks. May be null if the caller 1.33 + * doesn't care about callbacks. 1.34 + * @param name The name of the notification. This is currently only 1.35 + * used on Android and OS X. On Android the name is 1.36 + * hashed and used as a notification ID. Notifications 1.37 + * will replace previous notifications with the same name. 1.38 + * @param dir Bidi override for the title. Valid values are 1.39 + * "auto", "ltr" or "rtl". Only available on supported 1.40 + * platforms. 1.41 + * @param lang Language of title and text of the alert. Only available 1.42 + * on supported platforms. 1.43 + * @throws NS_ERROR_NOT_AVAILABLE If the notification cannot be displayed. 1.44 + * 1.45 + * The following arguments will be passed to the alertListener's observe() 1.46 + * method: 1.47 + * subject - null 1.48 + * topic - "alertfinished" when the alert goes away 1.49 + * "alertclickcallback" when the text is clicked 1.50 + * "alertshow" when the alert is shown 1.51 + * data - the value of the cookie parameter passed to showAlertNotification. 1.52 + * 1.53 + * @note Depending on current circumstances (if the user's in a fullscreen 1.54 + * application, for instance), the alert might not be displayed at all. 1.55 + * In that case, if an alert listener is passed in it will receive the 1.56 + * "alertfinished" notification immediately. 1.57 + */ 1.58 + void showAlertNotification(in AString imageUrl, 1.59 + in AString title, 1.60 + in AString text, 1.61 + [optional] in boolean textClickable, 1.62 + [optional] in AString cookie, 1.63 + [optional] in nsIObserver alertListener, 1.64 + [optional] in AString name, 1.65 + [optional] in AString dir, 1.66 + [optional] in AString lang, 1.67 + [optional] in nsIPrincipal principal); 1.68 + 1.69 + /** 1.70 + * Close alerts created by the service. 1.71 + * 1.72 + * @param name The name of the notification to close. If no name 1.73 + * is provided then only a notification created with 1.74 + * no name (if any) will be closed. 1.75 + */ 1.76 + void closeAlert([optional] in AString name, 1.77 + [optional] in nsIPrincipal principal); 1.78 +}; 1.79 + 1.80 +[scriptable, uuid(df1bd4b0-3a8c-40e6-806a-203f38b0bd9f)] 1.81 +interface nsIAlertsProgressListener : nsISupports 1.82 +{ 1.83 + /** 1.84 + * Called to notify the alert service that progress has occurred for the 1.85 + * given notification previously displayed with showAlertNotification(). 1.86 + * 1.87 + * @param name The name of the notification displaying the 1.88 + * progress. On Android the name is hashed and used 1.89 + * as a notification ID. 1.90 + * @param progress Numeric value in the range 0 to progressMax 1.91 + * indicating the current progress. 1.92 + * @param progressMax Numeric value indicating the maximum progress. 1.93 + * @param text The contents of the alert. If not provided, 1.94 + * the percentage will be displayed. 1.95 + */ 1.96 + void onProgress(in AString name, 1.97 + in long long progress, 1.98 + in long long progressMax, 1.99 + [optional] in AString text); 1.100 + 1.101 + /** 1.102 + * Called to cancel and hide the given notification previously displayed 1.103 + * with showAlertNotification(). 1.104 + * 1.105 + * @param name The name of the notification. 1.106 + */ 1.107 + void onCancel(in AString name); 1.108 +}; 1.109 +