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

Unified Diff: 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/
Patch Set: Created Aug. 15, 2017, 11:40 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterComposer.js
===================================================================
--- a/lib/filterComposer.js
+++ b/lib/filterComposer.js
@@ -21,16 +21,17 @@
const {defaultMatcher} = require("matcher");
const {RegExpFilter} = require("filterClasses");
const {FilterNotifier} = require("filterNotifier");
const {Prefs} = require("prefs");
const {extractHostFromFrame, stringifyURL, isThirdParty} = require("url");
const {getKey, checkWhitelisted} = require("whitelisting");
const {port} = require("messaging");
+const info = require("info");
let readyPages = new ext.PageMap();
/**
* Checks whether the given page is ready to use the filter composer
*
* @param {Page} page
* @return {boolean}
@@ -179,30 +180,40 @@
page.contextMenus.remove(contextMenuItem);
if (typeof filter == "undefined")
filter = checkWhitelisted(page);
if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page))
page.contextMenus.create(contextMenuItem);
}
+function shouldDisable()
+{
+ // 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
+ // "Fennec" (Firefox for Android).
+ return !info.application || info.application == "unknown" ||
+ info.application == "fennec";
+}
+
FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu);
Prefs.on("shouldShowBlockElementMenu", () =>
{
ext.pages.query({}, pages =>
{
for (let page of pages)
updateContextMenu(page);
});
});
port.on("composer.ready", (message, sender) =>
{
- readyPages.set(sender.page, null);
+ if (!shouldDisable())
+ readyPages.set(sender.page, null);
+
updateContextMenu(sender.page);
});
port.on("composer.openDialog", (message, sender) =>
{
return new Promise(resolve =>
{
ext.windows.create({
@@ -251,10 +262,13 @@
port.on("composer.quoteCSS", (message, sender) =>
{
return quoteCSS(message.CSS);
});
ext.pages.onLoading.addListener(page =>
{
+ if (shouldDisable())
Manish Jethani 2017/08/15 23:50:06 If we simply cut off the communication between com
+ return;
+
page.sendMessage({type: "composer.content.finished"});
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld