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-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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 if (callback) | 584 if (callback) |
585 callback(new Page(tab)); | 585 callback(new Page(tab)); |
586 } | 586 } |
587 else | 587 else |
588 { | 588 { |
589 ext.pages.open(optionsUrl, callback); | 589 ext.pages.open(optionsUrl, callback); |
590 } | 590 } |
591 }); | 591 }); |
592 }); | 592 }); |
593 }; | 593 }; |
| 594 |
| 595 |
| 596 /* Devtools panel */ |
| 597 |
| 598 var Panel = function(inspectedTabId, port) |
| 599 { |
| 600 this.inspectedTabId = inspectedTabId; |
| 601 this._port = port; |
| 602 }; |
| 603 Panel.prototype = { |
| 604 sendMessage: function(message) |
| 605 { |
| 606 this._port.postMessage(message); |
| 607 }, |
| 608 get onRemoved() |
| 609 { |
| 610 return this._port.onDisconnect; |
| 611 } |
| 612 }; |
| 613 |
| 614 ext.devtools = { |
| 615 onCreated: new ext._EventTarget() |
| 616 }; |
| 617 |
| 618 // If this code should ever be removed, note that we still have to |
| 619 // ensure that there is at least one listener for the onConnect event. |
| 620 // Otherwise we can't connect a port later, in order to detect when |
| 621 // the extension is reloaded,disabled or uninstalled. |
| 622 chrome.runtime.onConnect.addListener(function(port) |
| 623 { |
| 624 var match = port.name.match(/^devtools-(\d+)$/); |
| 625 if (match) |
| 626 { |
| 627 var panel = new Panel(parseInt(match[1], 10), port); |
| 628 ext.devtools.onCreated._dispatch(panel); |
| 629 } |
| 630 }); |
594 })(); | 631 })(); |
OLD | NEW |