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