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

Side by Side Diff: background.js

Issue 29339314: Issue 3870 - Rewrite legacy options page to use async messages (Closed)
Patch Set: Fix Downloading... indicators Created April 3, 2016, 4:10 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 | dependencies » ('j') | options.js » ('J')
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-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 10 matching lines...) Expand all
21 this.WhitelistFilter = WhitelistFilter; 21 this.WhitelistFilter = WhitelistFilter;
22 } 22 }
23 var FilterStorage = require("filterStorage").FilterStorage; 23 var FilterStorage = require("filterStorage").FilterStorage;
24 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; 24 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription;
25 var ElemHide = require("elemHide").ElemHide; 25 var ElemHide = require("elemHide").ElemHide;
26 var checkWhitelisted = require("whitelisting").checkWhitelisted; 26 var checkWhitelisted = require("whitelisting").checkWhitelisted;
27 var extractHostFromFrame = require("url").extractHostFromFrame; 27 var extractHostFromFrame = require("url").extractHostFromFrame;
28 var port = require("messaging").port; 28 var port = require("messaging").port;
29 var devtools = require("devtools"); 29 var devtools = require("devtools");
30 30
31 // This is a hack to speedup loading of the options page on Safari.
32 // Once we replaced the background page proxy with message passing
33 // this global function should removed.
34 function getUserFilters()
35 {
36 var filters = [];
37 var exceptions = [];
38
39 for (var i = 0; i < FilterStorage.subscriptions.length; i++)
Sebastian Noack 2016/04/03 18:19:59 Please remove the imports for names no longer used
kzar 2016/04/05 11:10:15 Done.
40 {
41 var subscription = FilterStorage.subscriptions[i];
42 if (!(subscription instanceof SpecialSubscription))
43 continue;
44
45 for (var j = 0; j < subscription.filters.length; j++)
46 {
47 var filter = subscription.filters[j];
48 if (filter instanceof WhitelistFilter && /^@@\|\|([^\/:]+)\^\$document$/. test(filter.text))
49 exceptions.push(RegExp.$1);
50 else
51 filters.push(filter.text);
52 }
53 }
54
55 return {filters: filters, exceptions: exceptions};
56 }
57
58 port.on("get-selectors", function(msg, sender) 31 port.on("get-selectors", function(msg, sender)
59 { 32 {
60 var selectors; 33 var selectors;
61 var trace = devtools && devtools.hasPanel(sender.page); 34 var trace = devtools && devtools.hasPanel(sender.page);
62 35
63 if (!checkWhitelisted(sender.page, sender.frame, 36 if (!checkWhitelisted(sender.page, sender.frame,
64 RegExpFilter.typeMap.DOCUMENT | 37 RegExpFilter.typeMap.DOCUMENT |
65 RegExpFilter.typeMap.ELEMHIDE)) 38 RegExpFilter.typeMap.ELEMHIDE))
66 selectors = ElemHide.getSelectorsForDomain( 39 selectors = ElemHide.getSelectorsForDomain(
67 extractHostFromFrame(sender.frame), 40 extractHostFromFrame(sender.frame),
(...skipping 15 matching lines...) Expand all
83 targetPage = sender.page; 56 targetPage = sender.page;
84 57
85 if (targetPage) 58 if (targetPage)
86 { 59 {
87 msg.payload.sender = sender.page.id; 60 msg.payload.sender = sender.page.id;
88 if (msg.expectsResponse) 61 if (msg.expectsResponse)
89 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); 62 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload));
90 targetPage.sendMessage(msg.payload); 63 targetPage.sendMessage(msg.payload);
91 } 64 }
92 }); 65 });
OLDNEW
« no previous file with comments | « no previous file | dependencies » ('j') | options.js » ('J')

Powered by Google App Engine
This is Rietveld