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

Delta Between Two Patch Sets: popup.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Left Patch Set: Implement Port.disconnect() Created March 21, 2016, 4:59 p.m.
Right Patch Set: Moved get-domain-enabled-state to whitelisting module Created March 22, 2016, 8:22 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « metadata.common ('k') | safari/include.youtube.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 var backgroundPage = ext.backgroundPage.getWindow(); 18 var backgroundPage = ext.backgroundPage.getWindow();
19 var require = backgroundPage.require; 19 var require = backgroundPage.require;
20 20
21 var Filter = require("filterClasses").Filter; 21 var Filter = require("filterClasses").Filter;
22 var FilterStorage = require("filterStorage").FilterStorage; 22 var FilterStorage = require("filterStorage").FilterStorage;
23 var Prefs = require("prefs").Prefs; 23 var Prefs = require("prefs").Prefs;
24 var checkWhitelisted = require("whitelisting").checkWhitelisted; 24 var checkWhitelisted = require("whitelisting").checkWhitelisted;
25 var getDecodedHostname = require("url").getDecodedHostname; 25 var getDecodedHostname = require("url").getDecodedHostname;
26 var getPort = require("messaging").getPort;
27 26
28 var page = null; 27 var page = null;
29 28
30 function onLoad() 29 function onLoad()
31 { 30 {
32 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) 31 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
33 { 32 {
34 page = pages[0]; 33 page = pages[0];
35 34
36 // Mark page as 'local' or 'nohtml' to hide non-relevant elements 35 // Mark page as 'local' or 'nohtml' to hide non-relevant elements
37 if (!page || (page.url.protocol != "http:" && 36 if (!page || (page.url.protocol != "http:" &&
38 page.url.protocol != "https:")) 37 page.url.protocol != "https:"))
39 document.body.classList.add("local"); 38 document.body.classList.add("local");
40 else if (!backgroundPage.htmlPages.has(page)) 39 else if (!backgroundPage.htmlPages.has(page))
41 { 40 {
42 document.body.classList.add("nohtml"); 41 document.body.classList.add("nohtml");
43 getPort(window).on("composer.ready", function(message, sender) 42 require("messaging").getPort(window).on(
44 { 43 "composer.ready", function(message, sender)
45 if (sender.page.id == page.id) 44 {
46 document.body.classList.remove("nohtml"); 45 if (sender.page.id == page.id)
47 }); 46 document.body.classList.remove("nohtml");
47 }
48 );
48 } 49 }
49 50
50 // Ask content script whether clickhide is active. If so, show cancel button . 51 // Ask content script whether clickhide is active. If so, show cancel button .
51 // If that isn't the case, ask background.html whether it has cached filters . If so, 52 // If that isn't the case, ask background.html whether it has cached filters . If so,
52 // ask the user whether she wants those filters. 53 // ask the user whether she wants those filters.
53 // Otherwise, we are in default state. 54 // Otherwise, we are in default state.
54 if (page) 55 if (page)
55 { 56 {
56 if (checkWhitelisted(page)) 57 if (checkWhitelisted(page))
57 document.body.classList.add("disabled"); 58 document.body.classList.add("disabled");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 135
135 function toggleCollapse(event) 136 function toggleCollapse(event)
136 { 137 {
137 var collapser = event.currentTarget; 138 var collapser = event.currentTarget;
138 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; 139 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
139 collapser.parentNode.classList.toggle("collapsed"); 140 collapser.parentNode.classList.toggle("collapsed");
140 } 141 }
141 142
142 document.addEventListener("DOMContentLoaded", onLoad, false); 143 document.addEventListener("DOMContentLoaded", onLoad, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld