From 48bb60b4c6aa04b3f24fd2d1fb7256bf3c532c27 Mon Sep 17 00:00:00 2001 From: Gregor Wagner Date: Tue, 24 Jul 2012 11:22:14 -0700 Subject: [PATCH] Bug 776764 - Allow permissionDB parent directory to not be the default profile directory. r=fabrice --- b2g/components/DirectoryProvider.js | 2 +- extensions/cookie/nsPermissionManager.cpp | 10 ++++++---- xpcom/io/nsAppDirectoryServiceDefs.h | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/b2g/components/DirectoryProvider.js b/b2g/components/DirectoryProvider.js index fc468823f146..1493ac5d92e1 100644 --- a/b2g/components/DirectoryProvider.js +++ b/b2g/components/DirectoryProvider.js @@ -22,7 +22,7 @@ DirectoryProvider.prototype = { getFile: function dp_getFile(prop, persistent) { #ifdef MOZ_WIDGET_GONK - let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir"]; + let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir", "permissionDBPDir"]; if (localProps.indexOf(prop) != -1) { prop.persistent = true; let file = Cc["@mozilla.org/file/local;1"] diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 05090f6915b4..9d5dccf1e2d3 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -303,11 +303,13 @@ nsresult nsPermissionManager::InitDB(bool aRemoveFile) { nsCOMPtr permissionsFile; - NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(permissionsFile)); - if (!permissionsFile) - return NS_ERROR_UNEXPECTED; + nsresult rv = NS_GetSpecialDirectory(NS_APP_PERMISSION_PARENT_DIR, getter_AddRefs(permissionsFile)); + if (NS_FAILED(rv)) { + rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(permissionsFile)); + } + NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED); - nsresult rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(kPermissionsFileName)); + rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(kPermissionsFileName)); NS_ENSURE_SUCCESS(rv, rv); if (aRemoveFile) { diff --git a/xpcom/io/nsAppDirectoryServiceDefs.h b/xpcom/io/nsAppDirectoryServiceDefs.h index a3d2f024265a..542662aa88f7 100644 --- a/xpcom/io/nsAppDirectoryServiceDefs.h +++ b/xpcom/io/nsAppDirectoryServiceDefs.h @@ -88,4 +88,6 @@ #define NS_APP_STORAGE_50_FILE "UStor" // sqlite database used as mozStorage profile db #define NS_APP_INDEXEDDB_PARENT_DIR "indexedDBPDir" + +#define NS_APP_PERMISSION_PARENT_DIR "permissionDBPDir" #endif