nsIBrowserDOMWindow.idl (7614B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "nsISupports.idl" 7 8 interface mozIDOMWindowProxy; 9 interface nsIDOMWindow; 10 interface nsIURI; 11 interface nsIPrincipal; 12 interface nsIPolicyContainer; 13 interface nsIReferrerInfo; 14 interface nsIOpenWindowInfo; 15 webidl BrowsingContext; 16 webidl Element; 17 18 [scriptable, uuid(e774db14-79ac-4156-a7a3-aa3fd0a22c10)] 19 interface nsIOpenURIInFrameParams : nsISupports 20 { 21 readonly attribute nsIOpenWindowInfo openWindowInfo; 22 23 attribute nsIReferrerInfo referrerInfo; 24 readonly attribute boolean isPrivate; 25 attribute nsIPrincipal triggeringPrincipal; 26 attribute nsIPolicyContainer policyContainer; 27 28 // The browser or frame element in the parent process which holds the 29 // opener window in the content process. May be null. 30 readonly attribute Element openerBrowser; 31 32 [implicit_jscontext] 33 readonly attribute jsval openerOriginAttributes; 34 }; 35 36 /** 37 * The C++ source has access to the browser script source through 38 * nsIBrowserDOMWindow. It is intended to be attached to the chrome DOMWindow 39 * of a toplevel browser window (a XUL window). A DOMWindow that does not 40 * happen to be a browser chrome window will simply have no access to any such 41 * interface. 42 */ 43 [scriptable, uuid(2a9bb880-5d73-40f3-8152-c60c8d137a14)] 44 interface nsIBrowserDOMWindow : nsISupports 45 { 46 /** 47 * Values for createContentWindow's and openURI's aWhere parameter. 48 */ 49 /** 50 * Do whatever the default is based on application state, user preferences, 51 * and the value of the aContext parameter to openURI. 52 */ 53 const short OPEN_DEFAULTWINDOW = 0; 54 /** 55 * Open in the "current window". If aOpener is provided, this should be the 56 * top window in aOpener's window hierarchy, but exact behavior is 57 * application-dependent. If aOpener is not provided, it's up to the 58 * application to decide what constitutes a "current window". 59 */ 60 const short OPEN_CURRENTWINDOW = 1; 61 /** 62 * Open in a new window. 63 */ 64 const short OPEN_NEWWINDOW = 2; 65 /** 66 * Open in a new content tab in the toplevel browser window corresponding to 67 * this nsIBrowserDOMWindow. 68 * Use browser.tabs.loadDivertedInBackground pref to choose whether to open 69 * in background tab or foreground tab. 70 */ 71 const short OPEN_NEWTAB = 3; 72 /** 73 * Open in a hidden browser. Used for printing. 74 */ 75 const short OPEN_PRINT_BROWSER = 4; 76 /** 77 * Open in a new background content tab in the toplevel browser window 78 * corresponding to this nsIBrowserDOMWindow. 79 */ 80 const short OPEN_NEWTAB_BACKGROUND = 5; 81 /** 82 * Open in a new foreground content tab in the toplevel browser window 83 * corresponding to this nsIBrowserDOMWindow. 84 */ 85 const short OPEN_NEWTAB_FOREGROUND = 6; 86 /** 87 * Open in a new content tab in the toplevel browser window 88 * corresponding to this nsIBrowserDOMWindow. The new content 89 * will be created immediately after the active tab in that window. 90 */ 91 const short OPEN_NEWTAB_AFTER_CURRENT = 7; 92 93 /** 94 * Values for createContentWindow's and openURI's aFlags parameter. 95 * This is a bitflags field. 96 * 97 * The 0x1 bit decides the behavior of OPEN_DEFAULTWINDOW, and the 0x4 bit 98 * controls whether or not to set the window.opener property on the newly 99 * opened window. 100 * 101 * NOTE: The 0x2 bit is ignored for backwards compatibility with addons, as 102 * OPEN_NEW used to have the value 2. The values 0 and 2 are treated 103 * the same way internally. 104 */ 105 /** 106 * Internal open new window. 107 */ 108 const long OPEN_NEW = 0x0; 109 /** 110 * External link (load request from another application, xremote, etc). 111 */ 112 const long OPEN_EXTERNAL = 0x1; 113 114 /** 115 * Don't set the window.opener property on the window which is being opened. 116 */ 117 const long OPEN_NO_OPENER = 0x4; 118 119 /** 120 * Don't set the referrer on the navigation inside the window which is 121 * being opened. 122 */ 123 const long OPEN_NO_REFERRER = 0x8; 124 125 /** 126 * Create the content window for the given URI. 127 128 * @param aURI the URI to be opened in the window (can be null). 129 * @param aWhere see possible values described above. 130 * @param aOpenWindowInfo info about the creation (can be null). 131 * @param aFlags flags which control the behavior of the load. The 132 * OPEN_EXTERNAL/OPEN_NEW flag is only used when 133 * aWhere == OPEN_DEFAULTWINDOW. 134 * @param aTriggeringPrincipal the principal that would trigger the potential 135 * load of aURI. 136 * @param aPolicyContainer the policyContainer to use (if any) for the new window. 137 * @return the window into which the URI would have been opened. 138 */ 139 BrowsingContext 140 createContentWindow(in nsIURI aURI, in nsIOpenWindowInfo aOpenWindowInfo, 141 in short aWhere, in long aFlags, 142 in nsIPrincipal aTriggeringPrincipal, 143 [optional] in nsIPolicyContainer aPolicyContainer); 144 145 /** 146 * As above, but return the nsFrameLoaderOwner for the new window. Value is 147 * returned as Element, QI'd back to nsFrameLoaderOwner as needed. 148 * 149 * Additional Parameters: 150 * @param aName The name to give the window opened in the new tab. 151 * @return The frame element for the newly opened window. 152 */ 153 Element 154 createContentWindowInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params, 155 in short aWhere, in long aFlags, 156 in AString aName); 157 158 /** 159 * Load a URI. 160 * @param aURI the URI to open. null is not allowed. To create the window 161 * without loading the URI, use createContentWindow instead. 162 * @param aWhere see possible values described above. 163 * @param aOpenWindowInfo info about the open (can be null). 164 * @param aFlags flags which control the behavior of the load. The 165 * OPEN_EXTERNAL/OPEN_NEW flag is only used when 166 * aWhere == OPEN_DEFAULTWINDOW. 167 * @param aTriggeringPrincipal the principal that triggered the load of aURI. 168 * @param aPolicyContainer the policyContainer to be applied to the new load. 169 * @return the window into which the URI was opened. 170 */ 171 BrowsingContext 172 openURI(in nsIURI aURI, in nsIOpenWindowInfo aOpenWindowInfo, 173 in short aWhere, in long aFlags, in nsIPrincipal aTriggeringPrincipal, 174 [optional] in nsIPolicyContainer aPolicyContainer); 175 176 /** 177 * As above, but return the nsFrameLoaderOwner for the new window. Value is 178 * returned as Element, QI'd back to nsFrameLoaderOwner as needed. 179 * 180 * Additional Parameters: 181 * @param aName The name to give the window opened in the new tab. 182 * @return The frame element for the newly opened window. 183 // XXXbz is this the right API? 184 // See bug 537428 185 */ 186 Element 187 openURIInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params, 188 in short aWhere, in long aFlags, 189 in AString aName); 190 191 /** 192 * This function is responsible for calling 193 * nsIDocumentViewer::PermitUnload on each frame in the window. It 194 * returns true if closing the window is allowed. See canClose() in 195 * BrowserUtils.sys.mjs for a simple implementation of this method. 196 */ 197 boolean canClose(); 198 199 /** 200 * The number browser tabs in the window. This number currently includes 201 * lazy tabs, though for most uses it probably should not. 202 */ 203 readonly attribute unsigned long tabCount; 204 };