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

Side by Side Diff: firstRun.js

Issue 29715759: Issue 6440 - Use long-lived connections to listen to extension events (Closed)
Patch Set: Added message passing mock for ports Created March 7, 2018, 7: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
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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // Show warning if filterlists settings were reinitialized 63 // Show warning if filterlists settings were reinitialized
64 if (issues.filterlistsReinitialized) 64 if (issues.filterlistsReinitialized)
65 { 65 {
66 E("filterlistsReinitializedWarning").removeAttribute("hidden"); 66 E("filterlistsReinitializedWarning").removeAttribute("hidden");
67 setLinks("filterlistsReinitializedWarning", openFilters); 67 setLinks("filterlistsReinitializedWarning", openFilters);
68 } 68 }
69 }); 69 });
70 70
71 updateSocialLinks(); 71 updateSocialLinks();
72 72
73 ext.onMessage.addListener((message) => 73 let port = browser.runtime.connect({name: "ui"});
74
75 port.onMessage.addListener((message) =>
74 { 76 {
75 if (message.type == "subscriptions.respond") 77 if (message.type == "subscriptions.respond")
76 { 78 {
77 updateSocialLinks(); 79 updateSocialLinks();
78 } 80 }
79 }); 81 });
80 browser.runtime.sendMessage({ 82
83 port.postMessage({
81 type: "subscriptions.listen", 84 type: "subscriptions.listen",
82 filter: ["added", "removed", "updated", "disabled"] 85 filter: ["added", "removed", "updated", "disabled"]
83 }); 86 });
84 } 87 }
85 88
86 function updateSocialLinks() 89 function updateSocialLinks()
87 { 90 {
88 for (let network of ["twitter", "facebook", "gplus"]) 91 for (let network of ["twitter", "facebook", "gplus"])
89 { 92 {
90 let link = E("share-" + network); 93 let link = E("share-" + network);
(...skipping 21 matching lines...) Expand all
112 }); 115 });
113 } 116 }
114 117
115 function openFilters() 118 function openFilters()
116 { 119 {
117 browser.runtime.sendMessage({type: "app.open", what: "options"}); 120 browser.runtime.sendMessage({type: "app.open", what: "options"});
118 } 121 }
119 122
120 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 123 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
121 }()); 124 }());
OLDNEW
« ext/common.js ('K') | « ext/content.js ('k') | js/desktop-options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld