1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5[ 6 { 7 "namespace": "windows", 8 "description": "Use the <code>chrome.windows</code> API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser.", 9 "compiler_options": { 10 "implemented_in": "chrome/browser/extensions/api/tabs/tabs_api.h" 11 }, 12 "types": [ 13 { 14 "id": "WindowType", 15 "type": "string", 16 "description": "The type of browser window this is. In some circumstances a window may not be assigned a <code>type</code> property; for example, when querying closed windows from the $(ref:sessions) API.", 17 "enum": [{ 18 "name": "normal", 19 "description": "A normal browser window." 20 }, { 21 "name": "popup", 22 "description": "A browser popup." 23 }, { 24 "name": "panel", 25 "description": "<i>Deprecated in this API.</i> A Chrome App panel-style window. Extensions can only see their own panel windows." 26 }, { 27 "name": "app", 28 "description": "<i>Deprecated in this API.</i> A Chrome App window. Extensions can only see their app own windows." 29 }, { 30 "name": "devtools", 31 "description": "A Developer Tools window." 32 }] 33 }, 34 { 35 "id": "WindowState", 36 "type": "string", 37 "description": "The state of this browser window. In some circumstances a window may not be assigned a <code>state</code> property; for example, when querying closed windows from the $(ref:sessions) API.", 38 // WARNING: These values are written to logs. New enum values can be 39 // added, but existing enums must never be renumbered or deleted and 40 // reused. If something needs to be removed, make sure to remove the 41 // "TabsApi.RequestedWindowState" histogram as it will be no longer 42 // valid, and make sure to mark it as obsolete in histograms.xml. 43 "enum": [{ 44 "name": "normal", 45 "description": "Normal window state (not minimized, maximized, or fullscreen)." 46 }, { 47 "name": "minimized", 48 "description": "Minimized window state." 49 }, { 50 "name": "maximized", 51 "description": "Maximized window state." 52 }, { 53 "name": "fullscreen", 54 "description": "Fullscreen window state." 55 }, { 56 "name": "locked-fullscreen", 57 "nodoc": true, 58 "description": "Locked fullscreen window state. This fullscreen state cannot be exited by user action and is available only to allowlisted extensions on Chrome OS." 59 }] 60 }, 61 { 62 "id": "Window", 63 "type": "object", 64 "properties": { 65 "id": {"type": "integer", "optional": true, "minimum": 0, "description": "The ID of the window. Window IDs are unique within a browser session. In some circumstances a window may not be assigned an <code>ID</code> property; for example, when querying windows using the $(ref:sessions) API, in which case a session ID may be present."}, 66 "focused": {"type": "boolean", "description": "Whether the window is currently the focused window."}, 67 "top": {"type": "integer", "optional": true, "description": "The offset of the window from the top edge of the screen in pixels. In some circumstances a window may not be assigned a <code>top</code> property; for example, when querying closed windows from the $(ref:sessions) API."}, 68 "left": {"type": "integer", "optional": true, "description": "The offset of the window from the left edge of the screen in pixels. In some circumstances a window may not be assigned a <code>left</code> property; for example, when querying closed windows from the $(ref:sessions) API."}, 69 "width": {"type": "integer", "optional": true, "description": "The width of the window, including the frame, in pixels. In some circumstances a window may not be assigned a <code>width</code> property; for example, when querying closed windows from the $(ref:sessions) API."}, 70 "height": {"type": "integer", "optional": true, "description": "The height of the window, including the frame, in pixels. In some circumstances a window may not be assigned a <code>height</code> property; for example, when querying closed windows from the $(ref:sessions) API."}, 71 "tabs": {"type": "array", "items": { "$ref": "tabs.Tab" }, "optional": true, "description": "Array of $(ref:tabs.Tab) objects representing the current tabs in the window."}, 72 "incognito": {"type": "boolean", "description": "Whether the window is incognito."}, 73 "type": { 74 "$ref": "WindowType", 75 "optional": true, 76 "description": "The type of browser window this is." 77 }, 78 "state": { 79 "$ref": "WindowState", 80 "optional": true, 81 "description": "The state of this browser window." 82 }, 83 "alwaysOnTop": {"type": "boolean", "description": "Whether the window is set to be always on top."}, 84 "sessionId": {"type": "string", "optional": true, "description": "The session ID used to uniquely identify a window, obtained from the $(ref:sessions) API."} 85 } 86 }, 87 { 88 "id": "CreateType", 89 "type": "string", 90 "description": "Specifies what type of browser window to create. 'panel' is deprecated and is available only to existing whitelisted extensions on Chrome OS.", 91 "enum": ["normal", "popup", "panel"] 92 }, 93 { 94 "id": "QueryOptions", 95 "type": "object", 96 "properties": { 97 "populate": {"type": "boolean", "optional": true, "description": "If true, the $(ref:windows.Window) object has a <var>tabs</var> property that contains a list of the $(ref:tabs.Tab) objects. The <code>Tab</code> objects only contain the <code>url</code>, <code>pendingUrl</code>, <code>title</code>, and <code>favIconUrl</code> properties if the extension's manifest file includes the <code>\"tabs\"</code> permission." }, 98 "windowTypes": {"type": "array", "items": { "$ref": "WindowType" }, "optional": true, "description": "If set, the $(ref:windows.Window) returned is filtered based on its type. If unset, the default filter is set to <code>['normal', 'popup']</code>."} 99 } 100 } 101 ], 102 "properties": { 103 "WINDOW_ID_NONE": { 104 "value": -1, 105 "description": "The windowId value that represents the absence of a chrome browser window." 106 }, 107 "WINDOW_ID_CURRENT": { 108 "value": -2, 109 "description": "The windowId value that represents the <a href='windows#current-window'>current window</a>." 110 } 111 }, 112 "functions": [ 113 { 114 "name": "get", 115 "type": "function", 116 "description": "Gets details about a window.", 117 "parameters": [ 118 {"type": "integer", "name": "windowId", "minimum": -2}, 119 { 120 "name": "queryOptions", 121 "$ref": "QueryOptions", 122 "optional": true 123 } 124 ], 125 "returns_async": { 126 "name": "callback", 127 "parameters": [ 128 { 129 "name": "window", "$ref": "Window" 130 } 131 ] 132 } 133 }, 134 { 135 "name": "getCurrent", 136 "type": "function", 137 "description": "Gets the <a href='#current-window'>current window</a>.", 138 "parameters": [ 139 { 140 "name": "queryOptions", 141 "$ref": "QueryOptions", 142 "optional": true 143 } 144 ], 145 "returns_async": { 146 "name": "callback", 147 "parameters": [ 148 { 149 "name": "window", "$ref": "Window" 150 } 151 ] 152 } 153 }, 154 { 155 "name": "getLastFocused", 156 "type": "function", 157 "description": "Gets the window that was most recently focused — typically the window 'on top'.", 158 "parameters": [ 159 { 160 "name": "queryOptions", 161 "$ref": "QueryOptions", 162 "optional": true 163 } 164 ], 165 "returns_async": { 166 "name": "callback", 167 "parameters": [ 168 { 169 "name": "window", "$ref": "Window" 170 } 171 ] 172 } 173 }, 174 { 175 "name": "getAll", 176 "type": "function", 177 "description": "Gets all windows.", 178 "parameters": [ 179 { 180 "name": "queryOptions", 181 "$ref": "QueryOptions", 182 "optional": true 183 } 184 ], 185 "returns_async": { 186 "name": "callback", 187 "parameters": [ 188 { 189 "name": "windows", "type": "array", "items": { "$ref": "Window" } 190 } 191 ] 192 } 193 }, 194 { 195 "name": "create", 196 "type": "function", 197 "description": "Creates (opens) a new browser window with any optional sizing, position, or default URL provided.", 198 "parameters": [ 199 { 200 "type": "object", 201 "name": "createData", 202 "properties": { 203 "url": { 204 "description": "A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme, e.g., 'http://www.google.com', not 'www.google.com'. Non-fully-qualified URLs are considered relative within the extension. Defaults to the New Tab Page.", 205 "optional": true, 206 "choices": [ 207 {"type": "string"}, 208 {"type": "array", "items": {"type": "string"}} 209 ] 210 }, 211 "tabId": {"type": "integer", "minimum": 0, "optional": true, "description": "The ID of the tab to add to the new window."}, 212 "left": {"type": "integer", "optional": true, "description": "The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels."}, 213 "top": {"type": "integer", "optional": true, "description": "The number of pixels to position the new window from the top edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels."}, 214 "width": {"type": "integer", "minimum": 0, "optional": true, "description": "The width in pixels of the new window, including the frame. If not specified, defaults to a natural width."}, 215 "height": {"type": "integer", "minimum": 0, "optional": true, "description": "The height in pixels of the new window, including the frame. If not specified, defaults to a natural height."}, 216 "focused": {"type": "boolean", "optional": true, "description": "If <code>true</code>, opens an active window. If <code>false</code>, opens an inactive window."}, 217 "incognito": {"type": "boolean", "optional": true, "description": "Whether the new window should be an incognito window."}, 218 "type": { 219 "$ref": "CreateType", 220 "optional": true, 221 "description": "Specifies what type of browser window to create." 222 }, 223 "state": { 224 "$ref": "WindowState", 225 "optional": true, 226 "description": "The initial state of the window. The <code>minimized</code>, <code>maximized</code>, and <code>fullscreen</code> states cannot be combined with <code>left</code>, <code>top</code>, <code>width</code>, or <code>height</code>." 227 }, 228 "setSelfAsOpener": { 229 "type": "boolean", 230 "optional": true, 231 "description": "If <code>true</code>, the newly-created window's 'window.opener' is set to the caller and is in the same <a href=\"https://www.w3.org/TR/html51/browsers.html#unit-of-related-browsing-contexts\">unit of related browsing contexts</a> as the caller." 232 } 233 }, 234 "optional": true 235 } 236 ], 237 "returns_async": { 238 "name": "callback", 239 "optional": true, 240 "parameters": [ 241 { 242 "name": "window", "$ref": "Window", "description": "Contains details about the created window.", 243 "optional": true 244 } 245 ] 246 } 247 }, 248 { 249 "name": "update", 250 "type": "function", 251 "description": "Updates the properties of a window. Specify only the properties that to be changed; unspecified properties are unchanged.", 252 "parameters": [ 253 {"type": "integer", "name": "windowId", "minimum": -2}, 254 { 255 "type": "object", 256 "name": "updateInfo", 257 "properties": { 258 "left": {"type": "integer", "optional": true, "description": "The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels."}, 259 "top": {"type": "integer", "optional": true, "description": "The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels."}, 260 "width": {"type": "integer", "minimum": 0, "optional": true, "description": "The width to resize the window to in pixels. This value is ignored for panels."}, 261 "height": {"type": "integer", "minimum": 0, "optional": true, "description": "The height to resize the window to in pixels. This value is ignored for panels."}, 262 "focused": {"type": "boolean", "optional": true, "description": "If <code>true</code>, brings the window to the front; cannot be combined with the state 'minimized'. If <code>false</code>, brings the next window in the z-order to the front; cannot be combined with the state 'fullscreen' or 'maximized'."}, 263 "drawAttention": {"type": "boolean", "optional": true, "description": "If <code>true</code>, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to <code>false</code> to cancel a previous <code>drawAttention</code> request."}, 264 "state": { 265 "$ref": "WindowState", 266 "optional": true, 267 "description": "The new state of the window. The 'minimized', 'maximized', and 'fullscreen' states cannot be combined with 'left', 'top', 'width', or 'height'." 268 } 269 } 270 } 271 ], 272 "returns_async": { 273 "name": "callback", 274 "optional": true, 275 "parameters": [ 276 { 277 "name": "window", "$ref": "Window" 278 } 279 ] 280 } 281 }, 282 { 283 "name": "remove", 284 "type": "function", 285 "description": "Removes (closes) a window and all the tabs inside it.", 286 "parameters": [ 287 {"type": "integer", "name": "windowId", "minimum": 0} 288 ], 289 "returns_async": {"name": "callback", "optional": true, "parameters": []} 290 } 291 ], 292 "events": [ 293 { 294 "name": "onCreated", 295 "type": "function", 296 "description": "Fired when a window is created.", 297 "filters": [ 298 { 299 "name": "windowTypes", 300 "type": "array", 301 "items": { "$ref": "WindowType" }, 302 "description": "Conditions that the window's type being created must satisfy. By default it satisfies <code>['normal', 'popup']</code>." 303 } 304 ], 305 "parameters": [ 306 { 307 "$ref": "Window", 308 "name": "window", 309 "description": "Details of the created window." 310 } 311 ] 312 }, 313 { 314 "name": "onRemoved", 315 "type": "function", 316 "description": "Fired when a window is removed (closed).", 317 "filters": [ 318 { 319 "name": "windowTypes", 320 "type": "array", 321 "items": { "$ref": "WindowType" }, 322 "description": "Conditions that the window's type being removed must satisfy. By default it satisfies <code>['normal', 'popup']</code>." 323 } 324 ], 325 "parameters": [ 326 {"type": "integer", "name": "windowId", "minimum": 0, "description": "ID of the removed window."} 327 ] 328 }, 329 { 330 "name": "onFocusChanged", 331 "type": "function", 332 "description": "Fired when the currently focused window changes. Returns <code>chrome.windows.WINDOW_ID_NONE</code> if all Chrome windows have lost focus. <b>Note:</b> On some Linux window managers, <code>WINDOW_ID_NONE</code> is always sent immediately preceding a switch from one Chrome window to another.", 333 "filters": [ 334 { 335 "name": "windowTypes", 336 "type": "array", 337 "items": { "$ref": "WindowType" }, 338 "description": "Conditions that the window's type being removed must satisfy. By default it satisfies <code>['normal', 'popup']</code>." 339 } 340 ], 341 "parameters": [ 342 {"type": "integer", "name": "windowId", "minimum": -1, "description": "ID of the newly-focused window."} 343 ] 344 }, 345 { 346 "name": "onBoundsChanged", 347 "type": "function", 348 "description": "Fired when a window has been resized; this event is only dispatched when the new bounds are committed, and not for in-progress changes.", 349 "parameters": [ 350 { 351 "$ref": "Window", 352 "name": "window", 353 "description": "Details of the window. The tabs will not be populated for the window." 354 } 355 ] 356 } 357 ] 358 } 359] 360