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

Side by Side Diff: messageResponder.js

Issue 29339192: Issue 3880 - Improve behavior of Safari content blocker option (Closed)
Patch Set: Created March 31, 2016, 12:12 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return result; 64 return result;
65 } 65 }
66 66
67 var convertSubscription = convertObject.bind(null, ["disabled", 67 var convertSubscription = convertObject.bind(null, ["disabled",
68 "downloadStatus", "homepage", "lastDownload", "title", "url"]); 68 "downloadStatus", "homepage", "lastDownload", "title", "url"]);
69 var convertFilter = convertObject.bind(null, ["text"]); 69 var convertFilter = convertObject.bind(null, ["text"]);
70 70
71 var changeListeners = new global.ext.PageMap(); 71 var changeListeners = new global.ext.PageMap();
72 var listenedPreferences = Object.create(null); 72 var listenedPreferences = Object.create(null);
73 var listenedFilterChanges = Object.create(null); 73 var listenedFilterChanges = Object.create(null);
74 var safariRestartRequired = null;
74 var messageTypes = { 75 var messageTypes = {
75 "app": "app.respond", 76 "app": "app.respond",
76 "filter": "filters.respond", 77 "filter": "filters.respond",
77 "pref": "prefs.respond", 78 "pref": "prefs.respond",
78 "subscription": "subscriptions.respond" 79 "subscription": "subscriptions.respond"
79 }; 80 };
80 81
81 function sendMessage(type, action) 82 function sendMessage(type, action)
82 { 83 {
83 var pages = changeListeners.keys(); 84 var pages = changeListeners.keys();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 safariContentBlocker: "safari" in global 183 safariContentBlocker: "safari" in global
183 && "extension" in global.safari 184 && "extension" in global.safari
184 && "setContentBlocker" in global.safari.extension 185 && "setContentBlocker" in global.safari.extension
185 }); 186 });
186 } 187 }
187 else 188 else
188 callback(info[message.what]); 189 callback(info[message.what]);
189 break; 190 break;
190 case "app.listen": 191 case "app.listen":
191 getListenerFilters(sender.page).app = message.filter; 192 getListenerFilters(sender.page).app = message.filter;
193 if (message.filter.indexOf("safariRestartRequired") != -1)
194 {
195 if (safariRestartRequired == null)
196 {
197 safariRestartRequired = false;
198 Prefs.on("safari_contentblocker", function()
199 {
200 safariRestartRequired = !Prefs.safari_contentblocker;
201 sendMessage("app", "safariRestartRequired", safariRestartRequired) ;
202 });
203 }
204
205 sender.page.sendMessage({
206 type: messageTypes.app,
207 action: "safariRestartRequired",
208 args: [safariRestartRequired]
209 });
210 }
192 break; 211 break;
193 case "app.open": 212 case "app.open":
194 if (message.what == "options") 213 if (message.what == "options")
195 ext.showOptions(); 214 ext.showOptions();
196 break; 215 break;
197 case "filters.add": 216 case "filters.add":
198 var result = require("filterValidation").parseFilter(message.text); 217 var result = require("filterValidation").parseFilter(message.text);
199 var errors = []; 218 var errors = [];
200 if (result.error) 219 if (result.error)
201 errors.push(result.error.toString()); 220 errors.push(result.error.toString());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 if (subscription instanceof DownloadableSubscription) 414 if (subscription instanceof DownloadableSubscription)
396 Synchronizer.execute(subscription, true); 415 Synchronizer.execute(subscription, true);
397 } 416 }
398 break; 417 break;
399 case "subscriptions.isDownloading": 418 case "subscriptions.isDownloading":
400 callback(Synchronizer.isExecuting(message.url)); 419 callback(Synchronizer.isExecuting(message.url));
401 break; 420 break;
402 } 421 }
403 }); 422 });
404 })(this); 423 })(this);
OLDNEW

Powered by Google App Engine
This is Rietveld