Backed out changeset 40811b076d51
authorDão Gottwald <dao@mozilla.com>
Sun, 13 Sep 2009 17:36:23 +0200
changeset 32437 7ec77bf7ffcdd922d642f0ed738d13242b3c64d0
parent 32436 40811b076d515f369ed6b142af845261eb7f903a
child 32438 46b550da2a8cec7d6b68b9332a141fdb8b57f9a6
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
backs out40811b076d515f369ed6b142af845261eb7f903a
Backed out changeset 40811b076d51
browser/installer/package-manifest.in
browser/installer/removed-files.in
modules/libpref/src/Makefile.in
modules/libpref/src/greprefs.js.in
modules/libpref/src/jar.mn
modules/libpref/src/nsPrefService.cpp
netwerk/base/public/Makefile.in
xpinstall/public/Makefile.in
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -376,16 +376,19 @@
 @BINPATH@/icons/*.png
 #endif
 
 ; [Default Preferences]
 ; All the pref files must be part of base to prevent migration bugs
 @BINPATH@/@PREF_DIR@/firefox.js
 @BINPATH@/@PREF_DIR@/firefox-branding.js
 @BINPATH@/@PREF_DIR@/channel-prefs.js
+@BINPATH@/greprefs/all.js
+@BINPATH@/greprefs/security-prefs.js
+@BINPATH@/greprefs/xpinstall.js
 @BINPATH@/defaults/autoconfig/platform.js
 @BINPATH@/defaults/autoconfig/prefcalls.js
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine. 
 @BINPATH@/res/hiddenWindow.html
 @BINPATH@/res/ua.css
 @BINPATH@/res/html.css
--- a/browser/installer/removed-files.in
+++ b/browser/installer/removed-files.in
@@ -23,20 +23,16 @@ defaults/profile/extensions/{972ce4c6-7e
 defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/
 defaults/profile/extensions/Extensions.rdf
 defaults/profile/extensions/installed-extensions.txt
 defaults/profile/extensions/
 defaults/profile/search.rdf
 defaults/profile/US/
 extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf
 extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/
-greprefs/all.js
-greprefs/security-prefs.js
-greprefs/xpinstall.js
-greprefs/
 searchplugins/dictionary.src
 searchplugins/dictionary.png
 searchplugins/amazondotcom.src
 searchplugins/amazondotcom.png
 searchplugins/creativecommons.src
 searchplugins/creativecommons.png
 searchplugins/answers.src
 searchplugins/answers.png
--- a/modules/libpref/src/Makefile.in
+++ b/modules/libpref/src/Makefile.in
@@ -67,25 +67,27 @@ DEFINES += -DOS_ARCH=$(OS_ARCH) \
            -DMOZ_WIDGET_TOOLKIT=$(MOZ_WIDGET_TOOLKIT) \
            $(NULL)
 
 # this comes from a system header; we should probably be using XP_WINCE or something
 ifdef WINCE
 DEFINES += -DWINCE=1
 endif
 
+PREF_JS_EXPORTS	= $(srcdir)/init/all.js
+
 EXTRA_DSO_LDOPTS = \
 		$(LIBS_DIR) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 GARBAGE		+= $(addprefix $(DIST)/bin/defaults/pref/, \
-			mailnews.js editor.js \
+			all.js mailnews.js editor.js \
 			aix.js beos.js unix.js winpref.js os2prefs.js openvms.js photon.js)
 
 # Optimizer bug with GCC 3.2.2 on OS/2
 ifeq ($(OS_ARCH), OS2)
 nsPrefService.$(OBJ_SUFFIX): nsPrefService.cpp
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_AUTO_CXX)
 	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS:-O2=-O1) $(_VPATH_SRCS)
deleted file mode 100644
--- a/modules/libpref/src/greprefs.js.in
+++ /dev/null
@@ -1,4 +0,0 @@
-#filter emptyLines spaces
-#include ../../../xpinstall/public/xpinstall.js
-#include ../../../netwerk/base/public/security-prefs.js
-#include init/all.js
deleted file mode 100644
--- a/modules/libpref/src/jar.mn
+++ /dev/null
@@ -1,2 +0,0 @@
-toolkit.jar:
-*   res/greprefs.js                 (greprefs.js.in)
--- a/modules/libpref/src/nsPrefService.cpp
+++ b/modules/libpref/src/nsPrefService.cpp
@@ -443,56 +443,61 @@ nsresult nsPrefService::WritePrefFile(ns
       return rv;
     }
   }
 
   gDirty = PR_FALSE;
   return NS_OK;
 }
 
-static nsresult openPrefInputStream(nsIInputStream *aInStr) {
-  PRUint32 fileSize;
-  nsresult rv = aInStr->Available(&fileSize);
+static nsresult openPrefFile(nsIFile* aFile)
+{
+  nsCOMPtr<nsIInputStream> inStr;
+
+#if MOZ_TIMELINE
+  {
+    nsCAutoString str;
+    aFile->GetNativePath(str);
+    NS_TIMELINE_MARK_FUNCTION1("load pref file", str.get());
+  }
+#endif
+
+  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), aFile);
+  if (NS_FAILED(rv)) 
+    return rv;        
+
+  PRInt64 fileSize;
+  rv = aFile->GetFileSize(&fileSize);
   if (NS_FAILED(rv))
     return rv;
 
   nsAutoArrayPtr<char> fileBuffer(new char[fileSize]);
   if (fileBuffer == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
 
   PrefParseState ps;
   PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
 
   // Read is not guaranteed to return a buf the size of fileSize,
   // but usually will.
   nsresult rv2 = NS_OK;
   for (;;) {
     PRUint32 amtRead = 0;
-    rv = aInStr->Read((char*)fileBuffer, fileSize, &amtRead);
+    rv = inStr->Read((char*)fileBuffer, fileSize, &amtRead);
     if (NS_FAILED(rv) || amtRead == 0)
       break;
     if (!PREF_ParseBuf(&ps, fileBuffer, amtRead))
       rv2 = NS_ERROR_FILE_CORRUPTED;
   }
 
   PREF_FinalizeParseState(&ps);
 
   return NS_FAILED(rv) ? rv : rv2;
 }
 
-static nsresult openPrefFile(nsIFile* aFile)
-{
-  nsCOMPtr<nsIInputStream> inStr;
-
-  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), aFile);
-  if (NS_FAILED(rv)) 
-    return rv;        
-  return openPrefInputStream(inStr);
-}
-
 /*
  * some stuff that gets called from Pref_Init()
  */
 
 static int
 pref_CompareFileNames(nsIFile* aFile1, nsIFile* aFile2, void* /*unused*/)
 {
   nsCAutoString filename1, filename2;
@@ -629,43 +634,34 @@ static nsresult pref_LoadPrefsInDirList(
 }
 
 //----------------------------------------------------------------------------------------
 // Initialize default preference JavaScript buffers from
 // appropriate TEXT resources
 //----------------------------------------------------------------------------------------
 static nsresult pref_InitInitialObjects()
 {
+  nsCOMPtr<nsIFile> aFile;
+  nsCOMPtr<nsIFile> defaultPrefDir;
   nsresult          rv;
-  nsCOMPtr<nsIIOService> ioservice(do_GetIOService(&rv));
-  if (NS_FAILED(rv))
-    return rv;
 
   // first we parse the GRE default prefs. This also works if we're not using a GRE, 
-  nsCOMPtr<nsIURI> uri;
-  rv = ioservice->NewURI(NS_LITERAL_CSTRING("resource://gre-resources/greprefs.js"), nsnull, nsnull,
-                         getter_AddRefs(uri));
-  if (NS_FAILED(rv)) 
-    return rv;
-  nsCOMPtr<nsIChannel> channel;
-  rv = NS_NewChannel(getter_AddRefs(channel), uri);
-  if (NS_FAILED(rv)) 
-    return rv;
+
+  rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(defaultPrefDir));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIInputStream> inStr;  
-  rv = channel->Open(getter_AddRefs(inStr));
-  if (NS_SUCCEEDED(rv)) {
-    rv = openPrefInputStream(inStr);
-    if (NS_FAILED(rv)) {
-      NS_WARNING("Error parsing GRE default preferences. Is this an old-style embedding app?");
-    }
+  rv = defaultPrefDir->AppendNative(NS_LITERAL_CSTRING("greprefs"));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = pref_LoadPrefsInDir(defaultPrefDir, nsnull, 0);
+  if (NS_FAILED(rv)) {
+    NS_WARNING("Error parsing GRE default preferences. Is this an old-style embedding app?");
   }
 
   // now parse the "application" default preferences
-  nsCOMPtr<nsIFile> defaultPrefDir;
   rv = NS_GetSpecialDirectory(NS_APP_PREF_DEFAULTS_50_DIR, getter_AddRefs(defaultPrefDir));
   NS_ENSURE_SUCCESS(rv, rv);
 
   /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
   static const char* specialFiles[] = {
 #if defined(XP_MAC) || defined(XP_MACOSX)
       "macprefs.js"
 #elif defined(XP_WIN)
--- a/netwerk/base/public/Makefile.in
+++ b/netwerk/base/public/Makefile.in
@@ -141,11 +141,13 @@ EXPORTS		= \
 		nsNetUtil.h \
 		nsNetStrings.h \
 		nsChannelProperties.h \
 		nsURIHashKey.h \
 		nsReadLine.h \
 		nsASocketHandler.h \
 		$(NULL)
 
+PREF_JS_EXPORTS = $(srcdir)/security-prefs.js
+
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DIMPL_NS_NET
--- a/xpinstall/public/Makefile.in
+++ b/xpinstall/public/Makefile.in
@@ -57,9 +57,11 @@ XPIDLSRCS	= \
 		nsPICertNotification.idl \
 		$(NULL)
 
 EXPORTS		= \
 		nsIDOMInstallTriggerGlobal.h \
 		nsSoftwareUpdateIIDs.h \
 		$(NULL)
 
+PREF_JS_EXPORTS	= $(srcdir)/xpinstall.js
+
 include $(topsrcdir)/config/rules.mk