OLD | NEW |
(Empty) | |
| 1 <h1 class="page_title">Devtools Panels</h1><p id="classSummary"> |
| 2 Use the <code>chrome.devtools.panels</code> module to integrate |
| 3 your extension into Developer Tools window UI: create your own panels, access |
| 4 existing panels, and add sidebars. |
| 5 </p><p> |
| 6 See <a href="devtools.html">DevTools APIs summary</a> for |
| 7 general introduction to using Developer Tools APIs. |
| 8 </p> |
| 9 <h2>Overview</h2> |
| 10 <p> |
| 11 Each extension panel and sidebar is displayed as a separate HTML page. All |
| 12 extension pages displayed in the Developer Tools window have access to all |
| 13 modules in <code>chrome.devtools</code> API, as well as to |
| 14 <a href="extension.html">chrome.extension</a> API. Other extension APIs are not |
| 15 available to the pages within Developer Tools window, but you may invoke them |
| 16 by sending a request to the background page of your extension, similarly to how |
| 17 it's done in the <a href="overview.html#contentScripts">content scripts</a>. |
| 18 </p><p> |
| 19 You can use the <code><a href="#method-setOpenResourceHandler" |
| 20 >setOpenResourceHandler()</a></code> method to install a |
| 21 callback function that handles user requests to open a resource (typically, |
| 22 a click on a resource link in the Developer Tools window). At most one of the |
| 23 installed handlers gets called; users can specify (using the Developer Tools |
| 24 Settings dialog) either the default behavior or an extension to handle resource |
| 25 open requests. If an extension calls <code>setOpenResourceHandler()</code> |
| 26 multiple times, only the last handler is retained. |
| 27 </p> |
| 28 <h2 id="overview-examples">Examples</h2> |
| 29 <p>The following code adds a panel contained in <code>Panel.html</code>, |
| 30 represented by <code>FontPicker.png</code> on the Developer Tools toolbar |
| 31 and labeled as <em>Font Picker</em>:</p> |
| 32 <pre> |
| 33 chrome.devtools.panels.create("Font Picker", |
| 34 "FontPicker.png", |
| 35 "Panel.html" |
| 36 function(panel) { ... }); |
| 37 </pre> |
| 38 <p>The following code adds a sidebar pane contained in |
| 39 <code>Sidebar.html</code> and titled <em>Font Properties</em> to the Elements |
| 40 panel, then sets its height to <code>8ex</code>: |
| 41 <pre> |
| 42 chrome.devtools.panels.elements.createSidebarPane("Font Properties", |
| 43 function(sidebar) { |
| 44 sidebar.setPage("Sidebar.html"); |
| 45 sidebar.setHeight("8ex"); |
| 46 }); |
| 47 </pre> |
| 48 <p> |
| 49 This screenshot demonstrates the effect the above examples would have on |
| 50 Developer Tools window: |
| 51 <img src="{{static}}/images/devtools-panels.png" |
| 52 style="margin-left: 20px" |
| 53 width="686" height="289" |
| 54 alt="Extension icon panel on DevTools toolbar" /> |
| 55 </p> |
| 56 <p> |
| 57 You can find examples that use this API in |
| 58 <a href="samples.html#Chrome Query">Samples</a>. |
| 59 </p> |
OLD | NEW |