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

Delta Between Two Patch Sets: lib/filterComposer.js

Issue 29516679: Issue 5347 - Do not show composer menu item on Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Created Aug. 15, 2017, 11:40 p.m.
Right Patch Set: Check for "Fennec" explicitly Created Aug. 24, 2017, 10:33 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 | no next file » | 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-2017 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
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 *
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 getKey(page, frame), specificOnly 112 getKey(page, frame), specificOnly
113 ); 113 );
114 114
115 if (!filter) 115 if (!filter)
116 { 116 {
117 let filterText = url.replace(/^[\w-]+:\/+(?:www\.)?/, "||"); 117 let filterText = url.replace(/^[\w-]+:\/+(?:www\.)?/, "||");
118 118
119 if (specificOnly) 119 if (specificOnly)
120 filterText += "$domain=" + docDomain; 120 filterText += "$domain=" + docDomain;
121 121
122 if (filters.indexOf(filterText) == -1) 122 if (!filters.includes(filterText))
123 filters.push(filterText); 123 filters.push(filterText);
124 } 124 }
125 } 125 }
126 126
127 // If we couldn't generate any blocking filters, fallback to element hiding 127 // If we couldn't generate any blocking filters, fallback to element hiding
128 if (filters.length == 0 && !checkWhitelisted(page, frame, 128 if (filters.length == 0 && !checkWhitelisted(page, frame,
129 RegExpFilter.typeMap.ELEMHIDE)) 129 RegExpFilter.typeMap.ELEMHIDE))
130 { 130 {
131 // Generate CSS selectors based on the element's "id" and 131 // Generate CSS selectors based on the element's "id" and
132 // "class" attribute. 132 // "class" attribute.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 page.sendMessage({type: "composer.content.contextMenuClicked"}); 174 page.sendMessage({type: "composer.content.contextMenuClicked"});
175 } 175 }
176 }; 176 };
177 177
178 function updateContextMenu(page, filter) 178 function updateContextMenu(page, filter)
179 { 179 {
180 page.contextMenus.remove(contextMenuItem); 180 page.contextMenus.remove(contextMenuItem);
181 181
182 if (typeof filter == "undefined") 182 if (typeof filter == "undefined")
183 filter = checkWhitelisted(page); 183 filter = checkWhitelisted(page);
184 if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) 184
185 // We don't support the filter composer on Firefox for Android, because the
186 // user experience on mobile is quite different.
187 if (info.application != "fennec" &&
188 !filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page))
189 {
185 page.contextMenus.create(contextMenuItem); 190 page.contextMenus.create(contextMenuItem);
186 } 191 }
187
188 function shouldDisable()
189 {
190 // Disable the composer if the browser is unknown or if it's
Manish Jethani 2017/08/15 23:50:06 We have to cover null and "unknown" as well, becau
191 // "Fennec" (Firefox for Android).
192 return !info.application || info.application == "unknown" ||
193 info.application == "fennec";
194 } 192 }
195 193
196 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); 194 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu);
197 195
198 Prefs.on("shouldShowBlockElementMenu", () => 196 Prefs.on("shouldShowBlockElementMenu", () =>
199 { 197 {
200 ext.pages.query({}, pages => 198 ext.pages.query({}, pages =>
201 { 199 {
202 for (let page of pages) 200 for (let page of pages)
203 updateContextMenu(page); 201 updateContextMenu(page);
204 }); 202 });
205 }); 203 });
206 204
207 port.on("composer.ready", (message, sender) => 205 port.on("composer.ready", (message, sender) =>
208 { 206 {
209 if (!shouldDisable()) 207 readyPages.set(sender.page, null);
210 readyPages.set(sender.page, null);
211
212 updateContextMenu(sender.page); 208 updateContextMenu(sender.page);
213 }); 209 });
214 210
215 port.on("composer.openDialog", (message, sender) => 211 port.on("composer.openDialog", (message, sender) =>
216 { 212 {
217 return new Promise(resolve => 213 return new Promise(resolve =>
218 { 214 {
219 ext.windows.create({ 215 ext.windows.create({
220 url: ext.getURL("composer.html"), 216 url: ext.getURL("composer.html"),
221 left: 50, 217 left: 50,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 }); 256 });
261 }); 257 });
262 258
263 port.on("composer.quoteCSS", (message, sender) => 259 port.on("composer.quoteCSS", (message, sender) =>
264 { 260 {
265 return quoteCSS(message.CSS); 261 return quoteCSS(message.CSS);
266 }); 262 });
267 263
268 ext.pages.onLoading.addListener(page => 264 ext.pages.onLoading.addListener(page =>
269 { 265 {
270 if (shouldDisable())
Manish Jethani 2017/08/15 23:50:06 If we simply cut off the communication between com
271 return;
272
273 page.sendMessage({type: "composer.content.finished"}); 266 page.sendMessage({type: "composer.content.finished"});
274 }); 267 });
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld