| Index: chrome/ext/background.js |
| diff --git a/chrome/ext/background.js b/chrome/ext/background.js |
| index fe0cd37f2fa1b68ff83ab00a5ab9a4f46811777b..eab429541e5ad596bdfd4167c3fc7251d29114fd 100644 |
| --- a/chrome/ext/background.js |
| +++ b/chrome/ext/background.js |
| @@ -169,6 +169,7 @@ |
| /* Browser actions */ |
| + var supportedIconSizes = ["19", "38", "16", "32", "20", "40"]; |
|
Sebastian Noack
2016/08/15 21:22:16
Nit: Preserve the blank line.
kzar
2016/08/16 08:33:40
Done.
|
| var BrowserAction = function(tabId) |
| { |
| @@ -178,19 +179,30 @@ |
| BrowserAction.prototype = { |
| _applyChanges: function() |
| { |
| + var iconDetails = function() |
|
Sebastian Noack
2016/08/15 21:22:16
For consistency with the surrounding code, make it
kzar
2016/08/16 08:33:40
Done.
|
| + { |
| + var details = {tabId: this._tabId, path: {}}; |
| + for (var size of supportedIconSizes) |
| + details.path[size] = this._changes.iconPath.replace("$size", size); |
| + return details; |
| + }.bind(this); |
| + |
| if ("iconPath" in this._changes) |
| { |
| - chrome.browserAction.setIcon({ |
| - tabId: this._tabId, |
| - path: { |
| - 16: this._changes.iconPath.replace("$size", "16"), |
| - 19: this._changes.iconPath.replace("$size", "19"), |
| - 20: this._changes.iconPath.replace("$size", "20"), |
| - 32: this._changes.iconPath.replace("$size", "32"), |
| - 38: this._changes.iconPath.replace("$size", "38"), |
| - 40: this._changes.iconPath.replace("$size", "40") |
| - } |
| - }); |
| + try |
| + { |
| + chrome.browserAction.setIcon(iconDetails()); |
| + } |
| + catch (e) |
| + { |
| + if (supportedIconSizes.length == 2) |
| + throw(e); |
|
Sebastian Noack
2016/08/15 22:13:05
This branch is redundant. It's not that we would e
kzar
2016/08/16 08:33:40
Oh yea, it would just be called twice but who care
|
| + |
| + // Edge and newer versions of Chrome prefer different icon sizes, but |
| + // older versions of Chrome cannot handle them being present! |
| + supportedIconSizes.splice(2); |
| + chrome.browserAction.setIcon(iconDetails()); |
| + } |
| } |
| if ("badgeText" in this._changes) |