about summary refs log tree commit diff
path: root/config/firefox/beta/D6695.diff
blob: f8a8deeb8581c69d779821d69da7df27ed352a7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
diff --git a/toolkit/moz.build b/toolkit/moz.build
index 109fb2c..0b871d9 100644
--- a/toolkit/moz.build
+++ b/toolkit/moz.build
@@ -72,3 +72,5 @@ with Files('mozapps/preferences/**'):
 with Files('pluginproblem/**'):
     BUG_COMPONENT = ('Core', 'Plug-ins')
 
+if CONFIG['ENABLE_TESTS']:
+    DIRS += ['tests/gtest']
diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
index aafe82e..2d850fe 100644
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -390,13 +390,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
     nsCOMPtr<nsIFile> localDir;
     rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), false);
     if (NS_SUCCEEDED(rv)) {
-#if defined(XP_MACOSX)
-      rv = localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla"));
-#else
-      rv = localDir->AppendNative(NS_LITERAL_CSTRING(".mozilla"));
-#endif
-    }
-    if (NS_SUCCEEDED(rv)) {
       localDir.swap(file);
     }
   }
@@ -1238,7 +1231,8 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
             nsDependentCString(hasVendor ? GetAppVendor() : GetAppName())))) {
       return NS_ERROR_FAILURE;
     }
-  } else if (NS_FAILED(localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla")))) {
+  }
+  else if (NS_FAILED(localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla")))) {
     return NS_ERROR_FAILURE;
   }
 
@@ -1367,6 +1361,9 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
   NS_ENSURE_SUCCESS(rv, rv);
 
   localDir = dirFileMac;
+
+  rv = localDir->AppendRelativeNativePath(nsDependentCString("Mozilla"));
+  NS_ENSURE_SUCCESS(rv, rv);
 #elif defined(XP_IOS)
   nsAutoCString userDir;
   if (GetUIKitDirectory(aLocal, userDir)) {
@@ -1390,6 +1387,9 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir));
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = localDir->AppendRelativeNativePath(nsDependentCString("Mozilla"));
+  NS_ENSURE_SUCCESS(rv, rv);
 #elif defined(XP_UNIX)
   const char* homeDir = getenv("HOME");
   if (!homeDir || !*homeDir) return NS_ERROR_FAILURE;
@@ -1411,8 +1411,51 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
         rv = localDir->AppendNative(NS_LITERAL_CSTRING(".cache"));
     }
   } else {
+    bool exists;
+    // check old config ~/.mozilla
     rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
                                getter_AddRefs(localDir));
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = localDir->AppendRelativeNativePath(nsDependentCString(".mozilla"));
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = localDir->Exists(&exists);
+    NS_ENSURE_SUCCESS(rv, rv);
+    // otherwise, use new config
+    if (!exists) {
+      const char* xdghomedir = getenv("XDG_DATA_HOME");
+      if (!xdghomedir || !*xdghomedir) {
+        rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
+                                   getter_AddRefs(localDir));
+        NS_ENSURE_SUCCESS(rv, rv);
+        rv = localDir->AppendRelativeNativePath(nsDependentCString(".local"));
+        NS_ENSURE_SUCCESS(rv, rv);
+        rv = localDir->Exists(&exists);
+        if (NS_SUCCEEDED(rv) && !exists) {
+          rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
+          NS_ENSURE_SUCCESS(rv, rv);
+        }
+        rv = localDir->AppendRelativeNativePath(nsDependentCString("share"));
+        NS_ENSURE_SUCCESS(rv, rv);
+        rv = localDir->Exists(&exists);
+        if (NS_SUCCEEDED(rv) && !exists) {
+          rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
+        }
+      }
+      else {
+        rv = NS_NewNativeLocalFile(nsDependentCString(xdghomedir), true,
+                               getter_AddRefs(localDir));
+      }
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      rv = localDir->AppendRelativeNativePath(nsDependentCString("mozilla"));
+      NS_ENSURE_SUCCESS(rv, rv);
+      rv = localDir->Exists(&exists);
+      NS_ENSURE_SUCCESS(rv, rv);
+      if (NS_SUCCEEDED(rv) && !exists) {
+        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
+    }
   }
 #else
 #error "Don't know how to get product dir on your platform"
@@ -1523,20 +1566,12 @@ nsresult nsXREDirProvider::AppendSysUserExtensionPath(nsIFile* aFile) {
 
 #if defined(XP_MACOSX) || defined(XP_WIN)
 
-  static const char* const sXR = "Mozilla";
-  rv = aFile->AppendNative(nsDependentCString(sXR));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   static const char* const sExtensions = "Extensions";
   rv = aFile->AppendNative(nsDependentCString(sExtensions));
   NS_ENSURE_SUCCESS(rv, rv);
 
 #elif defined(XP_UNIX)
 
-  static const char* const sXR = ".mozilla";
-  rv = aFile->AppendNative(nsDependentCString(sXR));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   static const char* const sExtensions = "extensions";
   rv = aFile->AppendNative(nsDependentCString(sExtensions));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1554,20 +1589,12 @@ nsresult nsXREDirProvider::AppendSysUserExtensionsDevPath(nsIFile* aFile) {
 
 #if defined(XP_MACOSX) || defined(XP_WIN)
 
-  static const char* const sXR = "Mozilla";
-  rv = aFile->AppendNative(nsDependentCString(sXR));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   static const char* const sExtensions = "SystemExtensionsDev";
   rv = aFile->AppendNative(nsDependentCString(sExtensions));
   NS_ENSURE_SUCCESS(rv, rv);
 
 #elif defined(XP_UNIX)
 
-  static const char* const sXR = ".mozilla";
-  rv = aFile->AppendNative(nsDependentCString(sXR));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   static const char* const sExtensions = "systemextensionsdev";
   rv = aFile->AppendNative(nsDependentCString(sExtensions));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1625,9 +1652,6 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
   NS_ENSURE_SUCCESS(rv, rv);
 #elif defined(XP_UNIX)
   nsAutoCString folder;
-  // Make it hidden (by starting with "."), except when local (the
-  // profile is already under ~/.cache or XDG_CACHE_HOME).
-  if (!aLocal) folder.Assign('.');
 
   if (!profile.IsEmpty()) {
     // Skip any leading path characters
@@ -1647,8 +1671,12 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
       folder.Append(vendor);
       ToLowerCase(folder);
 
-      rv = aFile->AppendNative(folder);
-      NS_ENSURE_SUCCESS(rv, rv);
+      // Keep the 'mozilla' path for cache:
+      // Use ${XDG_DATA_HOME:-$HOME/.cache}/mozilla/firefox
+      if (aLocal) {
+        rv = aFile->AppendNative(folder);
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
 
       folder.Truncate();
     }
diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp
index 90e4ec9..8b838ec 100644
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -247,7 +247,7 @@ nsresult nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile** aLocalFile) {
 // GetProductDirectory - Gets the directory which contains the application data
 // folder
 //
-// UNIX   : ~/.mozilla/
+// UNIX   : ~/.mozilla/ or ${XDG_DATA_HOME:-~/.local/share}/mozilla
 // WIN    : <Application Data folder on user's machine>\Mozilla
 // Mac    : :Documents:Mozilla:
 //----------------------------------------------------------------------------------------
@@ -291,19 +291,80 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
     return rv;
   }
 #elif defined(XP_UNIX)
-  rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
+  const char* homeDir = PR_GetEnv("HOME");
+  /* check old config ~/.mozilla */
+  rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
                              getter_AddRefs(localDir));
   if (NS_FAILED(rv)) {
     return rv;
   }
+  rv = localDir->AppendRelativeNativePath(nsDependentCString(".mozilla"));
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = localDir->Exists(&exists);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  /* otherwise, use new config */
+  if (!exists) {
+    const char* xdghomedir = PR_GetEnv("XDG_DATA_HOME");
+    if (!xdghomedir || !*xdghomedir) {
+      /* XDG_DATA_HOME=$HOME/.local/share */
+      rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
+                                 getter_AddRefs(localDir));
+      if (NS_FAILED(rv)) {
+        return rv;
+      }
+      rv = localDir->AppendRelativeNativePath(nsDependentCString(".local"));
+      if (NS_FAILED(rv)) {
+        return rv;
+      }
+      rv = localDir->Exists(&exists);
+      if (NS_SUCCEEDED(rv) && !exists) {
+        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
+        if (NS_FAILED(rv)) {
+          return rv;
+        }
+      }
+      rv = localDir->AppendRelativeNativePath(nsDependentCString("share"));
+      if (NS_FAILED(rv)) {
+        return rv;
+      }
+      rv = localDir->Exists(&exists);
+      if (NS_SUCCEEDED(rv) && !exists) {
+        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
+      }
+    }
+    else {
+      rv = NS_NewNativeLocalFile(nsDependentCString(xdghomedir), true,
+                                 getter_AddRefs(localDir));
+    }
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = localDir->AppendRelativeNativePath(nsDependentCString("mozilla"));
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+  }
 #else
 #error dont_know_how_to_get_product_dir_on_your_platform
 #endif
 
+#if !defined(XP_UNIX) || defined(XP_MACOSX)
+  // Since we have to check for legacy configuration, we have
+  // the complete path for Linux already, so this is not
+  // needed. If we stop checking for legacy at some point,
+  // then we can change this to not be protected by
+  // this clause.
   rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
+
   if (NS_FAILED(rv)) {
     return rv;
   }
+#endif
+
   rv = localDir->Exists(&exists);
 
   if (NS_SUCCEEDED(rv) && !exists) {
@@ -323,7 +384,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
 // GetDefaultUserProfileRoot - Gets the directory which contains each user
 // profile dir
 //
-// UNIX   : ~/.mozilla/
+// UNIX   : ~/.mozilla/ or ${XDG_DATA_HOME:-~/.local/share}/mozilla
 // WIN    : <Application Data folder on user's machine>\Mozilla\Profiles
 // Mac    : :Documents:Mozilla:Profiles:
 //----------------------------------------------------------------------------------------