From aa98d1eae0d22e015ec19bdb97c554d7d3a19b50 Mon Sep 17 00:00:00 2001 From: "tony%ponderer.org" Date: Tue, 25 Jul 2006 17:44:26 +0000 Subject: [PATCH] bug 345675: unwanted connection to www.google.com at startup with Safe Browsing disabled patch: don't get key if sb off, don't get whitelist tables if remote checking on r=mmchew,sr=bryner --- .../safebrowsing/content/globalstore.js | 12 ++++++++++- .../safebrowsing/content/phishing-warden.js | 21 ++++--------------- .../url-classifier/content/listmanager.js | 8 ++++++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/browser/components/safebrowsing/content/globalstore.js b/browser/components/safebrowsing/content/globalstore.js index 6d0727d620ae..4af0d5a31ce5 100644 --- a/browser/components/safebrowsing/content/globalstore.js +++ b/browser/components/safebrowsing/content/globalstore.js @@ -66,6 +66,10 @@ function PROT_DataProvider() { // Watch for changes in the data provider and update accordingly. this.prefs_.addObserver(kDataProviderIdPref, BindToObject(this.loadDataProviderPrefs_, this)); + + // Watch for when anti-phishing is toggled on or off. + this.prefs_.addObserver(kPhishWardenEnabledPref, + BindToObject(this.loadDataProviderPrefs_, this)); } /** @@ -114,7 +118,13 @@ PROT_DataProvider.prototype.updateListManager_ = function() { // pref observer that sets the update url accordingly. listManager.setUpdateUrl(this.getUpdateURL()); - listManager.setKeyUrl(this.getKeyURL()); + // setKeyUrl has the side effect of fetching a key from the server. + // This shouldn't happen if anti-phishing is disabled, so we need to + // check for that. + var isEnabled = this.prefs_.getPref(kPhishWardenEnabledPref, false); + if (isEnabled) { + listManager.setKeyUrl(this.getKeyURL()); + } } /** diff --git a/browser/components/safebrowsing/content/phishing-warden.js b/browser/components/safebrowsing/content/phishing-warden.js index 6f4c5fbb227e..741c8118f04d 100644 --- a/browser/components/safebrowsing/content/phishing-warden.js +++ b/browser/components/safebrowsing/content/phishing-warden.js @@ -180,24 +180,11 @@ PROT_PhishingWarden.prototype.maybeToggleUpdateChecking = function() { return; // We update and save to disk all tables if we don't have remote checking - // enabled. However, as long as the warden is enabled we always update the - // whitelist, even if remote checking is disabled. This gives a performance - // benefit since we use the WL to suppress BL lookups. - // - // phishEnabled remote WLupdates BLupdates - // T T T F - // T F T T - // F T F F - // F F F F - - if (phishWardenEnabled === true) { + // enabled. + if (phishWardenEnabled === true && this.checkRemote_ === false) { + this.enableBlacklistTableUpdates(); this.enableWhitelistTableUpdates(); - if (this.checkRemote_ === true) { - this.disableBlacklistTableUpdates(); - } else if (this.checkRemote_ === false) { - this.enableBlacklistTableUpdates(); - } - } else if (phishWardenEnabled === false) { + } else { this.disableBlacklistTableUpdates(); this.disableWhitelistTableUpdates(); } diff --git a/toolkit/components/url-classifier/content/listmanager.js b/toolkit/components/url-classifier/content/listmanager.js index 6533ab3b552a..48e39044aa6c 100644 --- a/toolkit/components/url-classifier/content/listmanager.js +++ b/toolkit/components/url-classifier/content/listmanager.js @@ -268,12 +268,13 @@ PROT_ListManager.prototype.maybeToggleUpdateChecking = function() { // are no tables that want to be updated - we dont need to check anything. if (this.requireTableUpdates() === true) { G_Debug(this, "Starting managing lists"); + this.startUpdateChecker(); + // Multiple warden can ask us to reenable updates at the same time, but we // really just need to schedule a single update. if (!this.currentUpdateChecker_) this.currentUpdateChecker_ = new G_Alarm(BindToObject(this.checkForUpdates, this), 3000); - this.startUpdateChecker(); } else { G_Debug(this, "Stopping managing lists (if currently active)"); this.stopUpdateChecker(); // Cancel pending updates @@ -301,6 +302,11 @@ PROT_ListManager.prototype.stopUpdateChecker = function() { this.updateChecker_.cancel(); this.updateChecker_ = null; } + // Cancel the oneoff check from maybeToggleUpdateChecking. + if (this.currentUpdateChecker_) { + this.currentUpdateChecker_.cancel(); + this.currentUpdateChecker_ = null; + } } /**