Bug 422771 - reduce narrow Windows API calls in browser, original patch by Brad Lassey <blassey@mozilla.com>, r=jmathies
authorBrian Crowder <crowder@fiverocks.com>
Wed, 27 Aug 2008 14:44:54 -0700
changeset 18478 b9de55a635d57beecab07b06791670573bfb1b7f
parent 18477 aa15c8607978ad6032a3b5cf133e432199500c1f
child 18479 73d8df3129ac6a0ddd0d0b99aaa6704441f67a70
push id1575
push userbcrowder@mozilla.com
push dateWed, 27 Aug 2008 21:46:09 +0000
treeherdermozilla-central@f97dbb2beaab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs422771
milestone1.9.1a2pre
Bug 422771 - reduce narrow Windows API calls in browser, original patch by Brad Lassey <blassey@mozilla.com>, r=jmathies
browser/app/nsBrowserApp.cpp
browser/components/migration/src/nsIEProfileMigrator.cpp
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -59,21 +59,19 @@
 #endif
 
 static void Output(const char *fmt, ... )
 {
   va_list ap;
   va_start(ap, fmt);
 
 #if defined(XP_WIN) && !MOZ_WINCONSOLE
-  char msg[2048];
-
-  _vsnprintf(msg, sizeof(msg), fmt, ap);
-
-  MessageBox(NULL, msg, "XULRunner", MB_OK | MB_ICONERROR);
+  PRUnichar msg[2048];
+  _vsnwprintf(msg, sizeof(msg)/sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).get(), ap);
+  MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR);
 #else
   vfprintf(stderr, fmt, ap);
 #endif
 
   va_end(ap);
 }
 
 /**
--- a/browser/components/migration/src/nsIEProfileMigrator.cpp
+++ b/browser/components/migration/src/nsIEProfileMigrator.cpp
@@ -862,17 +862,17 @@ static GUID IEPStoreSiteAuthGUID = { 0x5
 
 nsresult
 nsIEProfileMigrator::CopyPasswords(PRBool aReplace)
 {
   HRESULT hr;
   nsresult rv;
   nsVoidArray signonsFound;
 
-  HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
+  HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
   if (!pstoreDLL) {
     // XXXben TODO
     // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
     // and we can just blunder into the registry and use CryptUnprotect to get the data out. 
     return NS_ERROR_FAILURE;
   }
 
   PStoreCreateInstancePtr PStoreCreateInstance = (PStoreCreateInstancePtr)::GetProcAddress(pstoreDLL, "PStoreCreateInstance");
@@ -1186,17 +1186,17 @@ nsIEProfileMigrator::GetUserNameAndPass(
 //
 // "Quite Easily Done". ;-)
 // 
 nsresult
 nsIEProfileMigrator::CopyFormData(PRBool aReplace)
 {
   HRESULT hr;
 
-  HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
+  HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
   if (!pstoreDLL) {
     // XXXben TODO
     // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
     // and we can just blunder into the registry and use CryptUnprotect to get the data out. 
     return NS_ERROR_FAILURE;
   }
 
   PStoreCreateInstancePtr PStoreCreateInstance = (PStoreCreateInstancePtr)::GetProcAddress(pstoreDLL, "PStoreCreateInstance");
@@ -1419,30 +1419,29 @@ nsIEProfileMigrator::CopySmartKeywords(P
   return NS_OK;
 }
 
 void 
 nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL) 
 {
   HRESULT result;
 
-  IUniformResourceLocator* urlLink = nsnull;
+  IUniformResourceLocatorW* urlLink = nsnull;
   result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
-                              IID_IUniformResourceLocator, (void**)&urlLink);
+                              IID_IUniformResourceLocatorW, (void**)&urlLink);
   if (SUCCEEDED(result) && urlLink) {
     IPersistFile* urlFile = nsnull;
     result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile);
     if (SUCCEEDED(result) && urlFile) {
       result = urlFile->Load(aFileName.get(), STGM_READ);
       if (SUCCEEDED(result) ) {
-        LPSTR lpTemp = nsnull;
+        LPWSTR lpTemp = nsnull;
         result = urlLink->GetURL(&lpTemp);
         if (SUCCEEDED(result) && lpTemp) {
-          *aOutURL = PL_strdup(lpTemp);
-
+          *aOutURL = (char*)ToNewUTF8String(nsDependentString(lpTemp));
           // free the string that GetURL alloc'd
           ::CoTaskMemFree(lpTemp);
         }
       }
       urlFile->Release();
     }
     urlLink->Release();
   }