Bug 1100024: ClassifyLocal should not lookup in any tables if safebrowsing is disabled (r=gcp)
authorMonica Chew <mmc@mozilla.com>
Fri, 09 Jan 2015 13:25:02 -0800
changeset 223129 6c8be2f5b065ea8f72082b7d7cdbe53f0f53b9f6
parent 223128 311c6349e630d72a4eb2396db21a1a0afb6b3b42
child 223130 671ad56e6e12927323e4d89d0076e7c04f58b55c
push id10769
push usercbook@mozilla.com
push dateMon, 12 Jan 2015 14:15:52 +0000
treeherderfx-team@0e9765732906 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1100024
milestone37.0a1
Bug 1100024: ClassifyLocal should not lookup in any tables if safebrowsing is disabled (r=gcp)
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
toolkit/components/url-classifier/nsUrlClassifierDBService.h
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1264,27 +1264,29 @@ nsUrlClassifierDBService::Init()
     return NS_ERROR_FAILURE;
 
   observerService->AddObserver(this, "profile-before-change", false);
   observerService->AddObserver(this, "xpcom-shutdown-threads", false);
 
   return NS_OK;
 }
 
-static void BuildTables(bool aTrackingProtectionEnabled, nsCString &tables)
+void
+nsUrlClassifierDBService::BuildTables(bool aTrackingProtectionEnabled,
+                                      nsCString &tables)
 {
   nsAutoCString malware;
   // LookupURI takes a comma-separated list already.
   Preferences::GetCString(MALWARE_TABLE_PREF, &malware);
-  if (!malware.IsEmpty()) {
+  if (mCheckMalware && !malware.IsEmpty()) {
     tables.Append(malware);
   }
   nsAutoCString phishing;
   Preferences::GetCString(PHISH_TABLE_PREF, &phishing);
-  if (!phishing.IsEmpty()) {
+  if (mCheckPhishing && !phishing.IsEmpty()) {
     tables.Append(',');
     tables.Append(phishing);
   }
   nsAutoCString tracking;
   Preferences::GetCString(TRACKING_TABLE_PREF, &tracking);
   if (aTrackingProtectionEnabled && !tracking.IsEmpty()) {
     tables.Append(',');
     tables.Append(tracking);
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.h
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.h
@@ -82,16 +82,19 @@ private:
 
   // Check if the key is on a known-clean host.
   nsresult CheckClean(const nsACString &lookupKey,
                       bool *clean);
 
   // Read everything into mGethashTables and mDisallowCompletionTables
   nsresult ReadTablesFromPrefs();
 
+  // Build a comma-separated list of tables to check
+  void BuildTables(bool trackingProtectionEnabled, nsCString& tables);
+
   nsRefPtr<nsUrlClassifierDBServiceWorker> mWorker;
   nsCOMPtr<nsIUrlClassifierDBServiceWorker> mWorkerProxy;
 
   nsInterfaceHashtable<nsCStringHashKey, nsIUrlClassifierHashCompleter> mCompleters;
 
   // TRUE if the nsURIClassifier implementation should check for malware
   // uris on document loads.
   bool mCheckMalware;