| <div id="pageData-name" 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> |
| |
| <img src="images/windows.png" |
| width="256" height="76" alt="Two windows, each with one tab" /> |
| |
| <h2 id="manifest">Manifest</h2> |
| <p> |
| To use the windows API, |
| you must declare the "tabs" permission |
| in <a href="manifest.html">manifest.json</a>. |
| (No, that isn't a typo — |
| the window and tabs modules interact so closely we |
| decided to just share one permission between them.) |
| 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 |
| <a href="tabs.html#method-getSelected">chrome.tabs.getSelected</a>. |
| 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="background_pages.html">background 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> |
| 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> |
| |
| <!-- END AUTHORED CONTENT --> |