39 #include "nsDirectoryServiceDefs.h"
42 #include "nsILocalFile.h"
43 #include "nsIObserverService.h"
44 #include "nsIProfileMigrator.h"
45 #include "nsIServiceManager.h"
46 #include "nsIStringBundle.h"
47 #include "nsISupportsArray.h"
48 #include "nsISupportsPrimitives.h"
49 #include "nsServiceManagerUtils.h"
50 #include "nsIProperties.h"
51 #include <Carbon/Carbon.h>
53 #define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html")
54 #define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer")
55 #define MACIE_DEFAULT_HOMEPAGE_PREF "\p4D534945„WWWHomePage"
56 #define TEMP_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("bookmarks_tmp.html")
58 #define MIGRATION_BUNDLE "chrome://browser/locale/migration/migration.properties"
67 mObserverService = do_GetService(
"@mozilla.org/observer-service;1");
78 nsMacIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup,
const PRUnichar* aProfile)
82 PRBool replace = aStartup ? PR_TRUE : PR_FALSE;
90 nsCOMPtr<nsIProperties> fileLocator =
91 do_GetService(
"@mozilla.org/file/directory_service;1", &rv);
92 NS_ENSURE_SUCCESS(rv, rv);
94 fileLocator->Get(NS_OSX_USER_PREFERENCES_DIR,
95 NS_GET_IID(nsILocalFile),
110 nsMacIEProfileMigrator::GetMigrateData(
const PRUnichar* aProfile,
118 nsCOMPtr<nsIProperties> fileLocator =
119 do_GetService(
"@mozilla.org/file/directory_service;1", &rv);
120 NS_ENSURE_SUCCESS(rv, rv);
122 fileLocator->Get(NS_OSX_USER_PREFERENCES_DIR,
123 NS_GET_IID(nsILocalFile),
140 nsMacIEProfileMigrator::GetSourceExists(PRBool* aResult)
146 PRBool prefExists = PR_FALSE;
148 ICInstance icInstance;
150 err = ::ICStart(&icInstance,
'FRFX');
153 Str255 IEhomePageValue;
154 long size = kICFileSpecHeaderSize;
156 IEhomePageValue, &size);
158 prefExists = PR_TRUE;
160 ::ICStop(icInstance);
169 GetMigrateData(nsnull, PR_FALSE, &data);
171 *aResult = data != 0;
177 nsMacIEProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
184 nsMacIEProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
191 nsMacIEProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
204 nsCOMPtr<nsIFile> sourceFile;
208 PRBool exists = PR_FALSE;
209 sourceFile->Exists(&exists);
218 NS_LITERAL_STRING(
"sourceNameIE").
get());
222 NS_ENSURE_SUCCESS(rv, rv);
226 nsCOMPtr<nsIFile> tempFile;
231 nsCOMPtr<nsIStringBundleService> bundleService =
232 do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
233 NS_ENSURE_SUCCESS(rv, rv);
234 nsCOMPtr<nsIStringBundle>
bundle;
236 NS_ENSURE_SUCCESS(rv, rv);
238 nsString toolbarFolderNameMacIE;
239 rv = bundle->GetStringFromName(NS_LITERAL_STRING(
"toolbarFolderNameMacIE").
get(),
240 getter_Copies(toolbarFolderNameMacIE));
241 NS_ENSURE_SUCCESS(rv, rv);
247 NS_ConvertUTF16toUTF8(toolbarFolderNameMacIE).
get());
248 NS_ENSURE_SUCCESS(rv, rv);
254 EmptyString().
get());
255 NS_ENSURE_SUCCESS(rv, rv);
258 return tempFile->Remove(PR_FALSE);
nsresult InitializeBookmarks(nsIFile *aTargetProfile)
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
nsresult CopyBookmarks(PRBool aReplace)
#define MACIE_PREFERENCES_FOLDER_NAME
virtual ~nsMacIEProfileMigrator()
nsresult ImportBookmarksHTML(nsIFile *aBookmarksFile, PRBool aImportIntoRoot, PRBool aOverwriteDefaults, const PRUnichar *aImportSourceNameKey)
nsresult AnnotatePersonalToolbarFolder(nsIFile *aSourceBookmarksFile, nsIFile *aTargetBookmarksFile, const char *aToolbarFolderName)
nsCOMPtr< nsIFile > mTargetProfile
#define TEMP_BOOKMARKS_FILE_NAME
#define NOTIFY_OBSERVERS(message, item)
#define MIGRATION_STARTED
nsCOMPtr< nsILocalFile > mSourceProfile
#define COPY_DATA(func, replace, itemIndex)
#define MACIE_BOOKMARKS_FILE_NAME
#define MACIE_DEFAULT_HOMEPAGE_PREF
const unsigned short BOOKMARKS
void GetProfilePath(nsIProfileStartup *aStartup, nsCOMPtr< nsIFile > &aProfileDir)
void GetMigrateDataFromArray(MigrationData *aDataArray, PRInt32 aDataArrayLength, PRBool aReplace, nsIFile *aSourceProfile, PRUint16 *aResult)