Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: devtools.js

Issue 29539835: Noissue - Check for devtools.panels API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Move check outside handler and add comment about Firefox version Created Sept. 8, 2017, 9:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 chrome.runtime.sendMessage( 22 // Versions of Firefox before 54 do not support the devtools.panels API; on
23 { 23 // these platforms, even when the option is enabled, we cannot show the
24 type: "prefs.get", 24 // devtools panel.
25 key: "show_devtools_panel" 25 if ("panels" in chrome.devtools)
26 }, 26 {
27 enabled => 27 chrome.runtime.sendMessage(
28 {
29 if (enabled)
30 { 28 {
31 chrome.devtools.panels.create( 29 type: "prefs.get",
32 "Adblock Plus", 30 key: "show_devtools_panel"
33 "icons/detailed/abp-48.png", 31 },
34 "devtools-panel.html", 32 enabled =>
35 panel => 33 {
36 { 34 if (enabled)
37 panel.onShown.addListener(window => 35 {
36 chrome.devtools.panels.create(
37 "Adblock Plus",
38 "icons/detailed/abp-48.png",
39 "devtools-panel.html",
40 panel =>
38 { 41 {
39 panelWindow = window; 42 panel.onShown.addListener(window =>
40 }); 43 {
44 panelWindow = window;
45 });
41 46
42 panel.onHidden.addListener(window => 47 panel.onHidden.addListener(window =>
43 { 48 {
44 panelWindow = null; 49 panelWindow = null;
45 }); 50 });
46 51
47 if (panel.onSearch) 52 if (panel.onSearch)
48 {
49 panel.onSearch.addListener((eventName, queryString) =>
50 { 53 {
51 if (panelWindow) 54 panel.onSearch.addListener((eventName, queryString) =>
52 panelWindow.postMessage({type: eventName, queryString}, "*"); 55 {
53 }); 56 if (panelWindow)
57 panelWindow.postMessage({type: eventName, queryString}, "*");
58 });
59 }
54 } 60 }
55 } 61 );
56 ); 62 }
57 } 63 }
58 } 64 );
59 ); 65 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld