зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 20ae968df114 (bug 939318)
This commit is contained in:
Родитель
1d05ce0049
Коммит
7bbf083a70
|
@ -29,7 +29,6 @@
|
|||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "nsISystemProxySettings.h"
|
||||
#include "nsINetworkLinkService.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
@ -340,7 +339,7 @@ proxy_GetIntPref(nsIPrefBranch *aPrefBranch,
|
|||
{
|
||||
int32_t temp;
|
||||
nsresult rv = aPrefBranch->GetIntPref(aPref, &temp);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
aResult = -1;
|
||||
else
|
||||
aResult = temp;
|
||||
|
@ -353,7 +352,7 @@ proxy_GetBoolPref(nsIPrefBranch *aPrefBranch,
|
|||
{
|
||||
bool temp;
|
||||
nsresult rv = aPrefBranch->GetBoolPref(aPref, &temp);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
aResult = false;
|
||||
else
|
||||
aResult = temp;
|
||||
|
@ -415,66 +414,14 @@ nsProtocolProxyService::Init()
|
|||
PrefsChanged(prefBranch, nullptr);
|
||||
}
|
||||
|
||||
// register for shutdown notification so we can clean ourselves up properly.
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
// register for shutdown notification so we can clean ourselves up
|
||||
// properly.
|
||||
if (obs)
|
||||
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
|
||||
obs->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// ReloadNetworkPAC() checks if there's a non-networked PAC in use then avoids
|
||||
// to call ReloadPAC()
|
||||
nsresult
|
||||
nsProtocolProxyService::ReloadNetworkPAC()
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefs =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t type;
|
||||
nsresult rv = prefs->GetIntPref(PROXY_PREF("type"), &type);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (type == PROXYCONFIG_PAC) {
|
||||
nsXPIDLCString pacSpec;
|
||||
prefs->GetCharPref(PROXY_PREF("autoconfig_url"),
|
||||
getter_Copies(pacSpec));
|
||||
if (!pacSpec.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> pacURI;
|
||||
rv = NS_NewURI(getter_AddRefs(pacURI), pacSpec);
|
||||
if(!NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsProtocolInfo pac;
|
||||
rv = GetProtocolInfo(pacURI, &pac);
|
||||
if(!NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!pac.scheme.EqualsLiteral("file") &&
|
||||
!pac.scheme.EqualsLiteral("data")) {
|
||||
LOG((": received network changed event, reload PAC"));
|
||||
ReloadPAC();
|
||||
}
|
||||
}
|
||||
} else if ((type == PROXYCONFIG_WPAD) || (type == PROXYCONFIG_SYSTEM)) {
|
||||
ReloadPAC();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
|
@ -493,12 +440,6 @@ nsProtocolProxyService::Observe(nsISupports *aSubject,
|
|||
mPACMan->Shutdown();
|
||||
mPACMan = nullptr;
|
||||
}
|
||||
} else if (strcmp(aTopic, NS_NETWORK_LINK_TOPIC) == 0) {
|
||||
nsCString converted = NS_ConvertUTF16toUTF8(aData);
|
||||
const char *state = converted.get();
|
||||
if (!strcmp(state, NS_NETWORK_LINK_DATA_CHANGED)) {
|
||||
ReloadNetworkPAC();
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
|
||||
|
@ -572,7 +513,7 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
|
|||
|
||||
if (!pref || !strcmp(pref, PROXY_PREF("socks")))
|
||||
proxy_GetStringPref(prefBranch, PROXY_PREF("socks"), mSOCKSProxyHost);
|
||||
|
||||
|
||||
if (!pref || !strcmp(pref, PROXY_PREF("socks_port")))
|
||||
proxy_GetIntPref(prefBranch, PROXY_PREF("socks_port"), mSOCKSProxyPort);
|
||||
|
||||
|
@ -646,14 +587,14 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
|
|||
}
|
||||
|
||||
bool
|
||||
nsProtocolProxyService::CanUseProxy(nsIURI *aURI, int32_t defaultPort)
|
||||
nsProtocolProxyService::CanUseProxy(nsIURI *aURI, int32_t defaultPort)
|
||||
{
|
||||
if (mHostFiltersArray.Length() == 0)
|
||||
return true;
|
||||
|
||||
int32_t port;
|
||||
nsAutoCString host;
|
||||
|
||||
|
||||
nsresult rv = aURI->GetAsciiHost(host);
|
||||
if (NS_FAILED(rv) || host.IsEmpty())
|
||||
return false;
|
||||
|
@ -683,7 +624,7 @@ nsProtocolProxyService::CanUseProxy(nsIURI *aURI, int32_t defaultPort)
|
|||
return true; // allow proxying
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Don't use proxy for local hosts (plain hostname, no dots)
|
||||
if (!is_ipaddr && mFilterLocalHosts && (kNotFound == host.FindChar('.'))) {
|
||||
LOG(("Not using proxy for this local host [%s]!\n", host.get()));
|
||||
|
@ -869,7 +810,7 @@ nsProtocolProxyService::GetProxyKey(nsProxyInfo *pi, nsCString &key)
|
|||
key.Append(':');
|
||||
key.AppendInt(pi->mPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsProtocolProxyService::SecondsSinceSessionStart()
|
||||
|
@ -1390,7 +1331,7 @@ nsProtocolProxyService::LoadHostFilters(const char *filters)
|
|||
return; // fail silently...
|
||||
|
||||
//
|
||||
// filter = ( host | domain | ipaddr ["/" mask] ) [":" port]
|
||||
// filter = ( host | domain | ipaddr ["/" mask] ) [":" port]
|
||||
// filters = filter *( "," LWS filter)
|
||||
//
|
||||
// Reset mFilterLocalHosts - will be set to true if "<local>" is in pref string
|
||||
|
@ -1402,7 +1343,7 @@ nsProtocolProxyService::LoadHostFilters(const char *filters)
|
|||
|
||||
const char *starthost = filters;
|
||||
const char *endhost = filters + 1; // at least that...
|
||||
const char *portLocation = 0;
|
||||
const char *portLocation = 0;
|
||||
const char *maskLocation = 0;
|
||||
|
||||
while (*endhost && (*endhost != ',' && !IS_ASCII_SPACE(*endhost))) {
|
||||
|
|
|
@ -280,7 +280,6 @@ protected:
|
|||
private:
|
||||
nsresult SetupPACThread();
|
||||
nsresult ResetPACThread();
|
||||
nsresult ReloadNetworkPAC();
|
||||
|
||||
public:
|
||||
// The Sun Forte compiler and others implement older versions of the
|
||||
|
|
Загрузка…
Ссылка в новой задаче