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

Delta Between Two Patch Sets: background.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Left Patch Set: Implement getPort() Created March 21, 2016, 3:25 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 | « no previous file | chrome/devtools.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
(...skipping 22 matching lines...) Expand all
33 this.extractHostFromFrame = extractHostFromFrame; 33 this.extractHostFromFrame = extractHostFromFrame;
34 } 34 }
35 var FilterStorage = require("filterStorage").FilterStorage; 35 var FilterStorage = require("filterStorage").FilterStorage;
36 var FilterNotifier = require("filterNotifier").FilterNotifier; 36 var FilterNotifier = require("filterNotifier").FilterNotifier;
37 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; 37 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription;
38 var ElemHide = require("elemHide").ElemHide; 38 var ElemHide = require("elemHide").ElemHide;
39 var defaultMatcher = require("matcher").defaultMatcher; 39 var defaultMatcher = require("matcher").defaultMatcher;
40 var Prefs = require("prefs").Prefs; 40 var Prefs = require("prefs").Prefs;
41 var updateIcon = require("icon").updateIcon; 41 var updateIcon = require("icon").updateIcon;
42 var showNextNotificationForUrl = require("notificationHelper").showNextNotificat ionForUrl; 42 var showNextNotificationForUrl = require("notificationHelper").showNextNotificat ionForUrl;
43 var port = require("messaging").port; 43 var port = require("messaging").port;
Wladimir Palant 2016/03/21 15:50:12 Arguably, this should use getPort() as well and no
Sebastian Noack 2016/03/21 17:15:42 background.js is matter to go away. In the mid-ter
44 var devtools = require("devtools"); 44 var devtools = require("devtools");
45 45
46 // Special-case domains for which we cannot use style-based hiding rules. 46 // Special-case domains for which we cannot use style-based hiding rules.
47 // See http://crbug.com/68705. 47 // See http://crbug.com/68705.
48 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; 48 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"];
49 49
50 var htmlPages = new ext.PageMap(); 50 var htmlPages = new ext.PageMap();
51 51
52 var contextMenuItem = { 52 var contextMenuItem = {
53 title: ext.i18n.getMessage("block_element"), 53 title: ext.i18n.getMessage("block_element"),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (filter.collapse != null) 183 if (filter.collapse != null)
184 return filter.collapse; 184 return filter.collapse;
185 185
186 blocked = true; 186 blocked = true;
187 } 187 }
188 } 188 }
189 189
190 return blocked && Prefs.hidePlaceholders; 190 return blocked && Prefs.hidePlaceholders;
191 }); 191 });
192 192
193 port.on("get-domain-enabled-state", function(msg, sender)
194 {
195 return {enabled: !checkWhitelisted(sender.page)};
196 });
197
198 port.on("forward", function(msg, sender) 193 port.on("forward", function(msg, sender)
199 { 194 {
200 var targetPage; 195 var targetPage;
201 if (msg.targetPageId) 196 if (msg.targetPageId)
202 targetPage = ext.getPage(msg.targetPageId); 197 targetPage = ext.getPage(msg.targetPageId);
203 else 198 else
204 targetPage = sender.page; 199 targetPage = sender.page;
205 200
206 if (targetPage) 201 if (targetPage)
207 { 202 {
208 msg.payload.sender = sender.page.id; 203 msg.payload.sender = sender.page.id;
209 if (msg.expectsResponse) 204 if (msg.expectsResponse)
210 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); 205 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload));
211 targetPage.sendMessage(msg.payload); 206 targetPage.sendMessage(msg.payload);
212 } 207 }
213 }); 208 });
214 209
215 // update icon when page changes location 210 // update icon when page changes location
216 ext.pages.onLoading.addListener(function(page) 211 ext.pages.onLoading.addListener(function(page)
217 { 212 {
218 page.sendMessage({type: "composer.content.finished"}); 213 page.sendMessage({type: "composer.content.finished"});
219 refreshIconAndContextMenu(page); 214 refreshIconAndContextMenu(page);
220 showNextNotificationForUrl(page.url); 215 showNextNotificationForUrl(page.url);
221 }); 216 });
LEFTRIGHT
« no previous file | chrome/devtools.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld