override.html revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
1<style> 2#pics { 3 margin:2em 1em 1.5em; 4} 5 6#pics td { 7 text-align:center; 8 width:50%!important; 9 border:none; 10 padding:0 1em; 11 font-size:90%; 12} 13 14#pics img { 15 width:188; 16 height:246; 17 border:none; 18} 19</style> 20 21<div id="pageData-title" class="pageData">Override Pages</div> 22<div id="pageData-showTOC" class="pageData">true</div> 23 24<p> 25Override pages are a way to substitute an HTML file from your extension 26for a page that Google Chrome normally provides. 27In addition to HTML, 28an override page usually has CSS and JavaScript code. 29</p> 30 31<p> 32An extension can replace any one of the following pages: 33<ul> 34 <li> <b>Bookmark Manager:</b> 35 The page that appears when the user chooses 36 the Bookmark Manager menu item 37 from the wrench menu or, on Mac, 38 the Bookmark Manager item from the Bookmarks menu. 39 You can also get to this page by entering the URL 40 <b>chrome://bookmarks</b>. 41 </li> 42 43 <li> <b>History:</b> 44 The page that appears when the user 45 chooses the History menu item 46 from the Tools (wrench) menu or, on Mac, 47 the Show Full History item from the History menu. 48 You can also get to this page by entering the URL 49 <b>chrome://history</b>. 50 </li> 51 52 <li> <b>New Tab:</b> 53 The page that appears when the user creates a new tab or window. 54 You can also get to this page by entering the URL 55 <b>chrome://newtab</b>. 56 </li> 57</ul> 58</p> 59 60<p class="note"> 61<b>Note:</b> 62A single extension can override 63only one page. 64</p> 65 66<p class="note"> 67<b>Note:</b> 68If you want to override the page in incognito windows as well, make sure to 69specify "spanning" mode for the <a href="manifest.html#incognito">incognito</a> 70manifest property. 71</p> 72 73<p class="note"> 74<b>Note:</b> 75You cannot override the New Tab page in incognito windows. 76</p> 77 78<p> 79The following screenshots show the default New Tab page 80next to a custom New Tab page. 81</p> 82 83<table id="pics"> 84 <tr> 85 <td> <b>The default New Tab page</b> </td> 86 <td> <b>An alternative New Tab page</b> </td> 87 </tr> 88 <tr> 89 <td> 90 <img src="images/ntp-default.png" 91 alt="default New Tab page" 92 width="200" height="173"> 93 </td> 94 <td> 95 <img src="images/ntp-blank.png" 96 alt="a blank New Tab page" 97 width="200" height="173"> 98 </td> 99 </tr> 100</table> 101 102<h2 id="manifest">Manifest</h2> 103 104<p> 105Register an override page in the 106<a href="manifest.html">extension manifest</a> like this: 107</p> 108 109<pre>{ 110 "name": "My extension", 111 ... 112 113<b> "chrome_url_overrides" : { 114 "<em>pageToOverride</em>": "<em>myPage.html</em>" 115 }</b>, 116 ... 117}</pre> 118 119<p> 120For <code><em>pageToOverride</em></code>, substitute one of the following: 121</p> 122 123<ul> 124 <li> <code>bookmarks</code> 125 <li> <code>history</code> 126 <li> <code>newtab</code> 127</ul> 128 129 130<h2 id="tips">Tips</h2> 131 132<p> 133For an effective override page, follow these guidelines: 134</p> 135 136<ul> 137 <li> 138 <p> 139 <b>Make your page quick and small.</b> <br /> 140 Users expect built-in browser pages to open instantly. 141 Avoid doing things that might take a long time. 142 For example, avoid synchronous fetches of network or database resources. 143 </p> 144 </li> 145 <li> 146 <p> 147 <b>Include a title in your page.</b> <br /> 148 Otherwise people might see the URL of the page, 149 which could be confusing. 150 Here's an example of specifying the title: 151 <code><title>New Tab</title></code> 152 </p> 153 </li> 154 <li> 155 <p> 156 <b>Don't rely on the page having the keyboard focus.</b> <br /> 157 The address bar always gets the focus first 158 when the user creates a new tab. 159 </p> 160 </li> 161 <li> 162 <p> 163 <b>Don't try to emulate the default New Tab page.</b> <br /> 164 The APIs necessary to create 165 a slightly modified version of the default New Tab page — 166 with top pages, 167 recently closed pages, 168 tips, 169 a theme background image, 170 and so on — 171 don't exist yet. 172 Until they do, 173 you're better off trying to make something completely different. 174 </p> 175 </li> 176</ul> 177 178<h2 id="examples"> Examples </h2> 179 180<p> 181You can find simple examples of defining override pages in the 182<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/override/">examples/api/override</a> 183directory. 184For other examples and for help in viewing the source code, see 185<a href="samples.html">Samples</a>. 186</p> 187 188 189<!-- [PENDING: Maybe have a gallery of NTPs?] --> 190