nsIPlatformGlue.idl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is mozilla.org Code.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Mozilla.org.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. * Mark Finkle <mark.finkle@gmail.com>
  25. * Matthew Gertner <matthew.gertner@gmail.com>
  26. *
  27. * Alternatively, the contents of this file may be used under the terms of
  28. * either the GNU General Public License Version 2 or later (the "GPL"), or
  29. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30. * in which case the provisions of the GPL or the LGPL are applicable instead
  31. * of those above. If you wish to allow use of your version of this file only
  32. * under the terms of either the GPL or the LGPL, and not to allow others to
  33. * use your version of this file under the terms of the MPL, indicate your
  34. * decision by deleting the provisions above and replace them with the notice
  35. * and other provisions required by the GPL or the LGPL. If you do not delete
  36. * the provisions above, a recipient may use your version of this file under
  37. * the terms of any one of the MPL, the GPL or the LGPL.
  38. *
  39. * ***** END LICENSE BLOCK ***** */
  40. /* Development of this Contribution was supported by Yahoo! Inc. */
  41. #include "nsISupports.idl"
  42. interface nsIApplicationIcon;
  43. interface nsIDOMWindow;
  44. interface nsIWebProgress;
  45. /**
  46. * Interface that gives simplified access to sound functionality
  47. */
  48. [scriptable, uuid(1be49d70-ec6d-11dc-95ff-0800200c9a66)]
  49. interface nsIPlatformGlueSound : nsISupports
  50. {
  51. /**
  52. * Makes a beeping noise.
  53. */
  54. void beep();
  55. /**
  56. * Plays a given sound resource.
  57. * @param aSoundURI
  58. * The URI of a sound resource
  59. */
  60. void playSound(in AString aSoundURI);
  61. };
  62. [function, scriptable, uuid(0d835990-2b21-11dd-bd0b-0800200c9a66)]
  63. interface nsIPlatformProtocolCallback : nsISupports
  64. {
  65. void handleURI(in AString uriSpec);
  66. };
  67. /**
  68. * Interface which must by implemented by listeners for showNotification
  69. */
  70. [scriptable, uuid(5edb55a7-3303-4d58-ac22-5b1712752caf)]
  71. interface nsIPlatformNotificationListener : nsISupports
  72. {
  73. /**
  74. * Callback executed when the user clicks on the notification.
  75. */
  76. void onClick();
  77. /**
  78. * Callback executed when the notification is finished and fades out.
  79. */
  80. void onFinished();
  81. };
  82. /**
  83. * Interface that web content can use to prevent shutdown
  84. */
  85. [scriptable, function, uuid(c609b327-e889-4560-9bcd-04d502436288)]
  86. interface nsIPlatformShutdownCallback : nsISupports
  87. {
  88. /**
  89. * Callback executed before shutdown.
  90. *
  91. * @returns True if the app can shutdown, false to prevent
  92. */
  93. boolean canShutdown();
  94. };
  95. /**
  96. * Interface that gives simplified access to platform functionality
  97. */
  98. [scriptable, uuid(64ef7c50-ec69-11dc-95ff-0800200c9a66)]
  99. interface nsIPlatformGlue : nsISupports
  100. {
  101. /**
  102. * Sends a given string to the console.
  103. * @param aTitle
  104. * The title of the alert
  105. * @param aText
  106. * The text of the alert
  107. * @param aImageURI
  108. * The URI of an image to use in alert. Can be null for no image.
  109. * @param textClickable
  110. * Make notification text clickable. Will execute click() method of
  111. * listener on click.
  112. * @param aListener
  113. * An object to receive callbacks from the notification. Can be null
  114. * for no callback functionality.
  115. * Implements a click() method executed when the user clicks on the
  116. * notification and a finished() method executed on notification fade
  117. * out.
  118. */
  119. void showNotification(in AString aTitle,
  120. in AString aText,
  121. [optional] in AString aImageURI,
  122. [optional] in boolean textClickable,
  123. [optional] in nsIPlatformNotificationListener aListener);
  124. /**
  125. * Post a name/value pair to the browser chrome. The browser is free to do
  126. * whatever it wants with this data
  127. * @param aName
  128. * The name or key for the data
  129. * @param aValue
  130. * The value of the data
  131. */
  132. void postStatus(in AString aName, in AString aValue);
  133. /**
  134. * Open the URI in the default browser.
  135. * @param aURISpec
  136. * URI to open
  137. */
  138. void openURI(in AString aURISpec);
  139. /**
  140. * Quit the application.
  141. */
  142. void quit();
  143. /**
  144. * Access to the sound interface.
  145. */
  146. nsIPlatformGlueSound sound();
  147. /**
  148. * Access to application tile icon (notification area or dock).
  149. */
  150. nsIApplicationIcon icon();
  151. /**
  152. * Register the application as the default handler for the specified URI scheme.
  153. *
  154. * @param uriScheme The scheme to register.
  155. * @param uriString The address to load for a URI of the given scheme. "%s" is used as a
  156. * place holder for the URI (e.g. "http://www.mymail.com?compose&to=%s").
  157. */
  158. void registerProtocolHandler(in AString uriScheme, in AString uriString);
  159. /**
  160. * Register a callback to be invoked (instead of navigating to the URI specified in
  161. * registerProtocolHandler) when the user loads a URI with the specified scheme.
  162. *
  163. * @param callback Callback to invoke.
  164. */
  165. void registerProtocolCallback(in AString uriScheme, in nsIPlatformProtocolCallback callback);
  166. /**
  167. * Unregister the application as the default handle for the specified URI scheme.
  168. *
  169. * @param uriScheme The scheme to unregister.
  170. */
  171. void unregisterProtocolHandler(in AString uriScheme);
  172. /**
  173. * Get the URI spec to use for the provided URI. The URI scheme is analyzed and the appropriate
  174. * protocol handler URI is used. If there is no protocol handler registered for the scheme, an
  175. * empty string is returned.
  176. *
  177. * @param uri URI to get the protocol handler address for (e.g. "mailto:matthew.gertner@gmail.com").
  178. * @returns the URI to load (e.g. "http://www.mymail.com?compose&to=matthew.gertner@gmail.com") or
  179. * an empty string if no protocol handler is registered for the scheme.
  180. */
  181. AString getProtocolURI(in AString uriSpec, out nsIPlatformProtocolCallback callback);
  182. /**
  183. * Check whether we are currently the registered handler for the specified protocol.
  184. *
  185. * @param uriScheme Protocol to check.
  186. */
  187. boolean isRegisteredProtocolHandler(in AString uriScheme);
  188. /**
  189. * Use the appropriate platform-specific mechanism to indicate that the window requires attention.
  190. */
  191. void getAttention();
  192. /**
  193. * Restore minimized window
  194. */
  195. void restoreWindow();
  196. /**
  197. * Display the preferences dialog.
  198. *
  199. * @param paneToShow The name of the pane to display when the dialog is opened.
  200. */
  201. void showPreferences(in AString paneToShow);
  202. /**
  203. * Display the About dialog.
  204. */
  205. void showAbout();
  206. /**
  207. * Clear private data (cache, history, etc.).
  208. */
  209. void clearPrivateData();
  210. /**
  211. * Register a callback from web content that can prevent app shutdown.
  212. *
  213. * @param Callback interface (function) returns true to allow shutdown, false to prevent
  214. */
  215. void registerShutdownCallback(in nsIPlatformShutdownCallback callback);
  216. /**
  217. * Invokes the shutdown callback, if any.
  218. *
  219. * @returns True if it is okay to shutdown (including if there is no callback), false otherwise
  220. */
  221. boolean invokeShutdownCallback();
  222. };