blob: 733b113fc546c7af63bcc1b87439f033d68ae51f [file] [log] [blame]
<h2 id="manifest">Manifest</h2>
<p>
When requested, a <code>$ref:windows.Window</code>
will contain an array of <code>$ref:tabs.Tab</code> objects.
You must declare the <code>"tabs"</code> permission in your
<a href="manifest.html">manifest</a> if you require access to the
<code>$ref:[tabs.Tab.url url]</code>,
<code>$ref:[tabs.Tab.title title]</code>, or
<code>$ref:[tabs.Tab.favIconUrl favIconUrl]</code> properties of
<code>$ref:tabs.Tab</code>.
For example:
</p>
<pre>{
"name": "My extension",
...
<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 defaults to the current window.
</p>
<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>
<p>For example, say an extension
creates a few tabs or windows from a single HTML file,
and that the HTML file
contains a call to
$ref:tabs.query.
The current window is the window that contains the page that made
the call, no matter what the topmost window is.
</p>
<p>In the case of the <a href="event_pages.html">event page</a>,
the value of the current window falls back to the last active window. Under some
circumstances, there may be no current window for background pages.
</p>
<h2 id="examples"> Examples </h2>
<p>
<img src="{{static}}/images/windows.png"
width="561" height="224" alt="Two windows, each with one tab" />
<br>
You can find simple examples of using the windows module in the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/windows/">examples/api/windows</a>
directory.
Another example is in the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html?content-type=text/plain">tabs_api.html</a> file
of the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/inspector/">inspector</a>
example.
For other examples and for help in viewing the source code, see
<a href="samples.html">Samples</a>.
</p>