From 1cfab001c3c74da125b41610da6a2cb3536e8264 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Fri, 1 Jul 2011 19:32:06 -0700 Subject: [PATCH] Bug 668699: If urlclassifier is turned off, do not open the database. r=dcamp --- .../url-classifier/nsUrlClassifierDBService.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 8d1d7bb362bc..a35f6f8e6995 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -77,6 +77,7 @@ #include "prprf.h" #include "prnetdb.h" #include "zlib.h" +#include "mozilla/Preferences.h" // Needed to interpert mozIStorageConnection::GetLastError #include @@ -1798,7 +1799,6 @@ nsUrlClassifierDBServiceWorker::GetTables(nsIUrlClassifierCallback* c) nsresult rv = OpenDb(); if (NS_FAILED(rv)) { - NS_ERROR("Unable to open database"); return NS_ERROR_FAILURE; } @@ -2913,7 +2913,6 @@ nsUrlClassifierDBServiceWorker::BeginUpdate(nsIUrlClassifierUpdateObserver *obse nsresult rv = OpenDb(); if (NS_FAILED(rv)) { - NS_ERROR("Unable to open database"); return NS_ERROR_FAILURE; } @@ -3061,7 +3060,6 @@ nsUrlClassifierDBServiceWorker::UpdateStream(const nsACString& chunk) LOG(("Update from Stream.")); nsresult rv = OpenDb(); if (NS_FAILED(rv)) { - NS_ERROR("Unable to open database"); return NS_ERROR_FAILURE; } @@ -3367,6 +3365,15 @@ nsUrlClassifierDBServiceWorker::OpenDb() if (mConnection) return NS_OK; + // If we're turned off, refuse to open the DB + PRBool openDB = + Preferences::GetBool(CHECK_MALWARE_PREF, CHECK_MALWARE_DEFAULT) || + Preferences::GetBool(CHECK_PHISHING_PREF, CHECK_PHISHING_DEFAULT); + if (!openDB) { + NS_WARNING("Not opening url-classifier DB"); + return NS_ERROR_NOT_AVAILABLE; + } + LOG(("Opening db\n")); nsresult rv;