From eabff34dcc0d36f197b9584ce6ee4a66d3663018 Mon Sep 17 00:00:00 2001 From: "shliang%netscape.com" Date: Wed, 17 May 2006 02:37:03 +0000 Subject: [PATCH] 192193 - preload popup blocking whitelist. r=danm, sr=jag --- suite/common/pref/pref-popups.xul | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/suite/common/pref/pref-popups.xul b/suite/common/pref/pref-popups.xul index 7f1054e8997..a2c7ef6eddb 100644 --- a/suite/common/pref/pref-popups.xul +++ b/suite/common/pref/pref-popups.xul @@ -73,8 +73,41 @@ gIconCheckbox = document.getElementById("displayIcon"); setButtons(); + + var prefillWhitelist = (document.getElementById("prefillWhitelist").getAttribute("value") == "true"); + if (prefillWhitelist) { + loadWhitelist(); + document.getElementById("prefillWhitelist").setAttribute("value", false); + } } + function loadWhitelist() { + try { + var whitelist; + var hosts; + var prefService = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + var prefs = prefService.getBranch(null); + whitelist = prefs.getComplexValue("privacy.popups.default_whitelist", + Components.interfaces.nsIPrefLocalizedString).data; + hosts = whitelist.split(","); + + var popupmanager = Components.classes["@mozilla.org/PopupWindowManager;1"] + .getService(Components.interfaces.nsIPopupWindowManager); + var ioService = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + + for (var i = 0; i < hosts.length; i++) { + var host = hosts[i]; + host = "http://" + host; + var uri = ioService.newURI(host, null, null); + popupmanager.add(uri, true); + } + } + catch (ex) { } + } + + function blacklistEmpty() { var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"] .getService(Components.interfaces.nsIPermissionManager); @@ -187,6 +220,7 @@ &popupNote.description; +