Bug 388652 - "remove code that supports deprecated "/lookup" request in SafeBrowsing protocol" [p=dcamp@mozilla.com (Dave Camp) r=tony a=blocking-firefox3+]
This commit is contained in:
@@ -104,218 +104,6 @@ var gSecurityPane = {
|
||||
permissionType: "install"
|
||||
},
|
||||
|
||||
// PHISHING
|
||||
|
||||
/*
|
||||
* Preferences:
|
||||
*
|
||||
* browser.safebrowsing.enabled
|
||||
* - true if phishing checks of all visited sites are enabled, false if
|
||||
* such checks are disabled
|
||||
* browser.safebrowsing.remoteLookups
|
||||
* - true if every site is checked against a remote phishing provider for
|
||||
* safety on load, false if a cached list should be used instead
|
||||
* browser.safebrowsing.dataProvider
|
||||
* - integer identifying the current anti-phishing provider in use
|
||||
* browser.safebrowsing.provider.<number>.<property>
|
||||
* - identifies each installed Safe Browsing provider; the provider's name is
|
||||
* stored in the "name" property, and the various URLs used in Safe Browsing
|
||||
* detection comprise the values of the rest of the properties
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables/disables the UI for the type of phishing detection used based on
|
||||
* whether phishing detection is enabled.
|
||||
*/
|
||||
readCheckPhish: function ()
|
||||
{
|
||||
var phishEnabled = document.getElementById("browser.safebrowsing.enabled").value;
|
||||
|
||||
var checkPhish = document.getElementById("checkPhishChoice");
|
||||
var loadList = document.getElementById("onloadProvider");
|
||||
var onloadAfter = document.getElementById("onloadAfter");
|
||||
|
||||
checkPhish.disabled = onloadAfter.disabled = !phishEnabled;
|
||||
loadList.disabled = !phishEnabled;
|
||||
|
||||
// don't override pref value
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays the currently-used phishing provider's EULA and offers the user
|
||||
* the choice of cancelling the enabling of phishing, but only if the user has
|
||||
* not previously agreed to the provider's EULA before.
|
||||
*
|
||||
* @param providerNum
|
||||
* the number of the provider whose policy should be displayed
|
||||
* @returns bool
|
||||
* true if the user still wants to enable phishing protection with
|
||||
* the current provider, false otherwise
|
||||
*/
|
||||
_userAgreedToPhishingEULA: function (providerNum)
|
||||
{
|
||||
// create the opt-in preference element for the provider
|
||||
const prefName = "browser.safebrowsing.provider." +
|
||||
providerNum +
|
||||
".privacy.optedIn";
|
||||
var pref = document.getElementById(prefName);
|
||||
|
||||
if (!pref) {
|
||||
pref = document.createElement("preference");
|
||||
pref.setAttribute("type", "bool");
|
||||
pref.id = prefName;
|
||||
pref.setAttribute("name", prefName);
|
||||
document.getElementById("securityPreferences").appendChild(pref);
|
||||
}
|
||||
|
||||
// only show privacy policy if it hasn't already been shown or the user
|
||||
// hasn't agreed to it
|
||||
if (!pref.value) {
|
||||
var rv = { userAgreed: false, providerNum: providerNum };
|
||||
document.documentElement.openSubDialog("chrome://browser/content/preferences/phishEULA.xul",
|
||||
"resizable", rv);
|
||||
|
||||
// mark this provider as having had its privacy policy accepted if it was
|
||||
if (rv.userAgreed)
|
||||
pref.value = true;
|
||||
|
||||
return rv.userAgreed;
|
||||
}
|
||||
|
||||
// user has previously agreed
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays a privacy policy if the user enables onload anti-phishing
|
||||
* checking. The policy must be accepted if onload checking is to be enabled,
|
||||
* and if it isn't we revert to downloaded list-based checking.
|
||||
*/
|
||||
writePhishChoice: function ()
|
||||
{
|
||||
var radio = document.getElementById("checkPhishChoice");
|
||||
var provider = document.getElementById("browser.safebrowsing.dataProvider");
|
||||
|
||||
// display a privacy policy if onload checking is being enabled
|
||||
if (radio.value == "true" &&
|
||||
!this._userAgreedToPhishingEULA(provider.value)) {
|
||||
radio.value = "false";
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't override pref value
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures that the user has agreed to the selected provider's privacy policy
|
||||
* if safe browsing is enabled.
|
||||
*/
|
||||
onSBChange: function ()
|
||||
{
|
||||
var phishEnabled = document.getElementById("browser.safebrowsing.enabled").value;
|
||||
var remoteLookup = document.getElementById("browser.safebrowsing.remoteLookups");
|
||||
var providerNum = document.getElementById("onloadProvider").value;
|
||||
|
||||
if (phishEnabled && remoteLookup.value &&
|
||||
!this._userAgreedToPhishingEULA(providerNum))
|
||||
remoteLookup.value = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Populates the menulist of providers of cached phishing lists if the
|
||||
* menulist isn't already populated.
|
||||
*/
|
||||
readOnloadPhishProvider: function ()
|
||||
{
|
||||
const Cc = Components.classes, Ci = Components.interfaces;
|
||||
const onloadPopupId = "onloadPhishPopup";
|
||||
var popup = document.getElementById(onloadPopupId);
|
||||
|
||||
if (!popup) {
|
||||
var providerBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService).
|
||||
getBranch("browser.safebrowsing.provider.");
|
||||
|
||||
// fill in onload phishing list data -- but require a privacy policy
|
||||
// URL be provided, and require it to be at a chrome URL so it's always
|
||||
// available
|
||||
var kids = providerBranch.getChildList("", {});
|
||||
var providers = [];
|
||||
var hasPrivacyPolicy = {};
|
||||
for (var i = 0; i < kids.length; i++) {
|
||||
var curr = kids[i];
|
||||
var matchesName = curr.match(/^(\d+)\.name$/);
|
||||
var matchesPolicy = curr.match(/^(\d+)\.privacy\.url$/);
|
||||
|
||||
// skip preferences which aren't names or privacy URLs
|
||||
if (!matchesName && !matchesPolicy)
|
||||
continue;
|
||||
|
||||
if (matchesName)
|
||||
providers.push(matchesName[1]);
|
||||
else
|
||||
hasPrivacyPolicy[matchesPolicy[1]] = true;
|
||||
}
|
||||
|
||||
// construct the menu only from the providers with policies
|
||||
for (var i = 0; i < providers.length; i++) {
|
||||
// skip providers without a privacy policy
|
||||
if (!(providers[i] in hasPrivacyPolicy))
|
||||
continue;
|
||||
|
||||
// ensure privacy URL is a chrome URL
|
||||
try {
|
||||
var providerNum = providers[i];
|
||||
var url = providerBranch.getCharPref(providerNum + ".privacy.url");
|
||||
var fallbackurl = providerBranch.getCharPref(providerNum +
|
||||
".privacy.fallbackurl");
|
||||
var scheme = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
extractScheme(fallbackurl);
|
||||
if (scheme != "chrome")
|
||||
throw "fallbackurl scheme must be chrome";
|
||||
}
|
||||
catch (e) {
|
||||
// don't add this provider
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!popup) {
|
||||
popup = document.createElement("menupopup");
|
||||
popup.id = onloadPopupId;
|
||||
}
|
||||
|
||||
var providerName = providerBranch.getCharPref(providerNum + ".name");
|
||||
|
||||
var item = document.createElement("menuitem");
|
||||
item.setAttribute("value", providerNum);
|
||||
item.setAttribute("label", providerName);
|
||||
item.setAttribute("oncommand", "gSecurityPane.onProviderChanged();");
|
||||
popup.appendChild(item);
|
||||
}
|
||||
|
||||
var onloadProviders = document.getElementById("onloadProvider");
|
||||
onloadProviders.appendChild(popup);
|
||||
}
|
||||
|
||||
// don't override the preference value in determining the right menuitem
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Requires that the user agree to the new phishing provider's EULA when the
|
||||
* provider is changed, disabling protection if the user doesn't agree.
|
||||
*/
|
||||
onProviderChanged: function ()
|
||||
{
|
||||
var pref = document.getElementById("browser.safebrowsing.dataProvider");
|
||||
var remoteLookup = document.getElementById("browser.safebrowsing.remoteLookups");
|
||||
|
||||
remoteLookup.value = this._userAgreedToPhishingEULA(pref.value);
|
||||
},
|
||||
|
||||
// PASSWORDS
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user