| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 let BrowserAction = function(tabId) | 320 let BrowserAction = function(tabId) |
| 321 { | 321 { |
| 322 this._tabId = tabId; | 322 this._tabId = tabId; |
| 323 this._changes = null; | 323 this._changes = null; |
| 324 }; | 324 }; |
| 325 BrowserAction.prototype = { | 325 BrowserAction.prototype = { |
| 326 _applyChanges() | 326 _applyChanges() |
| 327 { | 327 { |
| 328 if ("iconPath" in this._changes) | 328 if ("iconPath" in this._changes) |
| 329 { | 329 { |
| 330 chrome.browserAction.setIcon({ | 330 if (chrome.browserAction.setIcon) |
| 331 tabId: this._tabId, | 331 { |
| 332 path: { | 332 chrome.browserAction.setIcon({ |
| 333 16: this._changes.iconPath.replace("$size", "16"), | 333 tabId: this._tabId, |
| 334 19: this._changes.iconPath.replace("$size", "19"), | 334 path: { |
| 335 20: this._changes.iconPath.replace("$size", "20"), | 335 16: this._changes.iconPath.replace("$size", "16"), |
| 336 32: this._changes.iconPath.replace("$size", "32"), | 336 19: this._changes.iconPath.replace("$size", "19"), |
| 337 38: this._changes.iconPath.replace("$size", "38"), | 337 20: this._changes.iconPath.replace("$size", "20"), |
| 338 40: this._changes.iconPath.replace("$size", "40") | 338 32: this._changes.iconPath.replace("$size", "32"), |
| 339 } | 339 38: this._changes.iconPath.replace("$size", "38"), |
| 340 }); | 340 40: this._changes.iconPath.replace("$size", "40") |
| 341 } |
| 342 }); |
| 343 } |
| 341 } | 344 } |
| 342 | 345 |
| 343 if ("badgeText" in this._changes) | 346 if ("badgeText" in this._changes) |
| 344 { | 347 { |
| 345 chrome.browserAction.setBadgeText({ | 348 if (chrome.browserAction.setBadgeText) |
| 346 tabId: this._tabId, | 349 { |
| 347 text: this._changes.badgeText | 350 chrome.browserAction.setBadgeText({ |
| 348 }); | 351 tabId: this._tabId, |
| 352 text: this._changes.badgeText |
| 353 }); |
| 354 } |
| 349 } | 355 } |
| 350 | 356 |
| 351 if ("badgeColor" in this._changes) | 357 if ("badgeColor" in this._changes) |
| 352 { | 358 { |
| 353 chrome.browserAction.setBadgeBackgroundColor({ | 359 if (chrome.browserAction.setBadgeBackgroundColor) |
| 354 tabId: this._tabId, | 360 { |
| 355 color: this._changes.badgeColor | 361 chrome.browserAction.setBadgeBackgroundColor({ |
| 356 }); | 362 tabId: this._tabId, |
| 363 color: this._changes.badgeColor |
| 364 }); |
| 365 } |
| 357 } | 366 } |
| 358 | 367 |
| 359 this._changes = null; | 368 this._changes = null; |
| 360 }, | 369 }, |
| 361 _queueChanges() | 370 _queueChanges() |
| 362 { | 371 { |
| 363 chrome.tabs.get(this._tabId, () => | 372 chrome.tabs.get(this._tabId, () => |
| 364 { | 373 { |
| 365 // If the tab is prerendered, chrome.tabs.get() sets | 374 // If the tab is prerendered, chrome.tabs.get() sets |
| 366 // chrome.runtime.lastError and we have to delay our changes | 375 // chrome.runtime.lastError and we have to delay our changes |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 ext.windows = { | 748 ext.windows = { |
| 740 create(createData, callback) | 749 create(createData, callback) |
| 741 { | 750 { |
| 742 chrome.windows.create(createData, createdWindow => | 751 chrome.windows.create(createData, createdWindow => |
| 743 { | 752 { |
| 744 afterTabLoaded(callback)(createdWindow.tabs[0]); | 753 afterTabLoaded(callback)(createdWindow.tabs[0]); |
| 745 }); | 754 }); |
| 746 } | 755 } |
| 747 }; | 756 }; |
| 748 }()); | 757 }()); |
| OLD | NEW |