| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 let panelWindow = null; | 20 let panelWindow = null; |
| 21 | 21 |
| 22 // Versions of Firefox before 54 do not support the devtools.panels API; on | 22 // Versions of Firefox before 54 do not support the devtools.panels API; on |
| 23 // these platforms, even when the option is enabled, we cannot show the | 23 // these platforms, even when the option is enabled, we cannot show the |
| 24 // devtools panel. | 24 // devtools panel. |
| 25 if ("panels" in chrome.devtools) | 25 if ("panels" in browser.devtools) |
| 26 { | 26 { |
| 27 chrome.runtime.sendMessage( | 27 browser.runtime.sendMessage( |
| 28 { | 28 { |
| 29 type: "prefs.get", | 29 type: "prefs.get", |
| 30 key: "show_devtools_panel" | 30 key: "show_devtools_panel" |
| 31 }, | 31 }, |
| 32 enabled => | 32 enabled => |
| 33 { | 33 { |
| 34 if (enabled) | 34 if (enabled) |
| 35 { | 35 { |
| 36 chrome.devtools.panels.create( | 36 browser.devtools.panels.create( |
| 37 "Adblock Plus", | 37 "Adblock Plus", |
| 38 "icons/detailed/abp-48.png", | 38 "icons/detailed/abp-48.png", |
| 39 "devtools-panel.html", | 39 "devtools-panel.html", |
| 40 panel => | 40 panel => |
| 41 { | 41 { |
| 42 panel.onShown.addListener(window => | 42 panel.onShown.addListener(window => |
| 43 { | 43 { |
| 44 panelWindow = window; | 44 panelWindow = window; |
| 45 }); | 45 }); |
| 46 | 46 |
| 47 panel.onHidden.addListener(window => | 47 panel.onHidden.addListener(window => |
| 48 { | 48 { |
| 49 panelWindow = null; | 49 panelWindow = null; |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 if (panel.onSearch) | 52 if (panel.onSearch) |
| 53 { | 53 { |
| 54 panel.onSearch.addListener((eventName, queryString) => | 54 panel.onSearch.addListener((eventName, queryString) => |
| 55 { | 55 { |
| 56 if (panelWindow) | 56 if (panelWindow) |
| 57 panelWindow.postMessage({type: eventName, queryString}, "*"); | 57 panelWindow.postMessage({type: eventName, queryString}, "*"); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 ); | 61 ); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 ); | 64 ); |
| 65 } | 65 } |
| OLD | NEW |