Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 | 169 |
170 | 170 |
171 /* Browser actions */ | 171 /* Browser actions */ |
172 | 172 |
173 var BrowserAction = function(tabId) | 173 var BrowserAction = function(tabId) |
174 { | 174 { |
175 this._tabId = tabId; | 175 this._tabId = tabId; |
176 this._changes = null; | 176 this._changes = null; |
177 }; | 177 }; |
178 BrowserAction.prototype = { | 178 BrowserAction.prototype = { |
179 _legacySetIcon: function(details) | |
180 { | |
181 var legacyDetails = {}; | |
182 for (var key in details) | |
183 { | |
184 if (details.hasOwnProperty(key)) | |
Sebastian Noack
2016/08/16 16:49:11
Is this case worth to be considered? As far as I c
kzar
2016/08/16 16:59:17
Done.
| |
185 { | |
186 var value = details[key]; | |
187 if (typeof value == "object") | |
188 value = {19: value[19], 38: value[38]}; | |
189 legacyDetails[key] = value; | |
190 } | |
191 } | |
192 chrome.browserAction.setIcon(legacyDetails); | |
193 }, | |
194 _safeSetIcon: function(details) | |
195 { | |
196 try | |
197 { | |
198 chrome.browserAction.setIcon(details); | |
199 } | |
200 catch (e) | |
201 { | |
202 // Older versions of Chrome do not allow any sizes other than 19 and 38 | |
203 // to be present, but newer versions of Chrome (and Edge) prefer | |
204 // different sizes. | |
205 this._safeSetIcon = this._legacySetIcon; | |
206 this._legacySetIcon(details); | |
207 } | |
208 }, | |
179 _applyChanges: function() | 209 _applyChanges: function() |
180 { | 210 { |
181 if ("iconPath" in this._changes) | 211 if ("iconPath" in this._changes) |
182 { | 212 { |
183 chrome.browserAction.setIcon({ | 213 var details = {tabId: this._tabId, path: {}}; |
Sebastian Noack
2016/08/16 16:49:11
This change here isn't even necessary, and while i
kzar
2016/08/16 16:59:17
Done.
| |
184 tabId: this._tabId, | 214 let sizes = [16, 19, 20, 32, 38, 40]; |
185 path: { | 215 for (var size of sizes) |
186 16: this._changes.iconPath.replace("$size", "16"), | 216 details.path[size] = this._changes.iconPath.replace("$size", size); |
187 19: this._changes.iconPath.replace("$size", "19"), | 217 this._safeSetIcon(details); |
188 20: this._changes.iconPath.replace("$size", "20"), | |
189 32: this._changes.iconPath.replace("$size", "32"), | |
190 38: this._changes.iconPath.replace("$size", "38"), | |
191 40: this._changes.iconPath.replace("$size", "40") | |
192 } | |
193 }); | |
194 } | 218 } |
195 | 219 |
196 if ("badgeText" in this._changes) | 220 if ("badgeText" in this._changes) |
197 { | 221 { |
198 chrome.browserAction.setBadgeText({ | 222 chrome.browserAction.setBadgeText({ |
199 tabId: this._tabId, | 223 tabId: this._tabId, |
200 text: this._changes.badgeText | 224 text: this._changes.badgeText |
201 }); | 225 }); |
202 } | 226 } |
203 | 227 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 ext.windows = { | 619 ext.windows = { |
596 create: function(createData, callback) | 620 create: function(createData, callback) |
597 { | 621 { |
598 chrome.windows.create(createData, function(createdWindow) | 622 chrome.windows.create(createData, function(createdWindow) |
599 { | 623 { |
600 afterTabLoaded(callback)(createdWindow.tabs[0]); | 624 afterTabLoaded(callback)(createdWindow.tabs[0]); |
601 }); | 625 }); |
602 } | 626 } |
603 }; | 627 }; |
604 })(); | 628 })(); |
OLD | NEW |