PageRenderTime 32ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_sdk/idl/nsIWindowWatcher.idl

http://firefox-mac-pdf.googlecode.com/
IDL | 202 lines | 29 code | 23 blank | 150 comment | 0 complexity | 5f82f220d24c7b500ab92de0bbc58e9f MD5 | raw file
  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. * Netscape Communications, Inc.
  20. * Portions created by the Initial Developer are Copyright (C) 2001
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #include "nsISupports.idl"
  39. interface nsIDOMWindow;
  40. interface nsIObserver;
  41. interface nsIPrompt;
  42. interface nsIAuthPrompt;
  43. interface nsISimpleEnumerator;
  44. interface nsIWebBrowserChrome;
  45. interface nsIWindowCreator;
  46. /**
  47. * nsIWindowWatcher is the keeper of Gecko/DOM Windows. It maintains
  48. * a list of open top-level windows, and allows some operations on them.
  49. * Usage notes:
  50. * This component has an |activeWindow| property. Clients may expect
  51. * this property to be always current, so to properly integrate this component
  52. * the application will need to keep it current by setting the property
  53. * as the active window changes.
  54. * This component should not keep a (XPCOM) reference to any windows;
  55. * the implementation will claim no ownership. Windows must notify
  56. * this component when they are created or destroyed, so only a weak
  57. * reference is kept. Note that there is no interface for such notifications
  58. * (not a public one, anyway). This is taken care of both in Mozilla and
  59. * by common embedding code. Embedding clients need do nothing special
  60. * about that requirement.
  61. * This component must be initialized at application startup by calling
  62. * setWindowCreator.
  63. *
  64. * @status FROZEN
  65. */
  66. [scriptable, uuid(002286a8-494b-43b3-8ddd-49e3fc50622b)]
  67. interface nsIWindowWatcher : nsISupports {
  68. /** Create a new window. It will automatically be added to our list
  69. (via addWindow()).
  70. @param aParent parent window, if any. Null if no parent. If it is
  71. impossible to get to an nsIWebBrowserChrome from aParent, this
  72. method will effectively act as if aParent were null.
  73. @param aURL url to which to open the new window. Must already be
  74. escaped, if applicable. can be null.
  75. @param aName window name from JS window.open. can be null. If a window
  76. with this name already exists, the openWindow call may just load
  77. aUrl in it (if aUrl is not null) and return it.
  78. @param aFeatures window features from JS window.open. can be null.
  79. @param aArguments extra argument(s) to the new window, to be attached
  80. as the |arguments| property. An nsISupportsArray will be
  81. unwound into multiple arguments (but not recursively!).
  82. can be null.
  83. @return the new window
  84. @note This method may examine the JS context stack for purposes of
  85. determining the security context to use for the search for a given
  86. window named aName.
  87. @note This method should try to set the default charset for the new
  88. window to the default charset of aParent. This is not guaranteed,
  89. however.
  90. @note This method may dispatch a "toplevel-window-ready" notification
  91. via nsIObserverService if the window did not already exist.
  92. */
  93. nsIDOMWindow openWindow(in nsIDOMWindow aParent, in string aUrl,
  94. in string aName, in string aFeatures,
  95. in nsISupports aArguments);
  96. /** Clients of this service can register themselves to be notified
  97. when a window is opened or closed (added to or removed from this
  98. service). This method adds an aObserver to the list of objects
  99. to be notified.
  100. @param aObserver the object to be notified when windows are
  101. opened or closed. Its Observe method will be
  102. called with the following parameters:
  103. aObserver::Observe interprets its parameters so:
  104. aSubject the window being opened or closed, sent as an nsISupports
  105. which can be QIed to an nsIDOMWindow.
  106. aTopic a wstring, either "domwindowopened" or "domwindowclosed".
  107. someData not used.
  108. */
  109. void registerNotification(in nsIObserver aObserver);
  110. /** Clients of this service can register themselves to be notified
  111. when a window is opened or closed (added to or removed from this
  112. service). This method removes an aObserver from the list of objects
  113. to be notified.
  114. @param aObserver the observer to be removed.
  115. */
  116. void unregisterNotification(in nsIObserver aObserver);
  117. /** Get an iterator for currently open windows in the order they were opened,
  118. guaranteeing that each will be visited exactly once.
  119. @return an enumerator which will itself return nsISupports objects which
  120. can be QIed to an nsIDOMWindow
  121. */
  122. nsISimpleEnumerator getWindowEnumerator();
  123. /** Return a newly created nsIPrompt implementation.
  124. @param aParent the parent window used for posing alerts. can be null.
  125. @return a new nsIPrompt object
  126. */
  127. nsIPrompt getNewPrompter(in nsIDOMWindow aParent);
  128. /** Return a newly created nsIAuthPrompt implementation.
  129. @param aParent the parent window used for posing alerts. can be null.
  130. @return a new nsIAuthPrompt object
  131. */
  132. nsIAuthPrompt getNewAuthPrompter(in nsIDOMWindow aParent);
  133. /** Set the window creator callback. It must be filled in by the app.
  134. openWindow will use it to create new windows.
  135. @param creator the callback. if null, the callback will be cleared
  136. and window creation capabilities lost.
  137. */
  138. void setWindowCreator(in nsIWindowCreator creator);
  139. /** Retrieve the chrome window mapped to the given DOM window. Window
  140. Watcher keeps a list of all top-level DOM windows currently open,
  141. along with their corresponding chrome interfaces. Since DOM Windows
  142. lack a (public) means of retrieving their corresponding chrome,
  143. this method will do that.
  144. @param aWindow the DOM window whose chrome window the caller needs
  145. @return the corresponding chrome window
  146. */
  147. nsIWebBrowserChrome getChromeForWindow(in nsIDOMWindow aWindow);
  148. /**
  149. Retrieve an existing window (or frame).
  150. @param aTargetName the window name
  151. @param aCurrentWindow a starting point in the window hierarchy to
  152. begin the search. If null, each toplevel window
  153. will be searched.
  154. Note: This method will search all open windows for any window or
  155. frame with the given window name. Make sure you understand the
  156. security implications of this before using this method!
  157. */
  158. nsIDOMWindow getWindowByName(in wstring aTargetName,
  159. in nsIDOMWindow aCurrentWindow);
  160. /** The Watcher serves as a global storage facility for the current active
  161. (frontmost non-floating-palette-type) window, storing and returning
  162. it on demand. Users must keep this attribute current, including after
  163. the topmost window is closed. This attribute obviously can return null
  164. if no windows are open, but should otherwise always return a valid
  165. window.
  166. */
  167. attribute nsIDOMWindow activeWindow;
  168. };
  169. %{C++
  170. // {002286a8-494b-43b3-8ddd-49e3fc50622b}
  171. #define NS_WINDOWWATCHER_IID \
  172. {0x002286a8, 0x494b, 0x43b3, {0x8d, 0xdd, 0x49, 0xe3, 0xfc, 0x50, 0x62, 0x2b}}
  173. #define NS_WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
  174. %}