bevanb
bevanb

Reputation: 8521

Adding a favicon to a Chrome Extension new tab page

My Chrome extension loads main.html as the new tab page. How do I specify a favicon for that page?

When I try to specify a favicon in main.html, it doesn't appear. Here's my code in the <head> section:

    <link rel="shortcut icon" type="image/x-icon" href="http://www.stackoverflow.com/favicon.ico">

There is a 16px icon specified in the manifest, but it doesn't appear as the favicon:

"icons": { "16": "icon16.png",
                     "32": "icon32.png",
                     "128": "icon128.png" }

Upvotes: 2

Views: 2414

Answers (1)

Josh Lee
Josh Lee

Reputation: 177614

If you load the resource directly via chrome-extension://…/main.html, the icon is shown in the tab, but not in the new tab page. This seems to be deliberate, see favicon::ShouldDisplayFavicon in browser/favicon/favicon_utils.cc.

There's no obvious way around this without e.g. manually setting the tab URL to the chrome-extension:// scheme, which would not work well as a new tab page.

Upvotes: 6

Related Questions