| 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-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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 { | 315 { |
| 316 if (addedTabId == this._tabId) | 316 if (addedTabId == this._tabId) |
| 317 { | 317 { |
| 318 chrome.tabs.onReplaced.removeListener(onReplaced); | 318 chrome.tabs.onReplaced.removeListener(onReplaced); |
| 319 this._applyChanges(); | 319 this._applyChanges(); |
| 320 } | 320 } |
| 321 }; | 321 }; |
| 322 chrome.tabs.onReplaced.addListener(onReplaced); | 322 chrome.tabs.onReplaced.addListener(onReplaced); |
| 323 } | 323 } |
| 324 else | 324 else |
| 325 { |
| 325 this._applyChanges(); | 326 this._applyChanges(); |
| 327 } |
| 326 }); | 328 }); |
| 327 }, | 329 }, |
| 328 _addChange(name, value) | 330 _addChange(name, value) |
| 329 { | 331 { |
| 330 if (!this._changes) | 332 if (!this._changes) |
| 331 { | 333 { |
| 332 this._changes = {}; | 334 this._changes = {}; |
| 333 this._queueChanges(); | 335 this._queueChanges(); |
| 334 } | 336 } |
| 335 | 337 |
| 336 this._changes[name] = value; | 338 this._changes[name] = value; |
| 337 }, | 339 }, |
| 338 setIcon(path) | 340 setIcon(path) |
| 339 { | 341 { |
| 340 this._addChange("iconPath", path); | 342 this._addChange("iconPath", path); |
| 341 }, | 343 }, |
| 342 setBadge(badge) | 344 setBadge(badge) |
| 343 { | 345 { |
| 344 if (!badge) | 346 if (!badge) |
| 347 { |
| 345 this._addChange("badgeText", ""); | 348 this._addChange("badgeText", ""); |
| 349 } |
| 346 else | 350 else |
| 347 { | 351 { |
| 348 if ("number" in badge) | 352 if ("number" in badge) |
| 349 this._addChange("badgeText", badge.number.toString()); | 353 this._addChange("badgeText", badge.number.toString()); |
| 350 | 354 |
| 351 if ("color" in badge) | 355 if ("color" in badge) |
| 352 this._addChange("badgeColor", badge.color); | 356 this._addChange("badgeColor", badge.color); |
| 353 } | 357 } |
| 354 } | 358 } |
| 355 }; | 359 }; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 let results = ext.webRequest.onBeforeRequest._dispatch( | 536 let results = ext.webRequest.onBeforeRequest._dispatch( |
| 533 new URL(details.url), | 537 new URL(details.url), |
| 534 type.toUpperCase(), | 538 type.toUpperCase(), |
| 535 new Page({id: details.tabId}), | 539 new Page({id: details.tabId}), |
| 536 frame | 540 frame |
| 537 ); | 541 ); |
| 538 | 542 |
| 539 if (results.indexOf(false) != -1) | 543 if (results.indexOf(false) != -1) |
| 540 return {cancel: true}; | 544 return {cancel: true}; |
| 541 } | 545 } |
| 542 }, {urls: ["http://*/*", "https://*/*"]}, ["blocking"]); | 546 }, {urls: ["<all_urls>"]}, ["blocking"]); |
| 543 | 547 |
| 544 | 548 |
| 545 /* Message passing */ | 549 /* Message passing */ |
| 546 | 550 |
| 547 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => | 551 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => |
| 548 { | 552 { |
| 549 let sender = {}; | 553 let sender = {}; |
| 550 | 554 |
| 551 // Add "page" and "frame" if the message was sent by a content script. | 555 // Add "page" and "frame" if the message was sent by a content script. |
| 552 // If sent by popup or the background page itself, there is no "tab". | 556 // If sent by popup or the background page itself, there is no "tab". |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 onChanged: chrome.storage.onChanged | 601 onChanged: chrome.storage.onChanged |
| 598 }; | 602 }; |
| 599 | 603 |
| 600 /* Options */ | 604 /* Options */ |
| 601 | 605 |
| 602 if ("openOptionsPage" in chrome.runtime) | 606 if ("openOptionsPage" in chrome.runtime) |
| 603 { | 607 { |
| 604 ext.showOptions = callback => | 608 ext.showOptions = callback => |
| 605 { | 609 { |
| 606 if (!callback) | 610 if (!callback) |
| 611 { |
| 607 chrome.runtime.openOptionsPage(); | 612 chrome.runtime.openOptionsPage(); |
| 613 } |
| 608 else | 614 else |
| 609 { | 615 { |
| 610 chrome.runtime.openOptionsPage(() => | 616 chrome.runtime.openOptionsPage(() => |
| 611 { | 617 { |
| 612 if (chrome.runtime.lastError) | 618 if (chrome.runtime.lastError) |
| 613 return; | 619 return; |
| 614 | 620 |
| 615 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => | 621 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => |
| 616 { | 622 { |
| 617 if (tabs.length > 0) | 623 if (tabs.length > 0) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 { | 655 { |
| 650 let tab = tabs[0]; | 656 let tab = tabs[0]; |
| 651 | 657 |
| 652 chrome.windows.update(tab.windowId, {focused: true}); | 658 chrome.windows.update(tab.windowId, {focused: true}); |
| 653 chrome.tabs.update(tab.id, {active: true}); | 659 chrome.tabs.update(tab.id, {active: true}); |
| 654 | 660 |
| 655 if (callback) | 661 if (callback) |
| 656 callback(new Page(tab)); | 662 callback(new Page(tab)); |
| 657 } | 663 } |
| 658 else | 664 else |
| 665 { |
| 659 ext.pages.open(optionsUrl, callback); | 666 ext.pages.open(optionsUrl, callback); |
| 667 } |
| 660 }); | 668 }); |
| 661 }); | 669 }); |
| 662 }; | 670 }; |
| 663 } | 671 } |
| 664 | 672 |
| 665 /* Windows */ | 673 /* Windows */ |
| 666 ext.windows = { | 674 ext.windows = { |
| 667 create(createData, callback) | 675 create(createData, callback) |
| 668 { | 676 { |
| 669 chrome.windows.create(createData, createdWindow => | 677 chrome.windows.create(createData, createdWindow => |
| 670 { | 678 { |
| 671 afterTabLoaded(callback)(createdWindow.tabs[0]); | 679 afterTabLoaded(callback)(createdWindow.tabs[0]); |
| 672 }); | 680 }); |
| 673 } | 681 } |
| 674 }; | 682 }; |
| 675 }()); | 683 }()); |
| LEFT | RIGHT |