diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 501949660629..b718aa861fe2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -7467,8 +7467,9 @@ nsDocShell::CheckClassifier(nsIChannel *aChannel) classifier->SetChannel(aChannel); nsresult rv = classifier->Run(); - if (rv == NS_ERROR_FACTORY_NOT_REGISTERED) { - // no URI classifier, ignore this + if (rv == NS_ERROR_FACTORY_NOT_REGISTERED || + rv == NS_ERROR_NOT_AVAILABLE) { + // no URI classifier => ignored cases return NS_OK; } NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp index 4da2431a38d9..e561d8303877 100644 --- a/toolkit/components/build/nsToolkitCompsModule.cpp +++ b/toolkit/components/build/nsToolkitCompsModule.cpp @@ -86,10 +86,27 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind) #ifdef MOZ_URL_CLASSIFIER -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsUrlClassifierDBService, - nsUrlClassifierDBService::GetInstance) NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierStreamUpdater) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlClassifierUtils, Init) + +static NS_IMETHODIMP +nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + nsresult rv; + NS_ENSURE_ARG_POINTER(aResult); + NS_ENSURE_NO_AGGREGATION(aOuter); + + nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv); + if (NULL == inst) { + return rv; + } + /* NS_ADDREF(inst); */ + rv = inst->QueryInterface(aIID, aResult); + NS_RELEASE(inst); + + return rv; +} #endif #ifdef MOZ_FEEDS diff --git a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp index 8b2e55d39b53..5f6db37f8452 100644 --- a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp @@ -650,7 +650,13 @@ nsUrlClassifierDBServiceWorker::Init() // portable between machine types, so store it in the local profile dir. nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, getter_AddRefs(mDBFile)); - if (NS_FAILED(rv)) return rv; + + if (NS_FAILED(rv)) { + rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, + getter_AddRefs(mDBFile)); + } + + if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE; rv = mDBFile->Append(NS_LITERAL_STRING(DATABASE_FILENAME)); NS_ENSURE_SUCCESS(rv, rv); @@ -2266,16 +2272,20 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsUrlClassifierDBService, nsIObserver) /* static */ nsUrlClassifierDBService* -nsUrlClassifierDBService::GetInstance() +nsUrlClassifierDBService::GetInstance(nsresult *result) { + *result = NS_OK; if (!sUrlClassifierDBService) { sUrlClassifierDBService = new nsUrlClassifierDBService(); - if (!sUrlClassifierDBService) + if (!sUrlClassifierDBService) { + *result = NS_ERROR_OUT_OF_MEMORY; return nsnull; + } NS_ADDREF(sUrlClassifierDBService); // addref the global - if (NS_FAILED(sUrlClassifierDBService->Init())) { + *result = sUrlClassifierDBService->Init(); + if (NS_FAILED(*result)) { NS_RELEASE(sUrlClassifierDBService); return nsnull; } diff --git a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.h b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.h index 6f47ef9e7aa4..7c922bec99ce 100644 --- a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.h +++ b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.h @@ -61,7 +61,7 @@ public: nsresult Init(); - static nsUrlClassifierDBService* GetInstance(); + static nsUrlClassifierDBService* GetInstance(nsresult *result); #ifdef MOZILLA_1_8_BRANCH NS_DEFINE_STATIC_IID_ACCESSOR(NS_URLCLASSIFIERDBSERVICE_CID)