From bb07c79e0e396fe0fdfc2d145af8cf26375c7b7d Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Fri, 19 Oct 2007 04:24:50 +0000 Subject: [PATCH] Bug 369910 - "Cookies not imported from IE 7" [p=jimm r=gavin a=blocking-firefox3+ for M9] git-svn-id: svn://10.0.0.236/trunk@237883 18797224-902f-48f8-a5cc-f745e15eee43 --- .../migration/src/nsIEProfileMigrator.cpp | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp index e2a96bdb1f4..2eea04bc8d4 100644 --- a/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -1532,7 +1532,7 @@ nsIEProfileMigrator::CopyCookies(PRBool aReplace) { // IE cookies are stored in files named @domain[n].txt // (in 's Cookies folder. isn't the naming redundant?) - PRBool rv = NS_OK; + nsresult rv = NS_OK; nsCOMPtr cookiesDir; nsCOMPtr cookieFiles; @@ -1543,8 +1543,33 @@ nsIEProfileMigrator::CopyCookies(PRBool aReplace) // find the cookies directory NS_GetSpecialDirectory(NS_WIN_COOKIES_DIR, getter_AddRefs(cookiesDir)); - if (cookiesDir) - cookiesDir->GetDirectoryEntries(getter_AddRefs(cookieFiles)); + if (!cookiesDir) + return NS_ERROR_FAILURE; + + // Check for Vista's UAC, if so, tack on a "Low" sub dir + nsCOMPtr regKey = + do_CreateInstance("@mozilla.org/windows-registry-key;1"); + if (regKey) { + NS_NAMED_LITERAL_STRING(regPath,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"); + if (NS_SUCCEEDED(regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, + regPath, + nsIWindowsRegKey::ACCESS_QUERY_VALUE))) { + PRUint32 value; + if (NS_SUCCEEDED(regKey->ReadIntValue(NS_LITERAL_STRING("EnableLUA"), + &value)) && + value == 1) { + nsAutoString dir; + // For cases where we are running under protected mode, check + // cookiesDir for the Low sub directory. (Simpler than using + // process token calls to check our Vista integrity level.) + cookiesDir->GetLeafName(dir); + if (!dir.EqualsLiteral("Low")) + cookiesDir->Append(NS_LITERAL_STRING("Low")); + } + } + } + + cookiesDir->GetDirectoryEntries(getter_AddRefs(cookieFiles)); if (!cookieFiles) return NS_ERROR_FAILURE;