@@ -0,0 +1,933 @@
+Index: netwerk/base/public/nsISystemProxySettings.idl
+================================================================================
+--- allmakefiles.sh
++++ allmakefiles.sh
+@@ -984,6 +984,7 @@
+ toolkit/components/downloads/src/Makefile
+ toolkit/components/filepicker/Makefile
+ toolkit/components/gnome/Makefile
++toolkit/components/unixproxy/Makefile
+ toolkit/components/help/Makefile
+ toolkit/components/history/Makefile
+ toolkit/components/history/public/Makefile
+--- browser/components/preferences/connection.xul
++++ browser/components/preferences/connection.xul
+@@ -38,7 +38,12 @@
+ #
+ # ***** END LICENSE BLOCK *****
+
+-<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/connection.dtd">
++<!DOCTYPE prefwindow [
++ <!ENTITY % connectionDTD SYSTEM "chrome://browser/locale/preferences/connection.dtd">
++ %connectionDTD;
++ <!ENTITY % mainDTD SYSTEM "chrome://browser/locale/preferences/main.dtd">
++ %mainDTD;
++]>
+
+ <?xml-stylesheet href="chrome://global/skin/"?>
+
+@@ -99,6 +104,7 @@
+ <radiogroup id="networkProxyType" preference="network.proxy.type"
+ onsyncfrompreference="return gConnectionsDialog.readProxyType();">
+ <radio value="0" label="&directTypeRadio.label;" accesskey="&directTypeRadio.accesskey;"/>
++ <radio value="5" label="&systemDefaults.label;" />
+ <radio value="4" label="&WPADTypeRadio.label;" accesskey="&WPADTypeRadio.accesskey;"/>
+ <radio value="1" label="&manualTypeRadio.label;" accesskey="&manualTypeRadio.accesskey;"/>
+ <grid class="indent" flex="1">
+--- browser/installer/unix/packages-static
++++ browser/installer/unix/packages-static
+@@ -51,6 +51,7 @@
+ bin/xpicleanup
+
+ ; [Components]
++bin/components/libunixproxy.so
+ bin/components/accessibility.xpt
+ bin/components/accessibility-atk.xpt
+ bin/components/appshell.xpt
+--- netwerk/base/public/Makefile.in
++++ netwerk/base/public/Makefile.in
+@@ -98,6 +98,7 @@
+ nsIStreamTransportService.idl \
+ nsIStreamLoader.idl \
+ nsISyncStreamListener.idl \
++ nsISystemProxySettings.idl \
+ nsIUnicharStreamLoader.idl \
+ nsIStandardURL.idl \
+ nsIURLParser.idl \
+--- netwerk/base/public/nsISystemProxySettings.idl
++++ netwerk/base/public/nsISystemProxySettings.idl
+@@ -0,0 +1,65 @@
++/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is Novell code.
++ *
++ * The Initial Developer of the Original Code is Novell.
++ * Portions created by the Initial Developer are Copyright (C) 2005
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ * Robert O'Callahan (rocallahan@novell.com)
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either the GNU General Public License Version 2 or later (the "GPL"), or
++ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++#include "nsISupports.idl"
++#include "nsIURI.idl"
++
++%{C++
++#define NS_SYSTEMPROXYSETTINGS_CONTRACTID "@mozilla.org/system-proxy-settings;1"
++%}
++
++/**
++ * This interface allows the proxy code to use platform-specific proxy
++ * settings when the proxy preference is set to "automatic discovery". If it can
++ * load a service with the above contract ID, it will use it to determine the
++ * PAC file name. If no PAC file is specified then the service itself will behave
++ * like a PAC file.
++ */
++[scriptable, uuid(a9f3ae38-b769-4e0b-9317-578388e326c9)]
++interface nsISystemProxySettings : nsISupports
++{
++ /**
++ * If non-empty, use this PAC file. If empty, call getProxyForURI instead.
++ */
++ readonly attribute AUTF8String PACURI;
++
++ /**
++ * See nsIProxyAutoConfig::getProxyForURI; this function behaves exactly
++ * the same way.
++ */
++ ACString getProxyForURI(in nsIURI aURI);
++};
+--- netwerk/base/src/nsPACMan.h
++++ netwerk/base/src/nsPACMan.h
+@@ -128,6 +128,14 @@
+ */
+ PRBool IsLoading() { return mLoader != nsnull; }
+
++ /**
++ * Returns true if the given URI matches the URI of our PAC file.
++ */
++ PRBool IsPACURI(nsIURI *uri) {
++ PRBool result;
++ return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result;
++ }
++
+ private:
+ NS_DECL_NSISTREAMLOADEROBSERVER
+ NS_DECL_NSIINTERFACEREQUESTOR
+@@ -163,14 +171,6 @@
+ void OnLoadFailure();
+
+ /**
+- * Returns true if the given URI matches the URI of our PAC file.
+- */
+- PRBool IsPACURI(nsIURI *uri) {
+- PRBool result;
+- return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result;
+- }
+-
+- /**
+ * Event fu for calling StartLoading asynchronously.
+ */
+ PR_STATIC_CALLBACK(void *) LoadEvent_Handle(PLEvent *);
+--- netwerk/base/src/nsProtocolProxyService.cpp
++++ netwerk/base/src/nsProtocolProxyService.cpp
+@@ -411,6 +411,12 @@
+ mProxyConfig = NS_STATIC_CAST(ProxyConfig, type);
+ reloadPAC = PR_TRUE;
+ }
++
++ if (mProxyConfig == eProxyConfig_System) {
++ mSystemProxySettings = do_GetService(NS_SYSTEMPROXYSETTINGS_CONTRACTID);
++ } else {
++ mSystemProxySettings = nsnull;
++ }
+ }
+
+ if (!pref || !strcmp(pref, "network.proxy.http"))
+@@ -466,8 +472,10 @@
+ LoadHostFilters(tempString.get());
+ }
+
+- // We're done if not using PAC or WPAD
+- if (mProxyConfig != eProxyConfig_PAC && mProxyConfig != eProxyConfig_WPAD)
++ // We're done if not using something that could give us a PAC URL
++ // (PAC, WPAD or System)
++ if (mProxyConfig != eProxyConfig_PAC && mProxyConfig != eProxyConfig_WPAD &&
++ mProxyConfig != eProxyConfig_System)
+ return;
+
+ // OK, we need to reload the PAC file if:
+@@ -482,17 +490,21 @@
+ if (mProxyConfig == eProxyConfig_PAC) {
+ prefBranch->GetCharPref("network.proxy.autoconfig_url",
+ getter_Copies(tempString));
+- }
+- else if (mProxyConfig == eProxyConfig_WPAD) {
++ } else {
+ // We diverge from the WPAD spec here in that we don't walk the
+ // hosts's FQDN, stripping components until we hit a TLD. Doing so
+ // is dangerous in the face of an incomplete list of TLDs, and TLDs
+ // get added over time. We could consider doing only a single
+ // substitution of the first component, if that proves to help
+ // compatibility.
+- tempString.AssignLiteral("http://wpad/wpad.dat");
++ if (mSystemProxySettings)
|