summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/static/windows.html
blob: e501b43d144762e79b0c39ebb6f7991527f30612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<div id="pageData-title" class="pageData">Windows</div>

<!-- BEGIN AUTHORED CONTENT -->
<p id="classSummary">
Use the <code>chrome.windows</code> module
to interact with browser windows.
You can use this module to
create, modify, and rearrange windows in the browser.
</p>

<h2 id="permissions">Permissions</h2>
<p>You must declare the <var>tabs</var> permission
(no, that isn't a typo -- the window and tabs modules interact so closely we
decided to just share one permission between them)
in your extension's manifest to use the windows API.</p>
<p>Example:</p>
<pre>{
  "name": "My extension that uses windows",
  "version": "0.1",
<b>  "permissions": [
    "tabs"
  ]</b>
}</pre>

<h2 id="current-window">The current window</h2>

<p>Many functions in the extension system
take an optional <var>windowId</var> parameter
which is documented to default to the "current window".

<p>The <em>current window</em> is the window that
contains the code that is currently executing.
It's important to realize that this can be
different from the topmost or focused window.

<p>For example, consider code running in a
<a href="toolstrip.html">toolstrip</a>, that
calls <a href="tabs.html#method-getSelected">chrome.tabs.getSelected</a>.
The current window is the window that contains the toolstrip that made
the call, no matter what the topmost window is.

<p>In the case of the <a href="background_pages.html">background page</a>,
the value of the current window falls back to the topmost window.

<!-- END AUTHORED CONTENT -->