1 <img src="{{static}}/images/windows.png" 2 width="256" height="76" alt="Two windows, each with one tab" /> 3 4 <h2 id="manifest">Manifest</h2> 5 <p> 6 To use the windows API, 7 you must declare the "tabs" permission 8 in <a href="manifest.html">manifest.json</a>. 9 (No, that isn't a typo — 10 the window and tabs modules interact so closely we 11 decided to just share one permission between them.) 12 For example: 13 </p> 14 15 <pre>{ 16 "name": "My extension", 17 ... 18 <b>"permissions": ["tabs"]</b>, 19 ... 20 }</pre> 21 22 <h2 id="current-window">The current window</h2> 23 24 <p>Many functions in the extension system 25 take an optional <var>windowId</var> parameter, 26 which defaults to the current window. 27 </p> 28 29 <p>The <em>current window</em> is the window that 30 contains the code that is currently executing. 31 It's important to realize that this can be 32 different from the topmost or focused window. 33 </p> 34 35 <p>For example, say an extension 36 creates a few tabs or windows from a single HTML file, 37 and that the HTML file 38 contains a call to 39 $ref:tabs.query. 40 The current window is the window that contains the page that made 41 the call, no matter what the topmost window is. 42 </p> 43 44 <p>In the case of the <a href="event_pages.html">event page</a>, 45 the value of the current window falls back to the last active window. Under some 46 circumstances, there may be no current window for background pages. 47 </p> 48 49 <h2 id="examples"> Examples </h2> 50 51 <p> 52 You can find simple examples of using the windows module in the 53 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/windows/">examples/api/windows</a> 54 directory. 55 Another example is in the 56 <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 57 of the 58 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/inspector/">inspector</a> 59 example. 60 For other examples and for help in viewing the source code, see 61 <a href="samples.html">Samples</a>. 62 </p> 63