diff --git a/mozilla/camino/src/application/AppDirServiceProvider.cpp b/mozilla/camino/src/application/AppDirServiceProvider.cpp index d204d8d63bf..6573e29a06c 100644 --- a/mozilla/camino/src/application/AppDirServiceProvider.cpp +++ b/mozilla/camino/src/application/AppDirServiceProvider.cpp @@ -93,6 +93,10 @@ AppDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_ { rv = GetProductDirectory(getter_AddRefs(localFile)); } + else if (strcmp(prop, NS_APP_CACHE_PARENT_DIR) == 0) + { + rv = GetCacheDirectory(getter_AddRefs(localFile)); + } if (localFile && NS_SUCCEEDED(rv)) return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); @@ -105,15 +109,27 @@ AppDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_ //***************************************************************************** NS_METHOD -AppDirServiceProvider::GetProductDirectory(nsILocalFile **aLocalFile) +AppDirServiceProvider::GetProductDirectory(nsILocalFile **outLocalFile) { - NS_ENSURE_ARG_POINTER(aLocalFile); - *aLocalFile = nsnull; + return EnsureFolder(kApplicationSupportFolderType, outLocalFile); +} + +nsresult +AppDirServiceProvider::GetCacheDirectory(nsILocalFile** outCacheFolder) +{ + return EnsureFolder(kCachedDataFolderType, outCacheFolder); +} + +nsresult +AppDirServiceProvider::EnsureFolder(OSType inFolderType, nsILocalFile** outFolder) +{ + NS_ENSURE_ARG_POINTER(outFolder); + *outFolder = nsnull; nsresult rv; FSRef foundRef; - OSErr err = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &foundRef); + OSErr err = ::FSFindFolder(kUserDomain, inFolderType, kCreateFolder, &foundRef); if (err != noErr) return NS_ERROR_FAILURE; nsCOMPtr localDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); @@ -133,9 +149,8 @@ AppDirServiceProvider::GetProductDirectory(nsILocalFile **aLocalFile) if (NS_FAILED(rv)) return rv; - *aLocalFile = localDir; - NS_ADDREF(*aLocalFile); + *outFolder = localDir; + NS_ADDREF(*outFolder); return rv; -} - +} \ No newline at end of file diff --git a/mozilla/camino/src/application/AppDirServiceProvider.h b/mozilla/camino/src/application/AppDirServiceProvider.h index d7b7f4fb116..abfacce58ef 100644 --- a/mozilla/camino/src/application/AppDirServiceProvider.h +++ b/mozilla/camino/src/application/AppDirServiceProvider.h @@ -43,6 +43,8 @@ #include "nsILocalFile.h" #include "nsString.h" +#include + class nsIFile; //***************************************************************************** @@ -61,8 +63,9 @@ protected: virtual ~AppDirServiceProvider(); NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile); - NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile); - + nsresult GetCacheDirectory(nsILocalFile** outCacheFolder); + nsresult EnsureFolder(OSType inFolderType, nsILocalFile** outFolder); + nsCString mProductDirName; }; diff --git a/mozilla/camino/src/application/MainController.mm b/mozilla/camino/src/application/MainController.mm index 785de9c0b15..f0bc387e65d 100644 --- a/mozilla/camino/src/application/MainController.mm +++ b/mozilla/camino/src/application/MainController.mm @@ -249,6 +249,12 @@ const int kReuseWindowOnAE = 2; // order, we need to set a user default to return to the old behavior. [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSViewSetAncestorsWindowFirst"]; + // previous versions would keep the cache in the profile folder. If we find it there, remove it so + // that backup apps can more easily back up our profile. This will mean if anyone goes back to + // 0.8.x, they'll lose their favicons and cache, but that's ok. + NSString* cacheDir = [[pm newProfilePath] stringByAppendingPathComponent:@"Cache"]; + [[NSFileManager defaultManager] removeFileAtPath:cacheDir handler:nil]; + // register for window layering changes, so that we can update the bookmarks menu NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidBecomeKeyNotification object:nil]; diff --git a/mozilla/camino/src/preferences/PreferenceManager.h b/mozilla/camino/src/preferences/PreferenceManager.h index ee9f507f5a4..7debb21a082 100644 --- a/mozilla/camino/src/preferences/PreferenceManager.h +++ b/mozilla/camino/src/preferences/PreferenceManager.h @@ -74,4 +74,7 @@ class nsIPref; - (void)setPref:(const char*)prefName toInt:(int)value; - (void)setPref:(const char*)prefName toBoolean:(BOOL)value; +// the path to the user profile's root folder, used by camino 0.8+ +- (NSString*) newProfilePath; + @end