Skip to content

Commit 9ff8cd4

Browse files
author
Jono Xia
committed
Added a banner-style notification at the top of the page when Collusion blocks third-party content on a site. (The Options button is not implemented yet, so at the moment there's nothing you can do with this banner - it's just a placeholder.)
1 parent 691684b commit 9ff8cd4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,31 @@ function initCollusion() {
469469
console.log("Blocking page load of blocklisted site " + domain);
470470
channel.loadFlags = Ci.nsICachingChannel.LOAD_ONLY_FROM_CACHE;
471471
channel.cancel(Cr.NS_ERROR_FAILURE);
472+
473+
// Pop a banner notification that content was blocked, with an "allow" button.
474+
var message = "Collusion has blocked third-party content on this site";
475+
var popupButtonText = "Options";
476+
var popupButtonAccesskey = "O";
477+
var windowUtils = require("window-utils");
478+
var window = windowUtils.activeBrowserWindow;
479+
var thistab = window.gBrowser.mCurrrentBrowser;
480+
var notificationBox = window.gBrowser.getNotificationBox(thistab);
481+
var notification = notificationBox.getNotificationWithValue("popup-blocked");
482+
if (notification) {
483+
notification.label = message;
484+
} else {
485+
var buttons = [{
486+
label: popupButtonText,
487+
accessKey: popupButtonAccesskey,
488+
popup: "blockedPopupOptions",
489+
callback: null
490+
}];
491+
492+
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
493+
notificationBox.appendNotification(message, "popup-blocked",
494+
"chrome://browser/skin/Info.png",
495+
priority, buttons);
496+
}
472497
}
473498
});
474499

0 commit comments

Comments
 (0)