| <div id="pageData-name" class="pageData">Override Pages</div> |
| <div id="pageData-showTOC" class="pageData">true</div> |
| |
| <style> |
| #pics { |
| margin:2em 1em 1.5em; |
| } |
| |
| #pics td { |
| text-align:center; |
| width:50%!important; |
| border:none; |
| padding:0 1em; |
| font-size:90%; |
| } |
| |
| #pics img { |
| width:188; |
| height:246; |
| border:none; |
| } |
| </style> |
| |
| <p> |
| Override pages are a way to substitute an HTML file from your extension |
| for a page that Google Chrome normally provides. |
| In addition to HTML, |
| an override page usually has CSS and JavaScript code. |
| </p> |
| |
| <p> |
| An extension can replace any one of the following pages: |
| <ul> |
| <li> <b>Bookmark Manager:</b> |
| The page that appears when the user chooses |
| the Bookmark Manager menu item |
| from the wrench menu or, on Mac, |
| the Bookmark Manager item from the Bookmarks menu. |
| You can also get to this page by entering the URL |
| <b>chrome://bookmarks</b>. |
| </li> |
| |
| <li> <b>History:</b> |
| The page that appears when the user |
| chooses the History menu item |
| from the Tools (wrench) menu or, on Mac, |
| the Show Full History item from the History menu. |
| You can also get to this page by entering the URL |
| <b>chrome://history</b>. |
| </li> |
| |
| <li> <b>New Tab:</b> |
| The page that appears when the user creates a new tab or window. |
| You can also get to this page by entering the URL |
| <b>chrome://newtab</b>. |
| </li> |
| </ul> |
| </p> |
| |
| <p class="note"> |
| <b>Note:</b> |
| A single extension can override |
| <b>only one page</b>. |
| For example, an extension can't override both |
| the Bookmark Manager and History pages. |
| </p> |
| |
| <p> |
| Incognito windows are treated specially. |
| New Tab pages cannot be overridden in incognito windows. |
| Other override pages work in incognito windows |
| as long as the |
| <a href="manifest.html#incognito">incognito</a> |
| manifest property is set to "spanning" |
| (which is the default value for extensions |
| but not for packaged apps). |
| See <a href="overview.html#incognito">Saving data and incognito mode</a> |
| in the Overview for more details on how you should treat |
| incognito windows. |
| </p> |
| |
| <p> |
| The following screenshots show the default New Tab page |
| next to a custom New Tab page. |
| </p> |
| |
| <table id="pics"> |
| <tr> |
| <td> <b>The default New Tab page</b> </td> |
| <td> <b>An alternative New Tab page</b> </td> |
| </tr> |
| <tr> |
| <td> |
| <img src="images/ntp-default.png" |
| alt="default New Tab page" |
| width="200" height="173"> |
| </td> |
| <td> |
| <img src="images/ntp-blank.png" |
| alt="a blank New Tab page" |
| width="200" height="173"> |
| </td> |
| </tr> |
| </table> |
| |
| <h2 id="manifest">Manifest</h2> |
| |
| <p> |
| Register an override page in the |
| <a href="manifest.html">extension manifest</a> like this: |
| </p> |
| |
| <pre>{ |
| "name": "My extension", |
| ... |
| |
| <b> "chrome_url_overrides" : { |
| "<em>pageToOverride</em>": "<em>myPage.html</em>" |
| }</b>, |
| ... |
| }</pre> |
| |
| <p> |
| For <code><em>pageToOverride</em></code>, substitute one of the following: |
| </p> |
| |
| <ul> |
| <li> <code>bookmarks</code> |
| <li> <code>history</code> |
| <li> <code>newtab</code> |
| </ul> |
| |
| |
| <h2 id="tips">Tips</h2> |
| |
| <p> |
| For an effective override page, follow these guidelines: |
| </p> |
| |
| <ul> |
| <li> |
| <p> |
| <b>Make your page quick and small.</b> <br /> |
| Users expect built-in browser pages to open instantly. |
| Avoid doing things that might take a long time. |
| For example, avoid synchronous fetches of network or database resources. |
| </p> |
| </li> |
| <li> |
| <p> |
| <b>Include a title in your page.</b> <br /> |
| Otherwise people might see the URL of the page, |
| which could be confusing. |
| Here's an example of specifying the title: |
| <code><title>New Tab</title></code> |
| </p> |
| </li> |
| <li> |
| <p> |
| <b>Don't rely on the page having the keyboard focus.</b> <br /> |
| The address bar always gets the focus first |
| when the user creates a new tab. |
| </p> |
| </li> |
| <li> |
| <p> |
| <b>Don't try to emulate the default New Tab page.</b> <br /> |
| The APIs necessary to create |
| a slightly modified version of the default New Tab page — |
| with top pages, |
| recently closed pages, |
| tips, |
| a theme background image, |
| and so on — |
| don't exist yet. |
| Until they do, |
| you're better off trying to make something completely different. |
| </p> |
| </li> |
| </ul> |
| |
| <h2 id="examples"> Examples </h2> |
| |
| <p> |
| See the |
| <a href="samples.html#chrome_url_overrides">override samples</a>. |
| </p> |