Bug 924894 - Split prefs files up for Metro and Desktop when running in the same profile. r=jimm
authorBrian R. Bondy <netzen@gmail.com>
Tue, 05 Nov 2013 13:20:39 -0500
changeset 168205 5571ab3a0493e4b726dccadf49c1f811705bbe4f
parent 168172 a3f771caf25dc2f5c829e78a0fa52556c573ff86
child 168206 99497e0ef81e03ccd414a6671d787eab0ab96914
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs924894
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924894 - Split prefs files up for Metro and Desktop when running in the same profile. r=jimm
modules/libpref/src/Preferences.cpp
profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp
toolkit/xre/nsXREDirProvider.cpp
xpcom/io/nsAppDirectoryServiceDefs.h
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -747,17 +747,25 @@ Preferences::NotifyServiceObservers(cons
 }
 
 nsresult
 Preferences::UseDefaultPrefFile()
 {
   nsresult rv;
   nsCOMPtr<nsIFile> aFile;
 
-  rv = NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE, getter_AddRefs(aFile));
+#if defined(XP_WIN) && defined(MOZ_METRO)
+  if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
+    rv = NS_GetSpecialDirectory(NS_METRO_APP_PREFS_50_FILE, getter_AddRefs(aFile));
+  } else
+#endif
+  {
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE, getter_AddRefs(aFile));
+  }
+
   if (NS_SUCCEEDED(rv)) {
     rv = ReadAndOwnUserPrefFile(aFile);
     // Most likely cause of failure here is that the file didn't
     // exist, so save a new one. mUserPrefReadFailed will be
     // used to catch an error in actually reading the file.
     if (NS_FAILED(rv)) {
       if (NS_FAILED(SavePrefFileInternal(aFile)))
         NS_ERROR("Failed to save new shared pref file");
--- a/profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp
+++ b/profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp
@@ -11,16 +11,17 @@
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsISupportsUtils.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIObserverService.h"
 
 // File Name Defines
 
 #define PREFS_FILE_50_NAME           NS_LITERAL_CSTRING("prefs.js")
+#define PREFS_FILE_METRO_50_NAME     NS_LITERAL_CSTRING("metro-prefs.js")
 #define USER_CHROME_DIR_50_NAME      NS_LITERAL_CSTRING("chrome")
 #define LOCAL_STORE_FILE_50_NAME     NS_LITERAL_CSTRING("localstore.rdf")
 #define PANELS_FILE_50_NAME          NS_LITERAL_CSTRING("panels.rdf")
 #define MIME_TYPES_FILE_50_NAME      NS_LITERAL_CSTRING("mimeTypes.rdf")
 #define BOOKMARKS_FILE_50_NAME       NS_LITERAL_CSTRING("bookmarks.html")
 #define DOWNLOADS_FILE_50_NAME       NS_LITERAL_CSTRING("downloads.rdf")
 #define SEARCH_FILE_50_NAME          NS_LITERAL_CSTRING("search.rdf" )
 
@@ -164,16 +165,21 @@ nsProfileDirServiceProvider::GetFile(con
   if (strcmp(prop, NS_APP_PREFS_50_DIR) == 0) {
     rv = domainDir->Clone(getter_AddRefs(localFile));
   }
   else if (strcmp(prop, NS_APP_PREFS_50_FILE) == 0) {
     rv = domainDir->Clone(getter_AddRefs(localFile));
     if (NS_SUCCEEDED(rv))
       rv = localFile->AppendNative(PREFS_FILE_50_NAME);
   }
+  else if (strcmp(prop, NS_METRO_APP_PREFS_50_FILE) == 0) {
+    rv = domainDir->Clone(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendNative(PREFS_FILE_METRO_50_NAME);
+  }
   else if (strcmp(prop, NS_APP_USER_PROFILE_50_DIR) == 0) {
     rv = domainDir->Clone(getter_AddRefs(localFile));
   }
   else if (strcmp(prop, NS_APP_USER_PROFILE_LOCAL_50_DIR) == 0) {
     rv = mLocalProfileDir->Clone(getter_AddRefs(localFile));
   }
   else if (strcmp(prop, NS_APP_USER_CHROME_DIR) == 0) {
     rv = domainDir->Clone(getter_AddRefs(localFile));
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -395,16 +395,19 @@ nsXREDirProvider::GetFile(const char* aP
 
   if (NS_SUCCEEDED(GetProfileDir(getter_AddRefs(file)))) {
     if (!strcmp(aProperty, NS_APP_PREFS_50_DIR)) {
       rv = NS_OK;
     }
     else if (!strcmp(aProperty, NS_APP_PREFS_50_FILE)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("prefs.js"));
     }
+    else if (!strcmp(aProperty, NS_METRO_APP_PREFS_50_FILE)) {
+      rv = file->AppendNative(NS_LITERAL_CSTRING("metro-prefs.js"));
+    }
     else if (!strcmp(aProperty, NS_LOCALSTORE_UNSAFE_FILE)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("localstore.rdf"));
     }
     else if (!strcmp(aProperty, NS_APP_LOCALSTORE_50_FILE)) {
       if (gSafeMode) {
         rv = file->AppendNative(NS_LITERAL_CSTRING("localstore-safe.rdf"));
         file->Remove(false);
       }
--- a/xpcom/io/nsAppDirectoryServiceDefs.h
+++ b/xpcom/io/nsAppDirectoryServiceDefs.h
@@ -57,16 +57,17 @@
 // key with NS_SHARED returns a location that is shared by
 // other users of the profile. Without this prefix, the consumer
 // has exclusive access to this location.
  
 #define NS_SHARED                               "SHARED"
 
 #define NS_APP_PREFS_50_DIR                     "PrefD"         // Directory which contains user prefs       
 #define NS_APP_PREFS_50_FILE                    "PrefF"
+#define NS_METRO_APP_PREFS_50_FILE              "MetroPrefF"    // Metro browser prefs file
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST          "PrefDL"
 #define NS_EXT_PREFS_DEFAULTS_DIR_LIST          "ExtPrefDL"
 #define NS_APP_PREFS_OVERRIDE_DIR               "PrefDOverride" // Directory for per-profile defaults
         
 #define NS_APP_USER_PROFILE_50_DIR              "ProfD"
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR        "ProfLD"
         
 #define NS_APP_USER_CHROME_DIR                  "UChrm"