Bug 413021 - Migration/Import Wizard offer migrate from IE on Mac (where no IE is installed). patch from Michael Schonfeld <dev@schonfeld.org>, r=me.
authormozilla.mano@sent.com
Sat, 01 Mar 2008 05:47:28 -0800
changeset 12464 e1370dde58160f72f4cc6589c55eb5eee46431d3
parent 12463 68b64de6cc6a2cb8f7435116588aefe7406b607e
child 12465 42ab26ce102bb3db5e4932844af51387e7d04ee5
push idunknown
push userunknown
push dateunknown
reviewersme
bugs413021
milestone1.9b4pre
Bug 413021 - Migration/Import Wizard offer migrate from IE on Mac (where no IE is installed). patch from Michael Schonfeld <dev@schonfeld.org>, r=me.
browser/components/migration/src/nsMacIEProfileMigrator.cpp
--- a/browser/components/migration/src/nsMacIEProfileMigrator.cpp
+++ b/browser/components/migration/src/nsMacIEProfileMigrator.cpp
@@ -43,19 +43,21 @@
 #include "nsIObserverService.h"
 #include "nsIProfileMigrator.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsISupportsArray.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIProperties.h"
+#include <InternetConfig.h>
 
 #define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html")
 #define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer")
+#define MACIE_DEFAULT_HOMEPAGE_PREF  "\p4D534945„WWWHomePage"
 #define TEMP_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("bookmarks_tmp.html")
 
 #define MIGRATION_BUNDLE "chrome://browser/locale/migration/migration.properties"
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsMacIEProfileMigrator
 
 NS_IMPL_ISUPPORTS1(nsMacIEProfileMigrator, nsIBrowserProfileMigrator)
@@ -132,21 +134,47 @@ nsMacIEProfileMigrator::GetMigrateData(c
                           aReplace, mSourceProfile, aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMacIEProfileMigrator::GetSourceExists(PRBool* aResult)
 {
+  // Since the IE bookmarks file can sometimes be created by programs
+  // other than Internet Explorer, thus misleading, we must first
+  // check whether IE is even installed on this Mac.  We accomplish this by
+  // checking one of IEs stored preferences in the apple.internetconfig file.
+  PRBool prefExists = PR_FALSE;
+  OSErr err;
+  ICInstance icInstance;
+
+  err = ::ICStart(&icInstance, 'FRFX');
+  if (err == noErr) {
+    ICAttr attrs;
+    Str255 IEhomePageValue;
+    long size = kICFileSpecHeaderSize;
+    err = ::ICGetPref(icInstance, MACIE_DEFAULT_HOMEPAGE_PREF, &attrs,
+                      IEhomePageValue, &size);
+    if (err == noErr)
+      prefExists = PR_TRUE;
+
+    ::ICStop(icInstance);
+  }
+
+  if (!prefExists) {
+    *aResult = PR_FALSE;
+    return NS_OK;
+  }
+
   PRUint16 data;
   GetMigrateData(nsnull, PR_FALSE, &data);
-  
+
   *aResult = data != 0;
-  
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMacIEProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
 {
   *aResult = PR_FALSE;
   return NS_OK;