Skip to content

Commit

Permalink
Retry setting icon with legacy sizes if it fails. Fix #1003.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisCatus committed Mar 1, 2017
1 parent cc95e49 commit 0f61f18
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions omega-target-chromium-extension/src/tabs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,27 @@ class ChromeTabs
setIcon: (icon, tabId) ->
return unless icon?
if tabId?
chrome.browserAction.setIcon({
params = {
imageData: icon
tabId: tabId
}, @ignoreError)
}
else
chrome.browserAction.setIcon({imageData: icon}, @ignoreError)
params = {
imageData: icon
}
@_chromeSetIcon(params)

_chromeSetIcon: (params) ->
try
chrome.browserAction.setIcon(params, @ignoreError)
catch
# Some legacy Chrome versions will panic if there are other icon sizes.
params.imageData = {19: params.imageData[19], 38: params.imageData[38]}
chrome.browserAction.setIcon(params, @ignoreError)

clearIcon: (tabId) ->
return unless @_defaultAction?.icon?
chrome.browserAction.setIcon({
@_chromeSetIcon({
imageData: @_defaultAction.icon
tabId: tabId
}, @ignoreError)
Expand Down

0 comments on commit 0f61f18

Please sign in to comment.