Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIDOMWindow; |
michael@0 | 10 | interface nsIObserver; |
michael@0 | 11 | interface nsIPrompt; |
michael@0 | 12 | interface nsIAuthPrompt; |
michael@0 | 13 | interface nsISimpleEnumerator; |
michael@0 | 14 | interface nsIWebBrowserChrome; |
michael@0 | 15 | interface nsIWindowCreator; |
michael@0 | 16 | |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * nsIWindowWatcher is the keeper of Gecko/DOM Windows. It maintains |
michael@0 | 21 | * a list of open top-level windows, and allows some operations on them. |
michael@0 | 22 | |
michael@0 | 23 | * Usage notes: |
michael@0 | 24 | |
michael@0 | 25 | * This component has an |activeWindow| property. Clients may expect |
michael@0 | 26 | * this property to be always current, so to properly integrate this component |
michael@0 | 27 | * the application will need to keep it current by setting the property |
michael@0 | 28 | * as the active window changes. |
michael@0 | 29 | * This component should not keep a (XPCOM) reference to any windows; |
michael@0 | 30 | * the implementation will claim no ownership. Windows must notify |
michael@0 | 31 | * this component when they are created or destroyed, so only a weak |
michael@0 | 32 | * reference is kept. Note that there is no interface for such notifications |
michael@0 | 33 | * (not a public one, anyway). This is taken care of both in Mozilla and |
michael@0 | 34 | * by common embedding code. Embedding clients need do nothing special |
michael@0 | 35 | * about that requirement. |
michael@0 | 36 | * This component must be initialized at application startup by calling |
michael@0 | 37 | * setWindowCreator. |
michael@0 | 38 | */ |
michael@0 | 39 | [scriptable, uuid(67bc1691-fbaf-484a-a15b-c96212b45034)] |
michael@0 | 40 | interface nsIWindowWatcher : nsISupports { |
michael@0 | 41 | |
michael@0 | 42 | /** Create a new window. It will automatically be added to our list |
michael@0 | 43 | (via addWindow()). |
michael@0 | 44 | @param aParent parent window, if any. Null if no parent. If it is |
michael@0 | 45 | impossible to get to an nsIWebBrowserChrome from aParent, this |
michael@0 | 46 | method will effectively act as if aParent were null. |
michael@0 | 47 | @param aURL url to which to open the new window. Must already be |
michael@0 | 48 | escaped, if applicable. can be null. |
michael@0 | 49 | @param aName window name from JS window.open. can be null. If a window |
michael@0 | 50 | with this name already exists, the openWindow call may just load |
michael@0 | 51 | aUrl in it (if aUrl is not null) and return it. |
michael@0 | 52 | @param aFeatures window features from JS window.open. can be null. |
michael@0 | 53 | @param aArguments extra argument(s) to the new window, to be attached |
michael@0 | 54 | as the |arguments| property. An nsISupportsArray will be |
michael@0 | 55 | unwound into multiple arguments (but not recursively!). |
michael@0 | 56 | can be null. |
michael@0 | 57 | @return the new window |
michael@0 | 58 | |
michael@0 | 59 | @note This method may examine the JS context stack for purposes of |
michael@0 | 60 | determining the security context to use for the search for a given |
michael@0 | 61 | window named aName. |
michael@0 | 62 | @note This method should try to set the default charset for the new |
michael@0 | 63 | window to the default charset of aParent. This is not guaranteed, |
michael@0 | 64 | however. |
michael@0 | 65 | @note This method may dispatch a "toplevel-window-ready" notification |
michael@0 | 66 | via nsIObserverService if the window did not already exist. |
michael@0 | 67 | */ |
michael@0 | 68 | nsIDOMWindow openWindow(in nsIDOMWindow aParent, in string aUrl, |
michael@0 | 69 | in string aName, in string aFeatures, |
michael@0 | 70 | in nsISupports aArguments); |
michael@0 | 71 | |
michael@0 | 72 | /** Clients of this service can register themselves to be notified |
michael@0 | 73 | when a window is opened or closed (added to or removed from this |
michael@0 | 74 | service). This method adds an aObserver to the list of objects |
michael@0 | 75 | to be notified. |
michael@0 | 76 | @param aObserver the object to be notified when windows are |
michael@0 | 77 | opened or closed. Its Observe method will be |
michael@0 | 78 | called with the following parameters: |
michael@0 | 79 | |
michael@0 | 80 | aObserver::Observe interprets its parameters so: |
michael@0 | 81 | aSubject the window being opened or closed, sent as an nsISupports |
michael@0 | 82 | which can be QIed to an nsIDOMWindow. |
michael@0 | 83 | aTopic a wstring, either "domwindowopened" or "domwindowclosed". |
michael@0 | 84 | someData not used. |
michael@0 | 85 | */ |
michael@0 | 86 | void registerNotification(in nsIObserver aObserver); |
michael@0 | 87 | |
michael@0 | 88 | /** Clients of this service can register themselves to be notified |
michael@0 | 89 | when a window is opened or closed (added to or removed from this |
michael@0 | 90 | service). This method removes an aObserver from the list of objects |
michael@0 | 91 | to be notified. |
michael@0 | 92 | @param aObserver the observer to be removed. |
michael@0 | 93 | */ |
michael@0 | 94 | void unregisterNotification(in nsIObserver aObserver); |
michael@0 | 95 | |
michael@0 | 96 | /** Get an iterator for currently open windows in the order they were opened, |
michael@0 | 97 | guaranteeing that each will be visited exactly once. |
michael@0 | 98 | @return an enumerator which will itself return nsISupports objects which |
michael@0 | 99 | can be QIed to an nsIDOMWindow |
michael@0 | 100 | */ |
michael@0 | 101 | |
michael@0 | 102 | nsISimpleEnumerator getWindowEnumerator(); |
michael@0 | 103 | |
michael@0 | 104 | /** Return a newly created nsIPrompt implementation. |
michael@0 | 105 | @param aParent the parent window used for posing alerts. can be null. |
michael@0 | 106 | @return a new nsIPrompt object |
michael@0 | 107 | */ |
michael@0 | 108 | |
michael@0 | 109 | nsIPrompt getNewPrompter(in nsIDOMWindow aParent); |
michael@0 | 110 | |
michael@0 | 111 | /** Return a newly created nsIAuthPrompt implementation. |
michael@0 | 112 | @param aParent the parent window used for posing alerts. can be null. |
michael@0 | 113 | @return a new nsIAuthPrompt object |
michael@0 | 114 | */ |
michael@0 | 115 | |
michael@0 | 116 | nsIAuthPrompt getNewAuthPrompter(in nsIDOMWindow aParent); |
michael@0 | 117 | |
michael@0 | 118 | /** Set the window creator callback. It must be filled in by the app. |
michael@0 | 119 | openWindow will use it to create new windows. |
michael@0 | 120 | @param creator the callback. if null, the callback will be cleared |
michael@0 | 121 | and window creation capabilities lost. |
michael@0 | 122 | */ |
michael@0 | 123 | void setWindowCreator(in nsIWindowCreator creator); |
michael@0 | 124 | |
michael@0 | 125 | /** Returns true if a window creator callback has been set, false otherwise. |
michael@0 | 126 | */ |
michael@0 | 127 | boolean hasWindowCreator(); |
michael@0 | 128 | |
michael@0 | 129 | |
michael@0 | 130 | /** Retrieve the chrome window mapped to the given DOM window. Window |
michael@0 | 131 | Watcher keeps a list of all top-level DOM windows currently open, |
michael@0 | 132 | along with their corresponding chrome interfaces. Since DOM Windows |
michael@0 | 133 | lack a (public) means of retrieving their corresponding chrome, |
michael@0 | 134 | this method will do that. |
michael@0 | 135 | @param aWindow the DOM window whose chrome window the caller needs |
michael@0 | 136 | @return the corresponding chrome window |
michael@0 | 137 | */ |
michael@0 | 138 | nsIWebBrowserChrome getChromeForWindow(in nsIDOMWindow aWindow); |
michael@0 | 139 | |
michael@0 | 140 | /** |
michael@0 | 141 | Retrieve an existing window (or frame). |
michael@0 | 142 | @param aTargetName the window name |
michael@0 | 143 | @param aCurrentWindow a starting point in the window hierarchy to |
michael@0 | 144 | begin the search. If null, each toplevel window |
michael@0 | 145 | will be searched. |
michael@0 | 146 | |
michael@0 | 147 | Note: This method will search all open windows for any window or |
michael@0 | 148 | frame with the given window name. Make sure you understand the |
michael@0 | 149 | security implications of this before using this method! |
michael@0 | 150 | */ |
michael@0 | 151 | nsIDOMWindow getWindowByName(in wstring aTargetName, |
michael@0 | 152 | in nsIDOMWindow aCurrentWindow); |
michael@0 | 153 | |
michael@0 | 154 | /** The Watcher serves as a global storage facility for the current active |
michael@0 | 155 | (frontmost non-floating-palette-type) window, storing and returning |
michael@0 | 156 | it on demand. Users must keep this attribute current, including after |
michael@0 | 157 | the topmost window is closed. This attribute obviously can return null |
michael@0 | 158 | if no windows are open, but should otherwise always return a valid |
michael@0 | 159 | window. |
michael@0 | 160 | */ |
michael@0 | 161 | attribute nsIDOMWindow activeWindow; |
michael@0 | 162 | |
michael@0 | 163 | }; |
michael@0 | 164 | |
michael@0 | 165 | %{C++ |
michael@0 | 166 | #define NS_WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1" |
michael@0 | 167 | %} |