override.html revision 513209b27ff55e2841eac0e4120199c23acce758
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>
74The following screenshots show the default New Tab page
75next to a custom New Tab page.
76</p>
77
78<table id="pics">
79  <tr>
80    <td> <b>The default New Tab page</b> </td>
81    <td> <b>An alternative New Tab page</b> </td>
82  </tr>
83  <tr>
84    <td>
85      <img src="images/ntp-default.png"
86        alt="default New Tab page"
87        width="200" height="173">
88    </td>
89    <td>
90      <img src="images/ntp-blank.png"
91        alt="a blank New Tab page"
92        width="200" height="173">
93    </td>
94  </tr>
95</table>
96
97<h2 id="manifest">Manifest</h2>
98
99<p>
100Register an override page in the
101<a href="manifest.html">extension manifest</a> like this:
102</p>
103
104<pre>{
105  "name": "My extension",
106  ...
107
108<b>  "chrome_url_overrides" : {
109    "<em>pageToOverride</em>": "<em>myPage.html</em>"
110  }</b>,
111  ...
112}</pre>
113
114<p>
115For <code><em>pageToOverride</em></code>, substitute one of the following:
116</p>
117
118<ul>
119  <li> <code>bookmarks</code>
120  <li> <code>history</code>
121  <li> <code>newtab</code>
122</ul>
123
124
125<h2 id="tips">Tips</h2>
126
127<p>
128For an effective override page, follow these guidelines:
129</p>
130
131<ul>
132  <li>
133    <p>
134    <b>Make your page quick and small.</b> <br />
135    Users expect built-in browser pages to open instantly.
136    Avoid doing things that might take a long time.
137    For example, avoid synchronous fetches of network or database resources.
138    </p>
139  </li>
140  <li>
141    <p>
142    <b>Include a title in your page.</b> <br />
143    Otherwise people might see the URL of the page,
144    which could be confusing.
145    Here's an example of specifying the title:
146    <code>&lt;title>New&nbsp;Tab&lt;/title></code>
147    </p>
148  </li>
149  <li>
150    <p>
151    <b>Don't rely on the page having the keyboard focus.</b> <br />
152    The address bar always gets the focus first
153    when the user creates a new tab.
154    </p>
155  </li>
156  <li>
157    <p>
158    <b>Don't try to emulate the default New Tab page.</b> <br />
159    The APIs necessary to create
160    a slightly modified version of the default New Tab page &mdash;
161    with top pages,
162    recently closed pages,
163    tips,
164    a theme background image,
165    and so on &mdash;
166    don't exist yet.
167    Until they do,
168    you're better off trying to make something completely different.
169    </p>
170  </li>
171</ul>
172
173<h2 id="examples"> Examples </h2>
174
175<p>
176You can find simple examples of defining override pages in the
177<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/override/">examples/api/override</a>
178directory.
179For other examples and for help in viewing the source code, see
180<a href="samples.html">Samples</a>.
181</p>
182
183
184<!-- [PENDING: Maybe have a gallery of NTPs?] -->
185