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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 _applyChanges() | 336 _applyChanges() |
337 { | 337 { |
338 if ("iconPath" in this._changes) | 338 if ("iconPath" in this._changes) |
339 { | 339 { |
340 // Firefox for Android displays the browser action not as an icon but | 340 // Firefox for Android displays the browser action not as an icon but |
341 // as a menu item. There is no icon, but such an option may be added in | 341 // as a menu item. There is no icon, but such an option may be added in |
342 // the future. | 342 // the future. |
343 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746 | 343 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746 |
344 if ("setIcon" in chrome.browserAction) | 344 if ("setIcon" in chrome.browserAction) |
345 { | 345 { |
346 chrome.browserAction.setIcon({ | 346 let path = { |
347 tabId: this._tabId, | 347 16: this._changes.iconPath.replace("$size", "16"), |
348 path: { | 348 19: this._changes.iconPath.replace("$size", "19"), |
349 16: this._changes.iconPath.replace("$size", "16"), | 349 20: this._changes.iconPath.replace("$size", "20"), |
350 19: this._changes.iconPath.replace("$size", "19"), | 350 32: this._changes.iconPath.replace("$size", "32"), |
351 20: this._changes.iconPath.replace("$size", "20"), | 351 38: this._changes.iconPath.replace("$size", "38"), |
352 32: this._changes.iconPath.replace("$size", "32"), | 352 40: this._changes.iconPath.replace("$size", "40") |
353 38: this._changes.iconPath.replace("$size", "38"), | 353 }; |
354 40: this._changes.iconPath.replace("$size", "40") | 354 try |
355 } | 355 { |
356 }); | 356 chrome.browserAction.setIcon({tabId: this._tabId, path}); |
| 357 } |
| 358 catch (e) |
| 359 { |
| 360 // Edge throws if passed icon sizes different than 19,20,38,40px. |
| 361 delete path[16]; |
| 362 delete path[32]; |
| 363 chrome.browserAction.setIcon({tabId: this._tabId, path}); |
| 364 } |
357 } | 365 } |
358 } | 366 } |
359 | 367 |
360 if ("badgeText" in this._changes) | 368 if ("badgeText" in this._changes) |
361 { | 369 { |
362 // There is no badge on Firefox for Android; the browser action is | 370 // There is no badge on Firefox for Android; the browser action is |
363 // simply a menu item. | 371 // simply a menu item. |
364 if ("setBadgeText" in chrome.browserAction) | 372 if ("setBadgeText" in chrome.browserAction) |
365 { | 373 { |
366 chrome.browserAction.setBadgeText({ | 374 chrome.browserAction.setBadgeText({ |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 ext.windows = { | 785 ext.windows = { |
778 create(createData, callback) | 786 create(createData, callback) |
779 { | 787 { |
780 chrome.windows.create(createData, createdWindow => | 788 chrome.windows.create(createData, createdWindow => |
781 { | 789 { |
782 afterTabLoaded(callback)(createdWindow.tabs[0]); | 790 afterTabLoaded(callback)(createdWindow.tabs[0]); |
783 }); | 791 }); |
784 } | 792 } |
785 }; | 793 }; |
786 }()); | 794 }()); |
OLD | NEW |