mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 870704 - [Buri][Shira-49020] There is no option to configure a proxy for WiFi connections. r=vchang, sr=mrbkap
This commit is contained in:
parent
e419f5d181
commit
3c403e6122
@ -606,7 +606,7 @@ NetworkManager.prototype = {
|
||||
dns2_str: this.active.dns2
|
||||
};
|
||||
this.worker.postMessage(options);
|
||||
this.setNetworkProxy();
|
||||
this.setNetworkProxy(this.active);
|
||||
},
|
||||
|
||||
removeDefaultRoute: function removeDefaultRoute(ifname) {
|
||||
@ -689,9 +689,9 @@ NetworkManager.prototype = {
|
||||
this.worker.postMessage(options);
|
||||
},
|
||||
|
||||
setNetworkProxy: function setNetworkProxy() {
|
||||
setNetworkProxy: function setNetworkProxy(network) {
|
||||
try {
|
||||
if (!this.active.httpProxyHost || this.active.httpProxyHost == "") {
|
||||
if (!network.httpProxyHost || network.httpProxyHost == "") {
|
||||
// Sets direct connection to internet.
|
||||
Services.prefs.clearUserPref("network.proxy.type");
|
||||
Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
|
||||
@ -699,23 +699,23 @@ NetworkManager.prototype = {
|
||||
Services.prefs.clearUserPref("network.proxy.http_port");
|
||||
Services.prefs.clearUserPref("network.proxy.ssl");
|
||||
Services.prefs.clearUserPref("network.proxy.ssl_port");
|
||||
debug("No proxy support for " + this.active.name + " network interface.");
|
||||
debug("No proxy support for " + network.name + " network interface.");
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Going to set proxy settings for " + this.active.name + " network interface.");
|
||||
debug("Going to set proxy settings for " + network.name + " network interface.");
|
||||
// Sets manual proxy configuration.
|
||||
Services.prefs.setIntPref("network.proxy.type", MANUAL_PROXY_CONFIGURATION);
|
||||
// Do not use this proxy server for all protocols.
|
||||
Services.prefs.setBoolPref("network.proxy.share_proxy_settings", false);
|
||||
Services.prefs.setCharPref("network.proxy.http", this.active.httpProxyHost);
|
||||
Services.prefs.setCharPref("network.proxy.ssl", this.active.httpProxyHost);
|
||||
let port = this.active.httpProxyPort == "" ? 8080 : this.active.httpProxyPort;
|
||||
Services.prefs.setCharPref("network.proxy.http", network.httpProxyHost);
|
||||
Services.prefs.setCharPref("network.proxy.ssl", network.httpProxyHost);
|
||||
let port = network.httpProxyPort == 0 ? 8080 : network.httpProxyPort;
|
||||
Services.prefs.setIntPref("network.proxy.http_port", port);
|
||||
Services.prefs.setIntPref("network.proxy.ssl_port", port);
|
||||
} catch (ex) {
|
||||
debug("Exception " + ex + ". Unable to set proxy setting for "
|
||||
+ this.active.name + " network interface.");
|
||||
+ network.name + " network interface.");
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
@ -119,7 +119,7 @@ interface nsIWifiOperationModeCallback : nsISupports
|
||||
/**
|
||||
* Manage network interfaces.
|
||||
*/
|
||||
[scriptable, uuid(5b22c620-f8b9-11e2-b778-0800200c9a66)]
|
||||
[scriptable, uuid(fad3fb08-664f-48e3-bba3-423186988c61)]
|
||||
interface nsINetworkManager : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -231,4 +231,12 @@ interface nsINetworkManager : nsISupports
|
||||
* Callback to notify Wifi firmware reload result.
|
||||
*/
|
||||
void setWifiOperationMode(in DOMString interfaceName, in DOMString mode, in nsIWifiOperationModeCallback callback);
|
||||
|
||||
/**
|
||||
* Set http proxy for specific network
|
||||
*
|
||||
* @param network
|
||||
* Network interface to register.
|
||||
*/
|
||||
void setNetworkProxy(in nsINetworkInterface network);
|
||||
};
|
||||
|
@ -87,6 +87,7 @@ DOMWifiManager.prototype = {
|
||||
"WifiManager:forget:Return:OK", "WifiManager:forget:Return:NO",
|
||||
"WifiManager:wps:Return:OK", "WifiManager:wps:Return:NO",
|
||||
"WifiManager:setPowerSavingMode:Return:OK", "WifiManager:setPowerSavingMode:Return:NO",
|
||||
"WifiManager:setHttpProxy:Return:OK", "WifiManager:setHttpProxy:Return:NO",
|
||||
"WifiManager:setStaticIpMode:Return:OK", "WifiManager:setStaticIpMode:Return:NO",
|
||||
"WifiManager:wifiDown", "WifiManager:wifiUp",
|
||||
"WifiManager:onconnecting", "WifiManager:onassociate",
|
||||
@ -194,6 +195,16 @@ DOMWifiManager.prototype = {
|
||||
Services.DOMRequest.fireError(request, msg.data);
|
||||
break;
|
||||
|
||||
case "WifiManager:setHttpProxy:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
break;
|
||||
|
||||
case "WifiManager:setHttpProxy:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, msg.data);
|
||||
break;
|
||||
|
||||
case "WifiManager:setStaticIpMode:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
@ -360,6 +371,14 @@ DOMWifiManager.prototype = {
|
||||
return request;
|
||||
},
|
||||
|
||||
setHttpProxy: function nsIDOMWifiManager_setHttpProxy(network, info) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
var request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiManager:setHttpProxy", {network:network, info:info}, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
setStaticIpMode: function nsIDOMWifiManager_setStaticIpMode(network, info) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
|
@ -647,6 +647,48 @@ var WifiManager = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
var httpProxyConfig = Object.create(null);
|
||||
|
||||
/**
|
||||
* Given a network, configure http proxy when using wifi.
|
||||
* @param network A network object to update http proxy
|
||||
* @param info Info should have following field:
|
||||
* - httpProxyHost ip address of http proxy.
|
||||
* - httpProxyPort port of http proxy, set 0 to use default port 8080.
|
||||
* @param callback callback function.
|
||||
*/
|
||||
function configureHttpProxy(network, info, callback) {
|
||||
if (!network)
|
||||
return;
|
||||
|
||||
let networkKey = getNetworkKey(network);
|
||||
|
||||
if (!info || info.httpProxyHost === "") {
|
||||
delete httpProxyConfig[networkKey];
|
||||
} else {
|
||||
httpProxyConfig[networkKey] = network;
|
||||
httpProxyConfig[networkKey].httpProxyHost = info.httpProxyHost;
|
||||
httpProxyConfig[networkKey].httpProxyPort = info.httpProxyPort;
|
||||
}
|
||||
|
||||
callback(true);
|
||||
}
|
||||
|
||||
function getHttpProxyNetwork(network) {
|
||||
if (!network)
|
||||
return null;
|
||||
|
||||
let networkKey = getNetworkKey(network);
|
||||
return ((networkKey in httpProxyConfig) ? httpProxyConfig : null);
|
||||
}
|
||||
|
||||
function setHttpProxy(network) {
|
||||
if (!network)
|
||||
return;
|
||||
|
||||
gNetworkManager.setNetworkProxy(network);
|
||||
}
|
||||
|
||||
var staticIpConfig = Object.create(null);
|
||||
function setStaticIpMode(network, info, callback) {
|
||||
let setNetworkKey = getNetworkKey(network);
|
||||
@ -1548,6 +1590,9 @@ var WifiManager = (function() {
|
||||
manager.setPowerMode = (sdkVersion >= 16)
|
||||
? setPowerModeCommandJB
|
||||
: setPowerModeCommandICS;
|
||||
manager.getHttpProxyNetwork = getHttpProxyNetwork;
|
||||
manager.setHttpProxy = setHttpProxy;
|
||||
manager.configureHttpProxy = configureHttpProxy;
|
||||
manager.setSuspendOptimizations = setSuspendOptimizationsCommand;
|
||||
manager.setStaticIpMode = setStaticIpMode;
|
||||
manager.getRssiApprox = getRssiApproxCommand;
|
||||
@ -1851,6 +1896,7 @@ function WifiWorker() {
|
||||
"WifiManager:associate", "WifiManager:forget",
|
||||
"WifiManager:wps", "WifiManager:getState",
|
||||
"WifiManager:setPowerSavingMode",
|
||||
"WifiManager:setHttpProxy",
|
||||
"WifiManager:setStaticIpMode",
|
||||
"child-process-shutdown"];
|
||||
|
||||
@ -2160,6 +2206,11 @@ function WifiWorker() {
|
||||
WifiManager.getNetworkConfiguration(self.currentNetwork, function(){});
|
||||
}
|
||||
|
||||
// Update http proxy when connected to network.
|
||||
let netConnect = WifiManager.getHttpProxyNetwork(self.currentNetwork);
|
||||
if (netConnect)
|
||||
WifiManager.setHttpProxy(netConnect);
|
||||
|
||||
// The full authentication process is completed, reset the count.
|
||||
WifiManager.authenticationFailuresCount = 0;
|
||||
WifiManager.loopDetectionCount = 0;
|
||||
@ -2182,6 +2233,23 @@ function WifiWorker() {
|
||||
}
|
||||
|
||||
self._fireEvent("ondisconnect", {});
|
||||
|
||||
// When disconnected, clear the http proxy setting if it exists.
|
||||
// Temporarily set http proxy to empty and restore user setting after setHttpProxy.
|
||||
let netDisconnect = WifiManager.getHttpProxyNetwork(self.currentNetwork);
|
||||
if (netDisconnect) {
|
||||
let prehttpProxyHostSetting = netDisconnect.httpProxyHost;
|
||||
let prehttpProxyPortSetting = netDisconnect.httpProxyPort;
|
||||
|
||||
netDisconnect.httpProxyHost = "";
|
||||
netDisconnect.httpProxyPort = 0;
|
||||
|
||||
WifiManager.setHttpProxy(netDisconnect);
|
||||
|
||||
netDisconnect.httpProxyHost = prehttpProxyHostSetting;
|
||||
netDisconnect.httpProxyPort = prehttpProxyPortSetting;
|
||||
}
|
||||
|
||||
self.currentNetwork = null;
|
||||
self.ipAddress = "";
|
||||
|
||||
@ -2716,6 +2784,9 @@ WifiWorker.prototype = {
|
||||
case "WifiManager:setPowerSavingMode":
|
||||
this.setPowerSavingMode(msg);
|
||||
break;
|
||||
case "WifiManager:setHttpProxy":
|
||||
this.setHttpProxy(msg);
|
||||
break;
|
||||
case "WifiManager:setStaticIpMode":
|
||||
this.setStaticIpMode(msg);
|
||||
break;
|
||||
@ -3210,6 +3281,30 @@ WifiWorker.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
setHttpProxy: function(msg) {
|
||||
const message = "WifiManager:setHttpProxy:Return";
|
||||
let self = this;
|
||||
let network = msg.data.network;
|
||||
let info = msg.data.info;
|
||||
|
||||
netFromDOM(network, null);
|
||||
|
||||
WifiManager.configureHttpProxy(network, info, function(ok) {
|
||||
if (ok) {
|
||||
// If configured network is current connected network
|
||||
// need update http proxy immediately.
|
||||
let setNetworkKey = getNetworkKey(network);
|
||||
let curNetworkKey = self.currentNetwork ? getNetworkKey(self.currentNetwork) : null;
|
||||
if (setNetworkKey === curNetworkKey)
|
||||
WifiManager.setHttpProxy(network);
|
||||
|
||||
self._sendMessage(message, true, true, msg);
|
||||
} else {
|
||||
self._sendMessage(message, false, "Set http proxy failed", msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setStaticIpMode: function(msg) {
|
||||
const message = "WifiManager:setStaticMode:Return";
|
||||
let self = this;
|
||||
|
@ -59,7 +59,7 @@ interface nsIWifi : nsISupports
|
||||
void getWifiScanResults(in nsIWifiScanResultsReady callback);
|
||||
};
|
||||
|
||||
[scriptable, uuid(3f21012d-6e75-4632-b87c-acdd7c57fbf3)]
|
||||
[scriptable, uuid(e5a72295-1c5f-4848-9cbb-f1d3785c16c1)]
|
||||
interface nsIDOMWifiManager : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -145,6 +145,19 @@ interface nsIDOMWifiManager : nsISupports
|
||||
nsIDOMDOMRequest setStaticIpMode(in jsval network,
|
||||
in jsval info);
|
||||
|
||||
/**
|
||||
* Given a network, configure http proxy when using wifi.
|
||||
* @param network A network object with the SSID of the network to set http proxy.
|
||||
* @param info info should have following field:
|
||||
* - httpProxyHost ip address of http proxy.
|
||||
* - httpProxyPort port of http proxy, set 0 to use default port 8080.
|
||||
* set info to null to clear http proxy.
|
||||
* onsuccess: We have successfully configure http proxy.
|
||||
* onerror: We have failed to configure http proxy.
|
||||
*/
|
||||
nsIDOMDOMRequest setHttpProxy(in jsval network,
|
||||
in jsval info);
|
||||
|
||||
/**
|
||||
* Returns whether or not wifi is currently enabled.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user