nsIWindowWatcher.idl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. /**
  39. * nsIWindowWatcher is the keeper of Gecko/DOM Windows. It maintains
  40. * a list of open top-level windows, and allows some operations on them.
  41. * Usage notes:
  42. * This component has an |activeWindow| property. Clients may expect
  43. * this property to be always current, so to properly integrate this component
  44. * the application will need to keep it current by setting the property
  45. * as the active window changes.
  46. * This component should not keep a (XPCOM) reference to any windows;
  47. * the implementation will claim no ownership. Windows must notify
  48. * this component when they are created or destroyed, so only a weak
  49. * reference is kept. Note that there is no interface for such notifications
  50. * (not a public one, anyway). This is taken care of both in Mozilla and
  51. * by common embedding code. Embedding clients need do nothing special
  52. * about that requirement.
  53. * This component must be initialized at application startup by calling
  54. * setWindowCreator.
  55. *
  56. * @status FROZEN
  57. */
  58. #include "nsISupports.idl"
  59. interface nsIDOMWindow;
  60. interface nsIObserver;
  61. interface nsIPrompt;
  62. interface nsIAuthPrompt;
  63. interface nsISimpleEnumerator;
  64. interface nsIWebBrowserChrome;
  65. interface nsIWindowCreator;
  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.
  76. @param aFeatures window features from JS window.open. can be null.
  77. @param aArguments extra argument(s) to the new window, to be attached
  78. as the |arguments| property. An nsISupportsArray will be
  79. unwound into multiple arguments (but not recursively!).
  80. can be null.
  81. @return the new window
  82. */
  83. nsIDOMWindow openWindow(in nsIDOMWindow aParent, in string aUrl,
  84. in string aName, in string aFeatures,
  85. in nsISupports aArguments);
  86. /** Clients of this service can register themselves to be notified
  87. when a window is opened or closed (added to or removed from this
  88. service). This method adds an aObserver to the list of objects
  89. to be notified.
  90. @param aObserver the object to be notified when windows are
  91. opened or closed. Its Observe method will be
  92. called with the following parameters:
  93. aObserver::Observe interprets its parameters so:
  94. aSubject the window being opened or closed, sent as an nsISupports
  95. which can be QIed to an nsIDOMWindow.
  96. aTopic a wstring, either "domwindowopened" or "domwindowclosed".
  97. someData not used.
  98. */
  99. void registerNotification(in nsIObserver aObserver);
  100. /** Clients of this service can register themselves to be notified
  101. when a window is opened or closed (added to or removed from this
  102. service). This method removes an aObserver from the list of objects
  103. to be notified.
  104. @param aObserver the observer to be removed.
  105. */
  106. void unregisterNotification(in nsIObserver aObserver);
  107. /** Get an iterator for currently open windows in the order they were opened,
  108. guaranteeing that each will be visited exactly once.
  109. @return an enumerator which will itself return nsISupports objects which
  110. can be QIed to an nsIDOMWindow
  111. */
  112. nsISimpleEnumerator getWindowEnumerator();
  113. /** Return a newly created nsIPrompt implementation.
  114. @param aParent the parent window used for posing alerts. can be null.
  115. @return a new nsIPrompt object
  116. */
  117. nsIPrompt getNewPrompter(in nsIDOMWindow aParent);
  118. /** Return a newly created nsIAuthPrompt implementation.
  119. @param aParent the parent window used for posing alerts. can be null.
  120. @return a new nsIAuthPrompt object
  121. */
  122. nsIAuthPrompt getNewAuthPrompter(in nsIDOMWindow aParent);
  123. /** Set the window creator callback. It must be filled in by the app.
  124. openWindow will use it to create new windows.
  125. @param creator the callback. if null, the callback will be cleared
  126. and window creation capabilities lost.
  127. */
  128. void setWindowCreator(in nsIWindowCreator creator);
  129. /** Retrieve the chrome window mapped to the given DOM window. Window
  130. Watcher keeps a list of all top-level DOM windows currently open,
  131. along with their corresponding chrome interfaces. Since DOM Windows
  132. lack a (public) means of retrieving their corresponding chrome,
  133. this method will do that.
  134. @param aWindow the DOM window whose chrome window the caller needs
  135. @return the corresponding chrome window
  136. */
  137. nsIWebBrowserChrome getChromeForWindow(in nsIDOMWindow aWindow);
  138. /**
  139. Retrieve an existing window (or frame).
  140. @param aTargetName the window name
  141. @param aCurrentWindow a starting point in the window hierarchy to
  142. begin the search. If null, each toplevel window
  143. will be searched.
  144. Note: This method will search all open windows for any window or
  145. frame with the given window name. Make sure you understand the
  146. security implications of this before using this method!
  147. */
  148. nsIDOMWindow getWindowByName(in wstring aTargetName,
  149. in nsIDOMWindow aCurrentWindow);
  150. /** The Watcher serves as a global storage facility for the current active
  151. (frontmost non-floating-palette-type) window, storing and returning
  152. it on demand. Users must keep this attribute current, including after
  153. the topmost window is closed. This attribute obviously can return null
  154. if no windows are open, but should otherwise always return a valid
  155. window.
  156. */
  157. attribute nsIDOMWindow activeWindow;
  158. };
  159. %{C++
  160. // {002286a8-494b-43b3-8ddd-49e3fc50622b}
  161. #define NS_WINDOWWATCHER_IID \
  162. {0x002286a8, 0x494b, 0x43b3, {0x8d, 0xdd, 0x49, 0xe3, 0xfc, 0x50, 0x62, 0x2b}}
  163. #define NS_WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
  164. %}