culebrón
culebrón

Reputation: 36463

Chrome extension can't get access to chrome://extension-icon

I'm trying to list other extensions from my Chrome extension, and show their icons.

Another extension (Zenmate VPN) shows other's icons easily. I figured out that it has management permission in it's manifest.

When I add management to permissions section, everything works fine. The problem is that we don't want to add this permission there, because Chrome will disable the extension by default if the updated version asks for more permisssions.

Is there a way to somehow refresh permissions in a page, in order to make icon URLs work (chrome://extension-icon/*), like they work in ZenMate?

Upvotes: 0

Views: 604

Answers (2)

culebrón
culebrón

Reputation: 36463

I checked if I could go with wOxxOm's answer, and mostly extensions did not have bigger favicons, nor I can request chrome://favicon/* permission: Chrome throws an exeption:

Unchecked runtime.lastError while running permissions.request: 'chrome://favicon/*' is not a recognized permission.

So I found a simple and robust solution: I just close the current tab and create a new one:

    permissionsAchieved = function(allowed) {
        chrome.tabs.create({ url: "<write current url here>" });
        window.close();
    },

Done. In the newly opened tab, the icon is shown correctly.

But thanks for a suggestion!

Upvotes: 0

woxxom
woxxom

Reputation: 73546

If you already have chrome://favicon permission you can use it to display an extension favicon:

<img src="chrome://favicon/chrome-extension://igiofjhpmpihnifddep‌​npngfjhkfenbp/">

In case you didn't have chrome://favicon permission initially, try adding it in optional_permissions. If it won't work, try adding to permissions but first test if it'll disable your extension on update.

Other icon sizes may be specified (in the absence of an actual big icon the default 16x16px is scaled):

  • Retina 2x DPI: chrome://favicon/size/16@2x/chrome-extension://.......
  • 48px: chrome://favicon/size/48/chrome-extension://.......

Upvotes: 2

Related Questions