about summary refs log tree commit diff
path: root/overlays/patches/firefox/release/D6995.diff
blob: bb02e8a2b0aaf6485c87a167d878ed59015424d5 (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
diff --git a/toolkit/moz.build b/toolkit/moz.build
index 14f4638b693e..1ed5c2002991 100644
--- a/toolkit/moz.build
+++ b/toolkit/moz.build
@@ -75,3 +75,6 @@ with Files("mozapps/preferences/**"):
 
 with Files("l10n-registry.manifest"):
     BUG_COMPONENT = ("Core", "Localization")
+
+if CONFIG["ENABLE_TESTS"]:
+    DIRS += ["tests/gtest"]
diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
index 50a64a2b469c..b97fedabe5ca 100644
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -412,13 +412,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("Mozilla"_ns);
-#  else
-      rv = localDir->AppendNative(".mozilla"_ns);
-#  endif
-    }
-    if (NS_SUCCEEDED(rv)) {
       localDir.swap(file);
     }
   }
@@ -1417,6 +1410,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)) {
@@ -1440,6 +1436,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;
@@ -1460,8 +1459,51 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
       if (NS_SUCCEEDED(rv)) rv = localDir->AppendNative(".cache"_ns);
     }
   } 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"
@@ -1559,20 +1601,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);
@@ -1637,9 +1671,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
@@ -1659,8 +1690,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 ef974f99048f..b4025f056297 100644
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -233,7 +233,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:
 //----------------------------------------------------------------------------------------
@@ -277,19 +277,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) {
@@ -309,7 +370,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:
 //----------------------------------------------------------------------------------------