1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Robert O'Callahan (robert@ocallahan.org)
24 : * Michael Ventnor (m.ventnor@gmail.com)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #include "nsISystemProxySettings.h"
41 : #include "mozilla/ModuleUtils.h"
42 : #include "nsIServiceManager.h"
43 : #include "nsIGConfService.h"
44 : #include "nsIURI.h"
45 : #include "nsReadableUtils.h"
46 : #include "nsArrayUtils.h"
47 : #include "prnetdb.h"
48 : #include "prenv.h"
49 : #include "nsPrintfCString.h"
50 : #include "nsNetUtil.h"
51 : #include "nsISupportsPrimitives.h"
52 : #include "nsIGSettingsService.h"
53 : #include "nsInterfaceHashtable.h"
54 :
55 : class nsUnixSystemProxySettings : public nsISystemProxySettings {
56 : public:
57 : NS_DECL_ISUPPORTS
58 : NS_DECL_NSISYSTEMPROXYSETTINGS
59 :
60 269 : nsUnixSystemProxySettings() {}
61 : nsresult Init();
62 :
63 : private:
64 269 : ~nsUnixSystemProxySettings() {}
65 :
66 : nsCOMPtr<nsIGConfService> mGConf;
67 : nsCOMPtr<nsIGSettingsService> mGSettings;
68 : nsCOMPtr<nsIGSettingsCollection> mProxySettings;
69 : nsInterfaceHashtable<nsCStringHashKey, nsIGSettingsCollection> mSchemeProxySettings;
70 : bool IsProxyMode(const char* aMode);
71 : nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
72 : nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
73 : nsresult GetProxyFromGSettings(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
74 : nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType, nsACString& aResult);
75 : };
76 :
77 2690 : NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
78 :
79 : nsresult
80 269 : nsUnixSystemProxySettings::Init()
81 : {
82 269 : mSchemeProxySettings.Init(5);
83 269 : mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
84 269 : mGSettings = do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
85 269 : if (mGSettings) {
86 0 : mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
87 0 : getter_AddRefs(mProxySettings));
88 : }
89 :
90 269 : return NS_OK;
91 : }
92 :
93 : bool
94 7106 : nsUnixSystemProxySettings::IsProxyMode(const char* aMode)
95 : {
96 14212 : nsCAutoString mode;
97 21318 : return NS_SUCCEEDED(mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/mode"), mode)) &&
98 21318 : mode.EqualsASCII(aMode);
99 : }
100 :
101 : nsresult
102 3689 : nsUnixSystemProxySettings::GetPACURI(nsACString& aResult)
103 : {
104 3689 : if (mProxySettings) {
105 0 : nsCString proxyMode;
106 : // Check if mode is auto
107 0 : nsresult rv = mProxySettings->GetString(NS_LITERAL_CSTRING("mode"), proxyMode);
108 0 : if (rv == NS_OK && proxyMode.Equals("auto")) {
109 0 : return mProxySettings->GetString(NS_LITERAL_CSTRING("autoconfig-url"), aResult);
110 : }
111 : /* The org.gnome.system.proxy schema has been found, but auto mode is not set.
112 : * Don't try the GConf and return empty string. */
113 0 : aResult.Truncate();
114 0 : return NS_OK;
115 : }
116 :
117 3689 : if (mGConf && IsProxyMode("auto")) {
118 0 : return mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/autoconfig_url"),
119 0 : aResult);
120 : }
121 : // Return an empty string when auto mode is not set.
122 3689 : aResult.Truncate();
123 3689 : return NS_OK;
124 : }
125 :
126 : static bool
127 0 : IsInNoProxyList(const nsACString& aHost, PRInt32 aPort, const char* noProxyVal)
128 : {
129 0 : NS_ASSERTION(aPort >= 0, "Negative port?");
130 :
131 0 : nsCAutoString noProxy(noProxyVal);
132 0 : if (noProxy.EqualsLiteral("*"))
133 0 : return true;
134 :
135 0 : noProxy.StripWhitespace();
136 :
137 0 : nsReadingIterator<char> pos;
138 0 : nsReadingIterator<char> end;
139 0 : noProxy.BeginReading(pos);
140 0 : noProxy.EndReading(end);
141 0 : while (pos != end) {
142 0 : nsReadingIterator<char> last = pos;
143 0 : nsReadingIterator<char> nextPos;
144 0 : if (FindCharInReadable(',', last, end)) {
145 0 : nextPos = last;
146 0 : ++nextPos;
147 : } else {
148 0 : last = end;
149 0 : nextPos = end;
150 : }
151 :
152 0 : nsReadingIterator<char> colon = pos;
153 0 : PRInt32 port = -1;
154 0 : if (FindCharInReadable(':', colon, last)) {
155 0 : ++colon;
156 0 : nsDependentCSubstring portStr(colon, last);
157 0 : nsCAutoString portStr2(portStr); // We need this for ToInteger. String API's suck.
158 : PRInt32 err;
159 0 : port = portStr2.ToInteger(&err);
160 0 : if (NS_FAILED(err)) {
161 0 : port = -2; // don't match any port, so we ignore this pattern
162 : }
163 0 : --colon;
164 : } else {
165 0 : colon = last;
166 : }
167 :
168 0 : if (port == -1 || port == aPort) {
169 0 : nsDependentCSubstring hostStr(pos, colon);
170 : // By using StringEndsWith instead of an equality comparator, we can include sub-domains
171 0 : if (StringEndsWith(aHost, hostStr, nsCaseInsensitiveCStringComparator()))
172 0 : return true;
173 : }
174 :
175 0 : pos = nextPos;
176 : }
177 :
178 0 : return false;
179 : }
180 :
181 0 : static void SetProxyResult(const char* aType, const nsACString& aHost,
182 : PRInt32 aPort, nsACString& aResult)
183 : {
184 0 : aResult.AppendASCII(aType);
185 0 : aResult.Append(' ');
186 0 : aResult.Append(aHost);
187 0 : aResult.Append(':');
188 0 : aResult.Append(nsPrintfCString("%d", aPort));
189 0 : }
190 :
191 : static nsresult
192 0 : GetProxyFromEnvironment(const nsACString& aScheme,
193 : const nsACString& aHost,
194 : PRInt32 aPort,
195 : nsACString& aResult)
196 : {
197 0 : nsCAutoString envVar;
198 0 : envVar.Append(aScheme);
199 0 : envVar.AppendLiteral("_proxy");
200 0 : const char* proxyVal = PR_GetEnv(envVar.get());
201 0 : if (!proxyVal) {
202 0 : proxyVal = PR_GetEnv("all_proxy");
203 0 : if (!proxyVal) {
204 : // Return failure so that the caller can detect the failure and
205 : // fall back to other proxy detection (e.g., WPAD)
206 0 : return NS_ERROR_FAILURE;
207 : }
208 : }
209 :
210 0 : const char* noProxyVal = PR_GetEnv("no_proxy");
211 0 : if (noProxyVal && IsInNoProxyList(aHost, aPort, noProxyVal)) {
212 0 : aResult.AppendLiteral("DIRECT");
213 0 : return NS_OK;
214 : }
215 :
216 : // Use our URI parser to crack the proxy URI
217 0 : nsCOMPtr<nsIURI> proxyURI;
218 0 : nsresult rv = NS_NewURI(getter_AddRefs(proxyURI), proxyVal);
219 0 : NS_ENSURE_SUCCESS(rv, rv);
220 :
221 : // Is there a way to specify "socks://" or something in these environment
222 : // variables? I can't find any documentation.
223 : bool isHTTP;
224 0 : rv = proxyURI->SchemeIs("http", &isHTTP);
225 0 : NS_ENSURE_SUCCESS(rv, rv);
226 0 : if (!isHTTP)
227 0 : return NS_ERROR_UNKNOWN_PROTOCOL;
228 :
229 0 : nsCAutoString proxyHost;
230 0 : rv = proxyURI->GetHost(proxyHost);
231 0 : NS_ENSURE_SUCCESS(rv, rv);
232 :
233 : PRInt32 proxyPort;
234 0 : rv = proxyURI->GetPort(&proxyPort);
235 0 : NS_ENSURE_SUCCESS(rv, rv);
236 :
237 0 : SetProxyResult("PROXY", proxyHost, proxyPort, aResult);
238 0 : return NS_OK;
239 : }
240 :
241 : nsresult
242 0 : nsUnixSystemProxySettings::SetProxyResultFromGConf(const char* aKeyBase, const char* aType,
243 : nsACString& aResult)
244 : {
245 0 : nsCAutoString hostKey;
246 0 : hostKey.AppendASCII(aKeyBase);
247 0 : hostKey.AppendLiteral("host");
248 0 : nsCAutoString host;
249 0 : nsresult rv = mGConf->GetString(hostKey, host);
250 0 : NS_ENSURE_SUCCESS(rv, rv);
251 0 : if (host.IsEmpty())
252 0 : return NS_ERROR_FAILURE;
253 :
254 0 : nsCAutoString portKey;
255 0 : portKey.AppendASCII(aKeyBase);
256 0 : portKey.AppendLiteral("port");
257 : PRInt32 port;
258 0 : rv = mGConf->GetInt(portKey, &port);
259 0 : NS_ENSURE_SUCCESS(rv, rv);
260 :
261 : /* When port is 0, proxy is not considered as enabled even if host is set. */
262 0 : if (port == 0)
263 0 : return NS_ERROR_FAILURE;
264 :
265 0 : SetProxyResult(aType, host, port, aResult);
266 0 : return NS_OK;
267 : }
268 :
269 : nsresult
270 0 : nsUnixSystemProxySettings::SetProxyResultFromGSettings(const char* aKeyBase, const char* aType,
271 : nsACString& aResult)
272 : {
273 0 : nsDependentCString key(aKeyBase);
274 :
275 0 : nsCOMPtr<nsIGSettingsCollection> proxy_settings = mSchemeProxySettings.Get(key);
276 : nsresult rv;
277 0 : if (!proxy_settings) {
278 0 : rv = mGSettings->GetCollectionForSchema(key, getter_AddRefs(proxy_settings));
279 0 : NS_ENSURE_SUCCESS(rv, rv);
280 :
281 0 : mSchemeProxySettings.Put(key, proxy_settings);
282 : }
283 :
284 0 : nsCAutoString host;
285 0 : rv = proxy_settings->GetString(NS_LITERAL_CSTRING("host"), host);
286 0 : NS_ENSURE_SUCCESS(rv, rv);
287 0 : if (host.IsEmpty())
288 0 : return NS_ERROR_FAILURE;
289 :
290 : PRInt32 port;
291 0 : rv = proxy_settings->GetInt(NS_LITERAL_CSTRING("port"), &port);
292 0 : NS_ENSURE_SUCCESS(rv, rv);
293 :
294 : /* When port is 0, proxy is not considered as enabled even if host is set. */
295 0 : if (port == 0)
296 0 : return NS_ERROR_FAILURE;
297 :
298 0 : SetProxyResult(aType, host, port, aResult);
299 0 : return NS_OK;
300 : }
301 :
302 : /* copied from nsProtocolProxyService.cpp --- we should share this! */
303 : static void
304 0 : proxy_MaskIPv6Addr(PRIPv6Addr &addr, PRUint16 mask_len)
305 : {
306 0 : if (mask_len == 128)
307 0 : return;
308 :
309 0 : if (mask_len > 96) {
310 : addr.pr_s6_addr32[3] = PR_htonl(
311 0 : PR_ntohl(addr.pr_s6_addr32[3]) & (~0L << (128 - mask_len)));
312 : }
313 0 : else if (mask_len > 64) {
314 0 : addr.pr_s6_addr32[3] = 0;
315 : addr.pr_s6_addr32[2] = PR_htonl(
316 0 : PR_ntohl(addr.pr_s6_addr32[2]) & (~0L << (96 - mask_len)));
317 : }
318 0 : else if (mask_len > 32) {
319 0 : addr.pr_s6_addr32[3] = 0;
320 0 : addr.pr_s6_addr32[2] = 0;
321 : addr.pr_s6_addr32[1] = PR_htonl(
322 0 : PR_ntohl(addr.pr_s6_addr32[1]) & (~0L << (64 - mask_len)));
323 : }
324 : else {
325 0 : addr.pr_s6_addr32[3] = 0;
326 0 : addr.pr_s6_addr32[2] = 0;
327 0 : addr.pr_s6_addr32[1] = 0;
328 : addr.pr_s6_addr32[0] = PR_htonl(
329 0 : PR_ntohl(addr.pr_s6_addr32[0]) & (~0L << (32 - mask_len)));
330 : }
331 : }
332 :
333 0 : static bool ConvertToIPV6Addr(const nsACString& aName,
334 : PRIPv6Addr* aAddr)
335 : {
336 : PRNetAddr addr;
337 : // try to convert hostname to IP
338 0 : if (PR_StringToNetAddr(PromiseFlatCString(aName).get(), &addr) != PR_SUCCESS)
339 0 : return false;
340 :
341 : // convert parsed address to IPv6
342 0 : if (addr.raw.family == PR_AF_INET) {
343 : // convert to IPv4-mapped address
344 0 : PR_ConvertIPv4AddrToIPv6(addr.inet.ip, aAddr);
345 0 : } else if (addr.raw.family == PR_AF_INET6) {
346 : // copy the address
347 0 : memcpy(aAddr, &addr.ipv6.ip, sizeof(PRIPv6Addr));
348 : } else {
349 0 : return false;
350 : }
351 :
352 0 : return true;
353 : }
354 :
355 0 : static bool HostIgnoredByProxy(const nsACString& aIgnore,
356 : const nsACString& aHost)
357 : {
358 0 : if (aIgnore.Equals(aHost, nsCaseInsensitiveCStringComparator()))
359 0 : return true;
360 :
361 0 : if (aIgnore.First() == '*' &&
362 0 : StringEndsWith(aHost, nsDependentCSubstring(aIgnore, 1),
363 0 : nsCaseInsensitiveCStringComparator()))
364 0 : return true;
365 :
366 0 : PRInt32 mask = 128;
367 0 : nsReadingIterator<char> start;
368 0 : nsReadingIterator<char> slash;
369 0 : nsReadingIterator<char> end;
370 0 : aIgnore.BeginReading(start);
371 0 : aIgnore.BeginReading(slash);
372 0 : aIgnore.EndReading(end);
373 0 : if (FindCharInReadable('/', slash, end)) {
374 0 : ++slash;
375 0 : nsDependentCSubstring maskStr(slash, end);
376 0 : nsCAutoString maskStr2(maskStr);
377 : PRInt32 err;
378 0 : mask = maskStr2.ToInteger(&err);
379 0 : if (err != 0) {
380 0 : mask = 128;
381 : }
382 0 : --slash;
383 : } else {
384 0 : slash = end;
385 : }
386 :
387 0 : nsDependentCSubstring ignoreStripped(start, slash);
388 : PRIPv6Addr ignoreAddr, hostAddr;
389 0 : if (!ConvertToIPV6Addr(ignoreStripped, &ignoreAddr) ||
390 0 : !ConvertToIPV6Addr(aHost, &hostAddr))
391 0 : return false;
392 :
393 0 : proxy_MaskIPv6Addr(ignoreAddr, mask);
394 0 : proxy_MaskIPv6Addr(hostAddr, mask);
395 :
396 0 : return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
397 : }
398 :
399 : nsresult
400 3417 : nsUnixSystemProxySettings::GetProxyFromGConf(const nsACString& aScheme,
401 : const nsACString& aHost,
402 : PRInt32 aPort,
403 : nsACString& aResult)
404 : {
405 3417 : bool masterProxySwitch = false;
406 3417 : mGConf->GetBool(NS_LITERAL_CSTRING("/system/http_proxy/use_http_proxy"), &masterProxySwitch);
407 3417 : if (!IsProxyMode("manual") || !masterProxySwitch) {
408 3417 : aResult.AppendLiteral("DIRECT");
409 3417 : return NS_OK;
410 : }
411 :
412 0 : nsCOMPtr<nsIArray> ignoreList;
413 0 : if (NS_SUCCEEDED(mGConf->GetStringList(NS_LITERAL_CSTRING("/system/http_proxy/ignore_hosts"),
414 0 : getter_AddRefs(ignoreList))) && ignoreList) {
415 0 : PRUint32 len = 0;
416 0 : ignoreList->GetLength(&len);
417 0 : for (PRUint32 i = 0; i < len; ++i) {
418 0 : nsCOMPtr<nsISupportsString> str = do_QueryElementAt(ignoreList, i);
419 0 : if (str) {
420 0 : nsAutoString s;
421 0 : if (NS_SUCCEEDED(str->GetData(s)) && !s.IsEmpty()) {
422 0 : if (HostIgnoredByProxy(NS_ConvertUTF16toUTF8(s), aHost)) {
423 0 : aResult.AppendLiteral("DIRECT");
424 0 : return NS_OK;
425 : }
426 : }
427 : }
428 : }
429 : }
430 :
431 0 : bool useHttpProxyForAll = false;
432 : // This setting sometimes doesn't exist, don't bail on failure
433 0 : mGConf->GetBool(NS_LITERAL_CSTRING("/system/http_proxy/use_same_proxy"), &useHttpProxyForAll);
434 :
435 : nsresult rv;
436 0 : if (!useHttpProxyForAll) {
437 0 : rv = SetProxyResultFromGConf("/system/proxy/socks_", "SOCKS", aResult);
438 0 : if (NS_SUCCEEDED(rv))
439 0 : return rv;
440 : }
441 :
442 0 : if (aScheme.LowerCaseEqualsLiteral("http") || useHttpProxyForAll) {
443 0 : rv = SetProxyResultFromGConf("/system/http_proxy/", "PROXY", aResult);
444 0 : } else if (aScheme.LowerCaseEqualsLiteral("https")) {
445 0 : rv = SetProxyResultFromGConf("/system/proxy/secure_", "PROXY", aResult);
446 0 : } else if (aScheme.LowerCaseEqualsLiteral("ftp")) {
447 0 : rv = SetProxyResultFromGConf("/system/proxy/ftp_", "PROXY", aResult);
448 : } else {
449 0 : rv = NS_ERROR_FAILURE;
450 : }
451 :
452 0 : if (NS_FAILED(rv)) {
453 0 : aResult.AppendLiteral("DIRECT");
454 : }
455 0 : return NS_OK;
456 : }
457 :
458 : nsresult
459 0 : nsUnixSystemProxySettings::GetProxyFromGSettings(const nsACString& aScheme,
460 : const nsACString& aHost,
461 : PRInt32 aPort,
462 : nsACString& aResult)
463 : {
464 0 : nsCString proxyMode;
465 0 : nsresult rv = mProxySettings->GetString(NS_LITERAL_CSTRING("mode"), proxyMode);
466 0 : NS_ENSURE_SUCCESS(rv, rv);
467 :
468 0 : if (!proxyMode.Equals("manual")) {
469 0 : aResult.AppendLiteral("DIRECT");
470 0 : return NS_OK;
471 : }
472 :
473 0 : nsCOMPtr<nsIArray> ignoreList;
474 0 : if (NS_SUCCEEDED(mProxySettings->GetStringList(NS_LITERAL_CSTRING("ignore-hosts"),
475 0 : getter_AddRefs(ignoreList))) && ignoreList) {
476 0 : PRUint32 len = 0;
477 0 : ignoreList->GetLength(&len);
478 0 : for (PRUint32 i = 0; i < len; ++i) {
479 0 : nsCOMPtr<nsISupportsCString> str = do_QueryElementAt(ignoreList, i);
480 0 : if (str) {
481 0 : nsCString s;
482 0 : if (NS_SUCCEEDED(str->GetData(s)) && !s.IsEmpty()) {
483 0 : if (HostIgnoredByProxy(s, aHost)) {
484 0 : aResult.AppendLiteral("DIRECT");
485 0 : return NS_OK;
486 : }
487 : }
488 : }
489 : }
490 : }
491 :
492 0 : if (aScheme.LowerCaseEqualsLiteral("http")) {
493 0 : rv = SetProxyResultFromGSettings("org.gnome.system.proxy.http", "PROXY", aResult);
494 0 : } else if (aScheme.LowerCaseEqualsLiteral("https")) {
495 0 : rv = SetProxyResultFromGSettings("org.gnome.system.proxy.https", "PROXY", aResult);
496 : /* Try to use HTTP proxy when HTTPS proxy is not explicitly defined */
497 0 : if (rv != NS_OK)
498 0 : rv = SetProxyResultFromGSettings("org.gnome.system.proxy.http", "PROXY", aResult);
499 0 : } else if (aScheme.LowerCaseEqualsLiteral("ftp")) {
500 0 : rv = SetProxyResultFromGSettings("org.gnome.system.proxy.ftp", "PROXY", aResult);
501 : } else {
502 0 : rv = NS_ERROR_FAILURE;
503 : }
504 0 : if (rv != NS_OK) {
505 : /* If proxy for scheme is not specified, use SOCKS proxy for all schemes */
506 0 : rv = SetProxyResultFromGSettings("org.gnome.system.proxy.socks", "SOCKS", aResult);
507 : }
508 :
509 0 : if (NS_FAILED(rv)) {
510 0 : aResult.AppendLiteral("DIRECT");
511 : }
512 :
513 0 : return NS_OK;
514 : }
515 :
516 : nsresult
517 3420 : nsUnixSystemProxySettings::GetProxyForURI(nsIURI* aURI, nsACString& aResult)
518 : {
519 6840 : nsCAutoString scheme;
520 3420 : nsresult rv = aURI->GetScheme(scheme);
521 3420 : NS_ENSURE_SUCCESS(rv, rv);
522 :
523 6840 : nsCAutoString host;
524 3420 : rv = aURI->GetHost(host);
525 3420 : NS_ENSURE_SUCCESS(rv, rv);
526 :
527 : PRInt32 port;
528 3417 : rv = aURI->GetPort(&port);
529 3417 : NS_ENSURE_SUCCESS(rv, rv);
530 :
531 3417 : if (mProxySettings) {
532 0 : rv = GetProxyFromGSettings(scheme, host, port, aResult);
533 0 : if (rv == NS_OK)
534 0 : return rv;
535 : }
536 3417 : if (mGConf)
537 3417 : return GetProxyFromGConf(scheme, host, port, aResult);
538 :
539 0 : return GetProxyFromEnvironment(scheme, host, port, aResult);
540 : }
541 :
542 : #define NS_UNIXSYSTEMPROXYSERVICE_CID /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
543 : { 0x0fa3158c, 0xd5a7, 0x43de, \
544 : {0x91, 0x81, 0xa2, 0x85, 0xe7, 0x4c, 0xf1, 0xd4 } }
545 :
546 538 : NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUnixSystemProxySettings, Init)
547 : NS_DEFINE_NAMED_CID(NS_UNIXSYSTEMPROXYSERVICE_CID);
548 :
549 : static const mozilla::Module::CIDEntry kUnixProxyCIDs[] = {
550 : { &kNS_UNIXSYSTEMPROXYSERVICE_CID, false, NULL, nsUnixSystemProxySettingsConstructor },
551 : { NULL }
552 : };
553 :
554 : static const mozilla::Module::ContractIDEntry kUnixProxyContracts[] = {
555 : { NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_UNIXSYSTEMPROXYSERVICE_CID },
556 : { NULL }
557 : };
558 :
559 : static const mozilla::Module kUnixProxyModule = {
560 : mozilla::Module::kVersion,
561 : kUnixProxyCIDs,
562 : kUnixProxyContracts
563 : };
564 :
565 : NSMODULE_DEFN(nsUnixProxyModule) = &kUnixProxyModule;
|