Bug 668699: If urlclassifier is turned off, do not open the database. r=dcamp

This commit is contained in:
Kyle Huey 2011-07-01 19:32:06 -07:00
Родитель d9c62ff95b
Коммит 1cfab001c3
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -77,6 +77,7 @@
#include "prprf.h"
#include "prnetdb.h"
#include "zlib.h"
#include "mozilla/Preferences.h"
// Needed to interpert mozIStorageConnection::GetLastError
#include <sqlite3.h>
@ -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;