| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 catch (e) | 344 catch (e) |
| 345 { | 345 { |
| 346 // Edge throws if passed icon sizes different than 19,20,38,40px. | 346 // Edge throws if passed icon sizes different than 19,20,38,40px. |
| 347 delete path[16]; | 347 delete path[16]; |
| 348 delete path[32]; | 348 delete path[32]; |
| 349 return browser.browserAction.setIcon({tabId: this._tabId, path}); | 349 return browser.browserAction.setIcon({tabId: this._tabId, path}); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 if (change == "iconImageData" && "setIcon" in browser.browserAction) |
| 354 { |
| 355 return browser.browserAction.setIcon({ |
| 356 tabId: this._tabId, |
| 357 imageData: this._changes.iconImageData |
| 358 }); |
| 359 } |
| 360 |
| 353 // There is no badge on Firefox for Android; the browser action is | 361 // There is no badge on Firefox for Android; the browser action is |
| 354 // simply a menu item. | 362 // simply a menu item. |
| 355 if (change == "badgeText" && "setBadgeText" in browser.browserAction) | 363 if (change == "badgeText" && "setBadgeText" in browser.browserAction) |
| 356 return browser.browserAction.setBadgeText({ | 364 return browser.browserAction.setBadgeText({ |
| 357 tabId: this._tabId, | 365 tabId: this._tabId, |
| 358 text: this._changes.badgeText | 366 text: this._changes.badgeText |
| 359 }); | 367 }); |
| 360 | 368 |
| 361 // There is no badge on Firefox for Android; the browser action is | 369 // There is no badge on Firefox for Android; the browser action is |
| 362 // simply a menu item. | 370 // simply a menu item. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 392 this._changes = null; | 400 this._changes = null; |
| 393 }).catch(() => | 401 }).catch(() => |
| 394 { | 402 { |
| 395 // If the tab is prerendered, browser.browserAction.set* fails | 403 // If the tab is prerendered, browser.browserAction.set* fails |
| 396 // and we have to delay our changes until the currently visible tab | 404 // and we have to delay our changes until the currently visible tab |
| 397 // is replaced with the prerendered tab. | 405 // is replaced with the prerendered tab. |
| 398 browser.tabs.onReplaced.addListener(onReplaced); | 406 browser.tabs.onReplaced.addListener(onReplaced); |
| 399 }); | 407 }); |
| 400 } | 408 } |
| 401 }, | 409 }, |
| 402 setIcon(path) | 410 setIcon(path, imageData = null) |
| 403 { | 411 { |
| 404 this._addChange("iconPath", path); | 412 // Use ImageData if available. |
| 413 if (imageData) |
| 414 this._addChange("iconImageData", imageData); |
| 415 else |
| 416 this._addChange("iconPath", path); |
| 405 }, | 417 }, |
| 406 setBadge(badge) | 418 setBadge(badge) |
| 407 { | 419 { |
| 408 if (!badge) | 420 if (!badge) |
| 409 { | 421 { |
| 410 this._addChange("badgeText", ""); | 422 this._addChange("badgeText", ""); |
| 411 } | 423 } |
| 412 else | 424 else |
| 413 { | 425 { |
| 414 if ("number" in badge) | 426 if ("number" in badge) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 return frames.get(0) || null; | 531 return frames.get(0) || null; |
| 520 } | 532 } |
| 521 }; | 533 }; |
| 522 } | 534 } |
| 523 | 535 |
| 524 return ext.onMessage._dispatch( | 536 return ext.onMessage._dispatch( |
| 525 message, sender, sendResponse | 537 message, sender, sendResponse |
| 526 ).includes(true); | 538 ).includes(true); |
| 527 }); | 539 }); |
| 528 } | 540 } |
| OLD | NEW |