Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) | 179 _legacySetIcon: function(details) |
180 { | 180 { |
181 var legacyDetails = {}; | 181 var legacyDetails = {}; |
182 for (var key in details) | 182 for (var key in details) |
183 { | 183 { |
184 if (details.hasOwnProperty(key)) | 184 var value = details[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 { | 185 if (typeof value == "object") |
186 var value = details[key]; | 186 value = {19: value[19], 38: value[38]}; |
187 if (typeof value == "object") | 187 legacyDetails[key] = value; |
188 value = {19: value[19], 38: value[38]}; | |
189 legacyDetails[key] = value; | |
190 } | |
191 } | 188 } |
192 chrome.browserAction.setIcon(legacyDetails); | 189 chrome.browserAction.setIcon(legacyDetails); |
193 }, | 190 }, |
194 _safeSetIcon: function(details) | 191 _safeSetIcon: function(details) |
195 { | 192 { |
196 try | 193 try |
197 { | 194 { |
198 chrome.browserAction.setIcon(details); | 195 chrome.browserAction.setIcon(details); |
199 } | 196 } |
200 catch (e) | 197 catch (e) |
201 { | 198 { |
202 // Older versions of Chrome do not allow any sizes other than 19 and 38 | 199 // 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 | 200 // to be present, but newer versions of Chrome (and Edge) prefer |
204 // different sizes. | 201 // different sizes. |
205 this._safeSetIcon = this._legacySetIcon; | 202 this._safeSetIcon = this._legacySetIcon; |
206 this._legacySetIcon(details); | 203 this._legacySetIcon(details); |
207 } | 204 } |
208 }, | 205 }, |
209 _applyChanges: function() | 206 _applyChanges: function() |
210 { | 207 { |
211 if ("iconPath" in this._changes) | 208 if ("iconPath" in this._changes) |
212 { | 209 { |
213 var details = {tabId: this._tabId, path: {}}; | 210 this._safeSetIcon({ |
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.
| |
214 let sizes = [16, 19, 20, 32, 38, 40]; | 211 tabId: this._tabId, |
215 for (var size of sizes) | 212 path: { |
216 details.path[size] = this._changes.iconPath.replace("$size", size); | 213 16: this._changes.iconPath.replace("$size", "16"), |
217 this._safeSetIcon(details); | 214 19: this._changes.iconPath.replace("$size", "19"), |
215 20: this._changes.iconPath.replace("$size", "20"), | |
216 32: this._changes.iconPath.replace("$size", "32"), | |
217 38: this._changes.iconPath.replace("$size", "38"), | |
218 40: this._changes.iconPath.replace("$size", "40") | |
219 } | |
220 }); | |
218 } | 221 } |
219 | 222 |
220 if ("badgeText" in this._changes) | 223 if ("badgeText" in this._changes) |
221 { | 224 { |
222 chrome.browserAction.setBadgeText({ | 225 chrome.browserAction.setBadgeText({ |
223 tabId: this._tabId, | 226 tabId: this._tabId, |
224 text: this._changes.badgeText | 227 text: this._changes.badgeText |
225 }); | 228 }); |
226 } | 229 } |
227 | 230 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 ext.windows = { | 622 ext.windows = { |
620 create: function(createData, callback) | 623 create: function(createData, callback) |
621 { | 624 { |
622 chrome.windows.create(createData, function(createdWindow) | 625 chrome.windows.create(createData, function(createdWindow) |
623 { | 626 { |
624 afterTabLoaded(callback)(createdWindow.tabs[0]); | 627 afterTabLoaded(callback)(createdWindow.tabs[0]); |
625 }); | 628 }); |
626 } | 629 } |
627 }; | 630 }; |
628 })(); | 631 })(); |
LEFT | RIGHT |