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

Unified Diff: lib/popupBlocker.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency Created Oct. 17, 2017, 1:02 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 | « lib/options.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/popupBlocker.js
===================================================================
--- a/lib/popupBlocker.js
+++ b/lib/popupBlocker.js
@@ -28,20 +28,20 @@
let loadingPopups = new Map();
function forgetPopup(tabId)
{
loadingPopups.delete(tabId);
if (loadingPopups.size == 0)
{
- chrome.webRequest.onBeforeRequest.removeListener(onPopupURLChanged);
- chrome.webNavigation.onCommitted.removeListener(onPopupURLChanged);
- chrome.webNavigation.onCompleted.removeListener(onCompleted);
- chrome.tabs.onRemoved.removeListener(forgetPopup);
+ browser.webRequest.onBeforeRequest.removeListener(onPopupURLChanged);
+ browser.webNavigation.onCommitted.removeListener(onPopupURLChanged);
+ browser.webNavigation.onCompleted.removeListener(onCompleted);
+ browser.tabs.onRemoved.removeListener(forgetPopup);
}
}
function checkPotentialPopup(tabId, popup)
{
let urlObj = new URL(popup.url || "about:blank");
let urlString = stringifyURL(urlObj);
let documentHost = extractHostFromFrame(popup.sourceFrame);
@@ -53,17 +53,17 @@
);
let filter = defaultMatcher.matchesAny(
urlString, RegExpFilter.typeMap.POPUP,
documentHost, thirdParty, null, specificOnly
);
if (filter instanceof BlockingFilter)
- chrome.tabs.remove(tabId);
+ browser.tabs.remove(tabId);
logRequest(
popup.sourcePage, urlString, "POPUP",
documentHost, thirdParty, null,
specificOnly, filter
);
}
@@ -86,32 +86,32 @@
{
if (details.frameId == 0 && details.url != "about:blank")
forgetPopup(details.tabId);
}
// Versions of Firefox before 54 do not support
// webNavigation.onCreatedNavigationTarget
// https://bugzilla.mozilla.org/show_bug.cgi?id=1190687
-if ("onCreatedNavigationTarget" in chrome.webNavigation)
+if ("onCreatedNavigationTarget" in browser.webNavigation)
{
- chrome.webNavigation.onCreatedNavigationTarget.addListener(details =>
+ browser.webNavigation.onCreatedNavigationTarget.addListener(details =>
{
if (loadingPopups.size == 0)
{
- chrome.webRequest.onBeforeRequest.addListener(
+ browser.webRequest.onBeforeRequest.addListener(
onPopupURLChanged,
{
urls: ["http://*/*", "https://*/*"],
types: ["main_frame"]
}
);
- chrome.webNavigation.onCommitted.addListener(onPopupURLChanged);
- chrome.webNavigation.onCompleted.addListener(onCompleted);
- chrome.tabs.onRemoved.addListener(forgetPopup);
+ browser.webNavigation.onCommitted.addListener(onPopupURLChanged);
+ browser.webNavigation.onCompleted.addListener(onCompleted);
+ browser.tabs.onRemoved.addListener(forgetPopup);
}
let popup = {
url: details.url,
sourcePage: new ext.Page({id: details.sourceTabId}),
sourceFrame: null
};
« no previous file with comments | « lib/options.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld