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

Unified Diff: lib/filterComposer.js

Issue 29511561: Issue 5347 - Check for contextMenus API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Use consistent style for feature detection Created Aug. 15, 2017, 4:38 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
« ext/background.js ('K') | « ext/background.js ('k') | 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
@@ -179,31 +179,36 @@
page.contextMenus.remove(contextMenuItem);
if (typeof filter == "undefined")
filter = checkWhitelisted(page);
if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page))
page.contextMenus.create(contextMenuItem);
}
-FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu);
-
-Prefs.on("shouldShowBlockElementMenu", () =>
+if ("contextMenus" in chrome)
{
- ext.pages.query({}, pages =>
+ FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu);
+
+ Prefs.on("shouldShowBlockElementMenu", () =>
{
- for (let page of pages)
- updateContextMenu(page);
+ ext.pages.query({}, pages =>
+ {
+ for (let page of pages)
+ updateContextMenu(page);
+ });
});
-});
+}
port.on("composer.ready", (message, sender) =>
{
readyPages.set(sender.page, null);
- updateContextMenu(sender.page);
+
+ if ("contextMenus" in chrome)
+ updateContextMenu(sender.page);
});
port.on("composer.openDialog", (message, sender) =>
{
return new Promise(resolve =>
{
ext.windows.create({
url: ext.getURL("composer.html"),
« ext/background.js ('K') | « ext/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld