Backout 83e0b185e888 (bug 778606) due to orange.

This commit is contained in:
Ryan VanderMeulen 2012-07-30 20:14:29 -04:00
parent 26da6164d3
commit a3de6dea15
5 changed files with 77 additions and 39 deletions

View File

@ -715,12 +715,34 @@ pref("gecko.handlerService.schemes.ircs.3.uriTemplate", "chrome://browser-region
pref("gecko.handlerService.allowRegisterFromDifferentHost", false);
#ifdef MOZ_SAFE_BROWSING
// Safe browsing does nothing unless this pref is set
pref("browser.safebrowsing.enabled", true);
// Prevent loading of pages identified as malware
pref("browser.safebrowsing.malware.enabled", true);
// Debug logging to error console
pref("browser.safebrowsing.debug", false);
// Non-enhanced mode (local url lists) URL list to check for updates
pref("browser.safebrowsing.provider.0.updateURL", "http://safebrowsing.clients.google.com/safebrowsing/downloads?client={moz:client}&appver={moz:version}&pver=2.2");
pref("browser.safebrowsing.dataProvider", 0);
// Does the provider name need to be localizable?
pref("browser.safebrowsing.provider.0.name", "Google");
pref("browser.safebrowsing.provider.0.keyURL", "https://sb-ssl.google.com/safebrowsing/newkey?client={moz:client}&appver={moz:version}&pver=2.2");
pref("browser.safebrowsing.provider.0.reportURL", "http://safebrowsing.clients.google.com/safebrowsing/report?");
pref("browser.safebrowsing.provider.0.gethashURL", "http://safebrowsing.clients.google.com/safebrowsing/gethash?client={moz:client}&appver={moz:version}&pver=2.2");
// HTML report pages
pref("browser.safebrowsing.provider.0.reportGenericURL", "http://{moz:locale}.phish-generic.mozilla.com/?hl={moz:locale}");
pref("browser.safebrowsing.provider.0.reportErrorURL", "http://{moz:locale}.phish-error.mozilla.com/?hl={moz:locale}");
pref("browser.safebrowsing.provider.0.reportPhishURL", "http://{moz:locale}.phish-report.mozilla.com/?hl={moz:locale}");
pref("browser.safebrowsing.provider.0.reportMalwareURL", "http://{moz:locale}.malware-report.mozilla.com/?hl={moz:locale}");
pref("browser.safebrowsing.provider.0.reportMalwareErrorURL", "http://{moz:locale}.malware-error.mozilla.com/?hl={moz:locale}");
// FAQ URLs
pref("browser.safebrowsing.warning.infoURL", "http://www.mozilla.com/%LOCALE%/firefox/phishing-protection/");
pref("browser.geolocation.warning.infoURL", "http://www.mozilla.com/%LOCALE%/firefox/geolocation/");

View File

@ -13,6 +13,10 @@ include $(DEPTH)/config/autoconf.mk
TEST_DIRS += content/test
ifdef MOZILLA_OFFICIAL
DEFINES += -DOFFICIAL_BUILD=1
endif
EXTRA_PP_JS_MODULES = \
SafeBrowsing.jsm \
$(NULL)

View File

@ -13,18 +13,6 @@ Cu.import("resource://gre/modules/Services.jsm");
const phishingList = "goog-phish-shavar";
const malwareList = "goog-malware-shavar";
var urlList = {
updateURL: "http://safebrowsing.clients.google.com/safebrowsing/downloads?client=%SAFEBROWSING_ID%&appver=%VERSION%&pver=2.2",
keyURL: "https://sb-ssl.google.com/safebrowsing/newkey?client=%SAFEBROWSING_ID%&appver=%VERSION%&pver=2.2",
reportURL: "http://safebrowsing.clients.google.com/safebrowsing/report?",
gethashURL: "http://safebrowsing.clients.google.com/safebrowsing/gethash?client=%SAFEBROWSING_ID%&appver=%VERSION%&pver=2.2",
reportGenericURL: "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%",
reportErrorURL: "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%",
reportPhishURL: "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%",
reportMalwareURL: "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%",
reportMalwareErrorURL: "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%",
};
var debug = false;
function log(...stuff) {
if (!debug)
@ -37,16 +25,12 @@ function log(...stuff) {
var SafeBrowsing = {
init: function(customURLs) {
init: function() {
if (this.initialized) {
log("Already initialized");
return;
}
// Allow tests to specify local urls for testing against a local server.
if (customURLs)
urlList = customURLs;
Services.prefs.addObserver("browser.safebrowsing", this.readPrefs, false);
this.readPrefs();
@ -79,6 +63,7 @@ var SafeBrowsing = {
phishingEnabled: false,
malwareEnabled: false,
provName: null,
updateURL: null,
keyURL: null,
reportURL: null,
@ -120,20 +105,57 @@ var SafeBrowsing = {
return;
}
// The following URLs were once prefs, "browser.safebrowsing.provider.0.*"
let basePref = "browser.safebrowsing.provider.0.";
this.provName = Services.prefs.getCharPref(basePref + "name");
// Urls used to get data from a provider
this.updateURL = Services.urlFormatter.formatURL(urlList["updateURL"]);
this.keyURL = Services.urlFormatter.formatURL(urlList["keyURL"]);
this.reportURL = Services.urlFormatter.formatURL(urlList["reportURL"]);
this.gethashURL = Services.urlFormatter.formatURL(urlList["gethashURL"]);
this.updateURL = this.getUrlPref(basePref + "updateURL");
this.keyURL = this.getUrlPref(basePref + "keyURL");
this.reportURL = this.getUrlPref(basePref + "reportURL");
this.gethashURL = this.getUrlPref(basePref + "gethashURL");
// Urls to HTML report pages
this.reportGenericURL = Services.urlFormatter.formatURL(urlList["reportGenericURL"]);
this.reportErrorURL = Services.urlFormatter.formatURL(urlList["reportErrorURL"]);
this.reportPhishURL = Services.urlFormatter.formatURL(urlList["reportPhishURL"]);
this.reportMalwareURL = Services.urlFormatter.formatURL(urlList["reportMalwareURL"]);
this.reportMalwareErrorURL = Services.urlFormatter.formatURL(urlList["reportMalwareErrorURL"]);
this.reportGenericURL = this.getUrlPref(basePref + "reportGenericURL");
this.reportErrorURL = this.getUrlPref(basePref + "reportErrorURL");
this.reportPhishURL = this.getUrlPref(basePref + "reportPhishURL");
this.reportMalwareURL = this.getUrlPref(basePref + "reportMalwareURL")
this.reportMalwareErrorURL = this.getUrlPref(basePref + "reportMalwareErrorURL")
},
getUrlPref: function(prefName) {
let MOZ_OFFICIAL_BUILD = false;
#ifdef OFFICIAL_BUILD
MOZ_OFFICIAL_BUILD = true;
#endif
let url = Services.prefs.getCharPref(prefName);
let clientName = MOZ_OFFICIAL_BUILD ? "navclient-auto-ffox" : Services.appinfo.name;
let clientVersion = Services.appinfo.version;
// Parameter substitution
// XXX: we should instead use nsIURLFormatter here.
url = url.replace(/\{moz:locale\}/g, this.getLocale());
url = url.replace(/\{moz:client\}/g, clientName);
url = url.replace(/\{moz:buildid\}/g, Services.appinfo.appBuildID);
url = url.replace(/\{moz:version\}/g, clientVersion);
log(prefName, "is", url);
return url;
},
getLocale: function() {
const localePref = "general.useragent.locale";
let locale = Services.prefs.getCharPref(localePref);
try {
// Dumb. This API only works if pref is localized or has a user value.
locale = Services.prefs.getComplexValue(localePref, Ci.nsIPrefLocalizedString).data;
} catch (e) { }
return locale;
},

View File

@ -1,3 +1,4 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -11,10 +12,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = urlformatter
ifdef MOZILLA_OFFICIAL
DEFINES += -DOFFICIAL_BUILD=1
endif
XPIDLSRCS = \
nsIURLFormatter.idl \
$(NULL)

View File

@ -24,12 +24,6 @@ const PREF_PARTNER_BRANCH = "app.partner.";
const PREF_APP_DISTRIBUTION = "distribution.id";
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version";
#ifdef OFFICIAL_BUILD
const MOZ_OFFICIAL_BUILD = true;
#else
const MOZ_OFFICIAL_BUILD = false;
#endif
function nsURLFormatterService() {
XPCOMUtils.defineLazyGetter(this, "appInfo", function UFS_appInfo() {
return Cc["@mozilla.org/xre/app-info;1"].
@ -127,8 +121,7 @@ nsURLFormatterService.prototype = {
OS_VERSION: function() this.OSVersion,
CHANNEL: function() this.updateChannel,
DISTRIBUTION: function() this.distribution.id,
DISTRIBUTION_VERSION: function() this.distribution.version,
SAFEBROWSING_ID: function() MOZ_OFFICIAL_BUILD ? "navclient-auto-ffox" : this.appInfo.name,
DISTRIBUTION_VERSION: function() this.distribution.version
},
formatURL: function uf_formatURL(aFormat) {