+
+
+
diff --git a/dom/permission/tests/test_wifi-manage.html b/dom/permission/tests/test_wifi-manage.html
index 94d17b682cb..9e57434e619 100644
--- a/dom/permission/tests/test_wifi-manage.html
+++ b/dom/permission/tests/test_wifi-manage.html
@@ -30,7 +30,7 @@ var gData = [
perm: ["wifi-manage"],
needParentPerm: true,
obj: "mozWifiManager",
- webidl: "MozWifiManager",
+ idl: "nsIDOMWifiManager",
verifier: verifier.toSource(),
},
]
diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html
index c5ce599114c..89cb89f5aa0 100644
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -685,16 +685,8 @@ var interfaceNamesInGlobalScope =
{name: "MozVoicemailEvent", b2g: true, pref: "dom.voicemail.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozWakeLock", b2g: true, pref: "dom.wakelock.enabled"},
-// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "MozWifiConnection", b2g: true, permission: "wifi-manage"},
-// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "MozWifiConnectionInfo", b2g: true, permission: "wifi-manage"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozWifiConnectionInfoEvent", b2g: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "MozWifiManager", b2g: true, permission: "wifi-manage"},
-// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "MozWifiNetwork", b2g: true, permission: "wifi-manage"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozWifiStatusChangeEvent", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
diff --git a/dom/webidl/MozWifiManager.webidl b/dom/webidl/MozWifiManager.webidl
deleted file mode 100644
index 75181ca0696..00000000000
--- a/dom/webidl/MozWifiManager.webidl
+++ /dev/null
@@ -1,237 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-enum WifiWPSMethod {
- "pbc",
- "pin",
- "cancel"
-};
-
-enum ConnectionStatus {
- "connecting",
- "associated",
- "connected",
- "disconnected"
-};
-
-dictionary WifiWPSInfo {
- WifiWPSMethod method;
- DOMString? pin;
- DOMString? bssid;
-};
-
-dictionary NetworkProperties {
- DOMString ssid;
- sequence? security;
- sequence? capabilities;
- boolean known;
- boolean connected;
- boolean hidden;
-};
-
-[Constructor(optional NetworkProperties properties),
- JSImplementation="@mozilla.org/mozwifinetwork;1"]
-interface MozWifiNetwork {
- readonly attribute DOMString ssid;
- readonly attribute any security;
- readonly attribute any capabilities;
- readonly attribute boolean known;
- readonly attribute boolean connected;
- readonly attribute boolean hidden;
-
- attribute DOMString? bssid;
- attribute DOMString? signalStrength;
- attribute long? relSignalStrength;
- attribute DOMString? psk;
- attribute DOMString? keyManagement;
- attribute DOMString? identity;
- attribute DOMString? password;
- attribute DOMString? phase1;
- attribute DOMString? phase2;
- attribute DOMString? eap;
- attribute DOMString? pin;
-};
-
-[JSImplementation="@mozilla.org/mozwificonnection;1"]
-interface MozWifiConnection {
- readonly attribute ConnectionStatus status;
- readonly attribute MozWifiNetwork? network;
-};
-
-[JSImplementation="@mozilla.org/mozwificonnectioninfo;1"]
-interface MozWifiConnectionInfo {
- readonly attribute short signalStrength;
- readonly attribute short relSignalStrength;
- readonly attribute long linkSpeed;
- readonly attribute DOMString? ipAddress;
-};
-
-dictionary IPConfiguration {
- boolean enabled;
- DOMString ipaddr;
- DOMString proxy;
- short maskLength;
- DOMString gateway;
- DOMString dns1;
- DOMString dns2;
-};
-
-[JSImplementation="@mozilla.org/wifimanager;1",
- NavigatorProperty="mozWifiManager",
- Func="Navigator::HasWifiManagerSupport"]
-interface MozWifiManager : EventTarget {
- /**
- * Returns the list of currently available networks.
- * onsuccess: We have obtained the current list of networks. request.value
- * is an object whose property names are SSIDs and values are
- * network objects.
- * onerror: We were unable to obtain a list of property names.
- */
- DOMRequest getNetworks();
-
- /**
- * Returns the list of networks known to the system that will be
- * automatically connected to if they're in range.
- * onsuccess: request.value is an object whose property names are
- * SSIDs and values are network objects.
- * onerror: We were unable to obtain a list of known networks.
- */
- DOMRequest getKnownNetworks();
-
- /**
- * Takes one of the networks returned from getNetworks and tries to
- * connect to it.
- * @param network A network object with information about the network,
- * such as the SSID, key management desired, etc.
- * onsuccess: We have started attempting to associate with the network.
- * request.value is true.
- * onerror: We were unable to select the network. This most likely means a
- * configuration error.
- */
- DOMRequest associate(MozWifiNetwork network);
-
- /**
- * Given a network, removes it from the list of networks that we'll
- * automatically connect to. In order to re-connect to the network, it is
- * necessary to call associate on it.
- * @param network A network object with the SSID of the network to remove.
- * onsuccess: We have removed this network. If we were previously
- * connected to it, we have started reconnecting to the next
- * network in the list.
- * onerror: We were unable to remove the network.
- */
- DOMRequest forget(MozWifiNetwork network);
-
- /**
- * Wi-Fi Protected Setup functionality.
- * @param detail WPS detail which has 'method' and 'pin' field.
- * The possible method field values are:
- * - pbc: The Push Button Configuration.
- * - pin: The PIN configuration.
- * - cancel: Request to cancel WPS in progress.
- * If method field is 'pin', 'pin' field can exist and has
- * a PIN number.
- * If method field is 'pin', 'bssid' field can exist and has
- * a opposite BSSID.
- * onsuccess: We have successfully started/canceled wps.
- * onerror: We have failed to start/cancel wps.
- */
- DOMRequest wps(optional WifiWPSInfo detail);
-
- /**
- * Turn on/off wifi power saving mode.
- * @param enabled true or false.
- * onsuccess: We have successfully turn on/off wifi power saving mode.
- * onerror: We have failed to turn on/off wifi power saving mode.
- */
- DOMRequest setPowerSavingMode(boolean enabled);
-
- /**
- * Given a network, configure using static IP instead of running DHCP
- * @param network A network object with the SSID of the network to set static ip.
- * @param info info should have following field:
- * - enabled True to enable static IP, false to use DHCP
- * - ipaddr configured static IP address
- * - proxy configured proxy server address
- * - maskLength configured mask length
- * - gateway configured gateway address
- * - dns1 configured first DNS server address
- * - dns2 configured seconf DNS server address
- * onsuccess: We have successfully configure the static ip mode.
- * onerror: We have failed to configure the static ip mode.
- */
- DOMRequest setStaticIpMode(MozWifiNetwork network, optional IPConfiguration 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.
- */
- DOMRequest setHttpProxy(MozWifiNetwork network, any info);
-
- /**
- * Returns whether or not wifi is currently enabled.
- */
- readonly attribute boolean enabled;
-
- /**
- * Returns the MAC address of the wifi adapter.
- */
- readonly attribute DOMString macAddress;
-
- /**
- * An non-null object containing the following information:
- * - status ("disconnected", "connecting", "associated", "connected")
- * - network
- *
- * Note that the object returned is read only. Any changes required must
- * be done by calling other APIs.
- */
- readonly attribute MozWifiConnection? connection;
-
- /**
- * A connectionInformation object with the same information found in an
- * nsIDOMMozWifiConnectionInfoEvent (but without the network).
- * If we are not currently connected to a network, this will be null.
- */
- readonly attribute MozWifiConnectionInfo? connectionInformation;
-
- /**
- * State notification listeners. These all take an
- * nsIDOMMozWifiStatusChangeEvent with the new status and a network (which
- * may be null).
- *
- * The possible statuses are:
- * - connecting: Fires when we start the process of connecting to a
- * network.
- * - associated: Fires when we have connected to an access point but do
- * not yet have an IP address.
- * - connected: Fires once we are fully connected to an access point and
- * can access the internet.
- * - disconnected: Fires when we either fail to connect to an access
- * point (transition: associated -> disconnected) or
- * when we were connected to a network but have
- * disconnected for any reason (transition: connected ->
- * disconnected).
- */
- attribute EventHandler onstatuschange;
-
- /**
- * An event listener that is called with information about the signal
- * strength and link speed every 5 seconds.
- */
- attribute EventHandler onconnectionInfoUpdate;
-
- /**
- * These two events fire when the wifi system is brought online or taken
- * offline.
- */
- attribute EventHandler onenabled;
- attribute EventHandler ondisabled;
-};
diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
index f4934df66f2..a31fb66c7c2 100644
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -556,7 +556,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
WEBIDL_FILES += [
'MozSpeakerManager.webidl',
'MozWifiConnectionInfoEvent.webidl',
- 'MozWifiManager.webidl',
'MozWifiP2pManager.webidl',
'MozWifiP2pStatusChangeEvent.webidl',
'MozWifiStatusChangeEvent.webidl',
diff --git a/dom/wifi/DOMWifiManager.js b/dom/wifi/DOMWifiManager.js
index dc030b36551..4be4c24dc57 100644
--- a/dom/wifi/DOMWifiManager.js
+++ b/dom/wifi/DOMWifiManager.js
@@ -15,74 +15,67 @@ Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
const DEBUG = false; // set to false to suppress debug messages
const DOMWIFIMANAGER_CONTRACTID = "@mozilla.org/wifimanager;1";
-const DOMWIFIMANAGER_CID = Components.ID("{c9b5f09e-25d2-40ca-aef4-c4d13d93c706}");
-
-function MozWifiNetwork() {
-}
-
-MozWifiNetwork.prototype = {
-
- init: function(aWindow) {
- this._window = aWindow;
- },
-
- __init: function(obj) {
- this.ssid = obj.ssid;
- this.security = obj.security;
- this.capabilities = obj.capabilities;
- this.known = obj.known;
- this.connected = obj.connected;
- this.hidden = obj.hidden;
- },
-
- classID: Components.ID("{c01fd751-43c0-460a-8b64-abf652ec7220}"),
- contractID: "@mozilla.org/mozwifinetwork;1",
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
- Ci.nsIDOMGlobalPropertyInitializer])
-};
-
-function MozWifiConnection(obj) {
- this.status = obj.status;
- this.network = obj.network;
-}
-
-MozWifiConnection.prototype = {
- classID: Components.ID("{23579da4-201b-4319-bd42-9b7f337343ac}"),
- contractID: "@mozilla.org/mozwificonnection;1",
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports])
-};
-
-function MozWifiConnectionInfo(obj) {
- this.signalStrength = obj.signalStrength;
- this.relSignalStrength = obj.relSignalStrength;
- this.linkSpeed = obj.linkSpeed;
- this.ipAddress = obj.ipAddress;
-}
-
-MozWifiConnectionInfo.prototype = {
- classID: Components.ID("{83670352-6ed4-4c35-8de9-402296a1959c}"),
- contractID: "@mozilla.org/mozwificonnectioninfo;1",
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports])
-}
+const DOMWIFIMANAGER_CID = Components.ID("{2cf775a7-1837-410c-9e26-323c42e076da}");
function DOMWifiManager() {
- this.defineEventHandlerGetterSetter("onstatuschange");
- this.defineEventHandlerGetterSetter("onconnectionInfoUpdate");
- this.defineEventHandlerGetterSetter("onenabled");
- this.defineEventHandlerGetterSetter("ondisabled");
+}
+
+function exposeCurrentNetwork(currentNetwork) {
+ currentNetwork.__exposedProps__ = exposeCurrentNetwork.currentNetworkApi;
+}
+
+exposeCurrentNetwork.currentNetworkApi = {
+ ssid: "r",
+ security: "r",
+ capabilities: "r",
+ known: "r"
+};
+
+// For smaller, read-only APIs, we expose any property that doesn't begin with
+// an underscore.
+function exposeReadOnly(obj) {
+ var exposedProps = {};
+ for (let i in obj) {
+ if (i[0] === "_")
+ continue;
+ exposedProps[i] = "r";
+ }
+
+ obj.__exposedProps__ = exposedProps;
+ return obj;
}
DOMWifiManager.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
- classDescription: "DOMWifiManager",
- classID: DOMWIFIMANAGER_CID,
- contractID: DOMWIFIMANAGER_CONTRACTID,
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
+
+ classID: DOMWIFIMANAGER_CID,
+ classInfo: XPCOMUtils.generateCI({classID: DOMWIFIMANAGER_CID,
+ contractID: DOMWIFIMANAGER_CONTRACTID,
+ classDescription: "DOMWifiManager",
+ interfaces: [Ci.nsIDOMWifiManager],
+ flags: Ci.nsIClassInfo.DOM_OBJECT}),
+
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMWifiManager,
+ Ci.nsIDOMGlobalPropertyInitializer,
Ci.nsISupportsWeakReference,
Ci.nsIObserver]),
// nsIDOMGlobalPropertyInitializer implementation
init: function(aWindow) {
+ let principal = aWindow.document.nodePrincipal;
+ let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
+
+ let perm = principal == secMan.getSystemPrincipal()
+ ? Ci.nsIPermissionManager.ALLOW_ACTION
+ : Services.perms.testExactPermissionFromPrincipal(principal, "wifi-manage");
+
+ // Only pages with perm set can use the wifi manager.
+ this._hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
+
+ if (!this._hasPrivileges) {
+ return null;
+ }
+
// Maintain this state for synchronous APIs.
this._currentNetwork = null;
this._connectionStatus = "disconnected";
@@ -108,8 +101,10 @@ DOMWifiManager.prototype = {
var state = this._mm.sendSyncMessage("WifiManager:getState")[0];
if (state) {
- this._currentNetwork = this._convertWifiNetwork(state.network);
- this._lastConnectionInfo = this._convertConnectionInfo(state.connectionInfo);
+ this._currentNetwork = state.network;
+ if (this._currentNetwork)
+ exposeCurrentNetwork(this._currentNetwork);
+ this._lastConnectionInfo = state.connectionInfo;
this._enabled = state.enabled;
this._connectionStatus = state.status;
this._macAddress = state.macAddress;
@@ -122,40 +117,11 @@ DOMWifiManager.prototype = {
}
},
- _convertWifiNetworkToJSON: function(aNetwork) {
- let json = {};
-
- for (let key in aNetwork) {
- // In WifiWorker.js there are lots of check using "key in network".
- // So if the value of any property of WifiNetwork is undefined, do not clone it.
- if (aNetwork[key] != undefined) {
- json[key] = aNetwork[key];
- }
- }
- return json;
- },
-
- _convertWifiNetwork: function(aNetwork) {
- let network = aNetwork ? new this._window.MozWifiNetwork(aNetwork) : null;
- return network;
- },
-
- _convertWifiNetworks: function(aNetworks) {
- let networks = [];
- for (let i in aNetworks) {
- networks.push(this._convertWifiNetwork(aNetworks[i]));
- }
- return networks;
- },
-
- _convertConnection: function(aConn) {
- let conn = aConn ? new MozWifiConnection(aConn) : null;
- return conn;
- },
-
- _convertConnectionInfo: function(aInfo) {
- let info = aInfo ? new MozWifiConnectionInfo(aInfo) : null;
- return info;
+ uninit: function() {
+ this._onStatusChange = null;
+ this._onConnectionInfoUpdate = null;
+ this._onEnabled = null;
+ this._onDisabled = null;
},
_sendMessageForRequest: function(name, data, request) {
@@ -178,7 +144,7 @@ DOMWifiManager.prototype = {
switch (aMessage.name) {
case "WifiManager:getNetworks:Return:OK":
- Services.DOMRequest.fireSuccess(request, this._convertWifiNetworks(msg.data));
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:getNetworks:Return:NO":
@@ -186,7 +152,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:getKnownNetworks:Return:OK":
- Services.DOMRequest.fireSuccess(request, this._convertWifiNetworks(msg.data));
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:getKnownNetworks:Return:NO":
@@ -210,7 +176,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:wps:Return:OK":
- Services.DOMRequest.fireSuccess(request, msg.data);
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:wps:Return:NO":
@@ -218,7 +184,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:setPowerSavingMode:Return:OK":
- Services.DOMRequest.fireSuccess(request, msg.data);
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:setPowerSavingMode:Return:NO":
@@ -226,7 +192,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:setHttpProxy:Return:OK":
- Services.DOMRequest.fireSuccess(request, msg.data);
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:setHttpProxy:Return:NO":
@@ -234,7 +200,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:setStaticIpMode:Return:OK":
- Services.DOMRequest.fireSuccess(request, msg.data);
+ Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
break;
case "WifiManager:setStaticIpMode:Return:NO":
@@ -254,19 +220,22 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:onconnecting":
- this._currentNetwork = this._convertWifiNetwork(msg.network);
+ this._currentNetwork = msg.network;
+ exposeCurrentNetwork(this._currentNetwork);
this._connectionStatus = "connecting";
this._fireStatusChangeEvent();
break;
case "WifiManager:onassociate":
- this._currentNetwork = this._convertWifiNetwork(msg.network);
+ this._currentNetwork = msg.network;
+ exposeCurrentNetwork(this._currentNetwork);
this._connectionStatus = "associated";
this._fireStatusChangeEvent();
break;
case "WifiManager:onconnect":
- this._currentNetwork = this._convertWifiNetwork(msg.network);
+ this._currentNetwork = msg.network;
+ exposeCurrentNetwork(this._currentNetwork);
this._connectionStatus = "connected";
this._fireStatusChangeEvent();
break;
@@ -300,7 +269,7 @@ DOMWifiManager.prototype = {
break;
case "WifiManager:connectionInfoUpdate":
- this._lastConnectionInfo = this._convertConnectionInfo(msg);
+ this._lastConnectionInfo = msg;
this._fireConnectionInfoUpdate(msg);
break;
case "WifiManager:onconnectingfailed":
@@ -313,115 +282,156 @@ DOMWifiManager.prototype = {
},
_fireStatusChangeEvent: function StatusChangeEvent() {
- var event = new this._window.MozWifiStatusChangeEvent("statuschange",
- { network: this._currentNetwork,
- status: this._connectionStatus
- });
- this.__DOM_IMPL__.dispatchEvent(event);
+ if (this._onStatusChange) {
+ debug("StatusChangeEvent");
+ var event = new this._window.MozWifiStatusChangeEvent("statusChangeEvent",
+ { network: this._currentNetwork,
+ status: this._connectionStatus
+ });
+ this._onStatusChange.handleEvent(event);
+ }
},
- _fireConnectionInfoUpdate: function onConnectionInfoUpdate(info) {
- var evt = new this._window.MozWifiConnectionInfoEvent("connectioninfoupdate",
- { network: this._currentNetwork,
- signalStrength: info.signalStrength,
- relSignalStrength: info.relSignalStrength,
- linkSpeed: info.linkSpeed,
- ipAddress: info.ipAddress,
- });
- this.__DOM_IMPL__.dispatchEvent(evt);
+ _fireConnectionInfoUpdate: function connectionInfoUpdate(info) {
+ if (this._onConnectionInfoUpdate) {
+ debug("ConnectionInfoEvent");
+ var evt = new this._window.MozWifiConnectionInfoEvent("connectionInfoEvent",
+ { network: this._currentNetwork,
+ signalStrength: info.signalStrength,
+ relSignalStrength: info.relSignalStrength,
+ linkSpeed: info.linkSpeed,
+ ipAddress: info.ipAddress,
+ });
+ this._onConnectionInfoUpdate.handleEvent(evt);
+ }
},
_fireEnabledOrDisabled: function enabledDisabled(enabled) {
- var evt = new this._window.Event(enabled ? "enabled" : "disabled");
- this.__DOM_IMPL__.dispatchEvent(evt);
+ var handler = enabled ? this._onEnabled : this._onDisabled;
+ if (handler) {
+ var evt = new this._window.Event("WifiEnabled");
+ handler.handleEvent(evt);
+ }
},
- getNetworks: function getNetworks() {
+ // nsIDOMWifiManager
+ getNetworks: function nsIDOMWifiManager_getNetworks() {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
this._sendMessageForRequest("WifiManager:getNetworks", null, request);
return request;
},
- getKnownNetworks: function getKnownNetworks() {
+ getKnownNetworks: function nsIDOMWifiManager_getKnownNetworks() {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
this._sendMessageForRequest("WifiManager:getKnownNetworks", null, request);
return request;
},
- associate: function associate(network) {
+ associate: function nsIDOMWifiManager_associate(network) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
- this._sendMessageForRequest("WifiManager:associate",
- this._convertWifiNetworkToJSON(network), request);
+ this._sendMessageForRequest("WifiManager:associate", network, request);
return request;
},
- forget: function forget(network) {
+ forget: function nsIDOMWifiManager_forget(network) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
- this._sendMessageForRequest("WifiManager:forget",
- this._convertWifiNetworkToJSON(network), request);
+ this._sendMessageForRequest("WifiManager:forget", network, request);
return request;
},
- wps: function wps(detail) {
+ wps: function nsIDOMWifiManager_wps(detail) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
this._sendMessageForRequest("WifiManager:wps", detail, request);
return request;
},
- setPowerSavingMode: function setPowerSavingMode(enabled) {
+ setPowerSavingMode: function nsIDOMWifiManager_setPowerSavingMode(enabled) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
this._sendMessageForRequest("WifiManager:setPowerSavingMode", enabled, request);
return request;
},
- setHttpProxy: function setHttpProxy(network, info) {
+ 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: this._convertWifiNetworkToJSON(network), info:info}, request);
+ this._sendMessageForRequest("WifiManager:setHttpProxy", {network:network, info:info}, request);
return request;
},
- setStaticIpMode: function setStaticIpMode(network, info) {
+ setStaticIpMode: function nsIDOMWifiManager_setStaticIpMode(network, info) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
var request = this.createRequest();
- this._sendMessageForRequest("WifiManager:setStaticIpMode",
- { network: this._convertWifiNetworkToJSON(network), info: info}, request);
+ this._sendMessageForRequest("WifiManager:setStaticIpMode", {network: network,info: info}, request);
return request;
},
get enabled() {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
return this._enabled;
},
get macAddress() {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
return this._macAddress;
},
get connection() {
- let _connection = this._convertConnection({ status: this._connectionStatus,
- network: this._currentNetwork,
- });
- return _connection;
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ return exposeReadOnly({ status: this._connectionStatus,
+ network: this._currentNetwork });
},
get connectionInformation() {
- return this._lastConnectionInfo;
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ return this._lastConnectionInfo
+ ? exposeReadOnly(this._lastConnectionInfo)
+ : null;
},
- defineEventHandlerGetterSetter: function(name) {
- Object.defineProperty(this, name, {
- get: function() {
- return this.__DOM_IMPL__.getEventHandler(name);
- },
- set: function(handler) {
- this.__DOM_IMPL__.setEventHandler(name, handler);
- }
- });
+ set onstatuschange(callback) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ this._onStatusChange = callback;
},
+
+ set connectionInfoUpdate(callback) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ this._onConnectionInfoUpdate = callback;
+ },
+
+ set onenabled(callback) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ this._onEnabled = callback;
+ },
+
+ set ondisabled(callback) {
+ if (!this._hasPrivileges)
+ throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+ this._onDisabled = callback;
+ }
};
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
- DOMWifiManager, MozWifiNetwork, MozWifiConnection, MozWifiConnectionInfo
-]);
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DOMWifiManager]);
let debug;
if (DEBUG) {
diff --git a/dom/wifi/DOMWifiManager.manifest b/dom/wifi/DOMWifiManager.manifest
index b83229625fe..1c91bb281dd 100644
--- a/dom/wifi/DOMWifiManager.manifest
+++ b/dom/wifi/DOMWifiManager.manifest
@@ -1,12 +1,4 @@
# DOMWifiManager.js
-component {c9b5f09e-25d2-40ca-aef4-c4d13d93c706} DOMWifiManager.js
-contract @mozilla.org/wifimanager;1 {c9b5f09e-25d2-40ca-aef4-c4d13d93c706}
-
-component {c01fd751-43c0-460a-8b64-abf652ec7220} DOMWifiManager.js
-contract @mozilla.org/mozwifinetwork;1 {c01fd751-43c0-460a-8b64-abf652ec7220}
-
-component {23579da4-201b-4319-bd42-9b7f337343ac} DOMWifiManager.js
-contract @mozilla.org/mozwificonnection;1 {23579da4-201b-4319-bd42-9b7f337343ac}
-
-component {83670352-6ed4-4c35-8de9-402296a1959c} DOMWifiManager.js
-contract @mozilla.org/mozwificonnectioninfo;1 {83670352-6ed4-4c35-8de9-402296a1959c}
+component {2cf775a7-1837-410c-9e26-323c42e076da} DOMWifiManager.js
+contract @mozilla.org/wifimanager;1 {2cf775a7-1837-410c-9e26-323c42e076da}
+category JavaScript-navigator-property mozWifiManager @mozilla.org/wifimanager;1
diff --git a/dom/wifi/nsIWifi.idl b/dom/wifi/nsIWifi.idl
index 82ab9a75bd2..83b9a86a32e 100644
--- a/dom/wifi/nsIWifi.idl
+++ b/dom/wifi/nsIWifi.idl
@@ -58,3 +58,163 @@ interface nsIWifi : nsISupports
*/
void getWifiScanResults(in nsIWifiScanResultsReady callback);
};
+
+[scriptable, uuid(e5a72295-1c5f-4848-9cbb-f1d3785c16c1)]
+interface nsIDOMWifiManager : nsISupports
+{
+ /**
+ * Returns the list of currently available networks.
+ * onsuccess: We have obtained the current list of networks. request.value
+ * is an object whose property names are SSIDs and values are
+ * network objects.
+ * onerror: We were unable to obtain a list of property names.
+ */
+ nsIDOMDOMRequest getNetworks();
+
+ /**
+ * Returns the list of networks known to the system that will be
+ * automatically connected to if they're in range.
+ * onsuccess: request.value is an object whose property names are
+ * SSIDs and values are network objects.
+ * onerror: We were unable to obtain a list of known networks.
+ */
+ nsIDOMDOMRequest getKnownNetworks();
+
+ /**
+ * Takes one of the networks returned from getNetworks and tries to
+ * connect to it.
+ * @param network A network object with information about the network,
+ * such as the SSID, key management desired, etc.
+ * onsuccess: We have started attempting to associate with the network.
+ * request.value is true.
+ * onerror: We were unable to select the network. This most likely means a
+ * configuration error.
+ */
+ nsIDOMDOMRequest associate(in jsval network);
+
+ /**
+ * Given a network, removes it from the list of networks that we'll
+ * automatically connect to. In order to re-connect to the network, it is
+ * necessary to call associate on it.
+ * @param network A network object with the SSID of the network to remove.
+ * onsuccess: We have removed this network. If we were previously
+ * connected to it, we have started reconnecting to the next
+ * network in the list.
+ * onerror: We were unable to remove the network.
+ */
+ nsIDOMDOMRequest forget(in jsval network);
+
+ /**
+ * Wi-Fi Protected Setup functionality.
+ * @param detail WPS detail which has 'method' and 'pin' field.
+ * The possible method field values are:
+ * - pbc: The Push Button Configuration.
+ * - pin: The PIN configuration.
+ * - cancel: Request to cancel WPS in progress.
+ * If method field is 'pin', 'pin' field can exist and has
+ * a PIN number.
+ * If method field is 'pin', 'bssid' field can exist and has
+ * a opposite BSSID.
+ * onsuccess: We have successfully started/canceled wps.
+ * onerror: We have failed to start/cancel wps.
+ */
+ nsIDOMDOMRequest wps(in jsval detail);
+
+ /**
+ * Turn on/off wifi power saving mode.
+ * @param enabled true or false.
+ * onsuccess: We have successfully turn on/off wifi power saving mode.
+ * onerror: We have failed to turn on/off wifi power saving mode.
+ */
+ nsIDOMDOMRequest setPowerSavingMode(in boolean enabled);
+
+ /**
+ * Given a network, configure using static IP instead of running DHCP
+ * @param network A network object with the SSID of the network to set static ip.
+ * @param info info should have following field:
+ * - enabled True to enable static IP, false to use DHCP
+ * - ipaddr configured static IP address
+ * - proxy configured proxy server address
+ * - maskLength configured mask length
+ * - gateway configured gateway address
+ * - dns1 configured first DNS server address
+ * - dns2 configured seconf DNS server address
+ * onsuccess: We have successfully configure the static ip mode.
+ * onerror: We have failed to configure the static ip mode.
+ */
+ 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.
+ */
+ readonly attribute boolean enabled;
+
+ /**
+ * Returns the MAC address of the wifi adapter.
+ */
+ readonly attribute DOMString macAddress;
+
+ /**
+ * An non-null object containing the following information:
+ * - status ("disconnected", "connecting", "associated", "connected")
+ * - network
+ *
+ * Note that the object returned is read only. Any changes required must
+ * be done by calling other APIs.
+ */
+ readonly attribute jsval connection;
+
+ /**
+ * A connectionInformation object with the same information found in an
+ * nsIDOMMozWifiConnectionInfoEvent (but without the network).
+ * If we are not currently connected to a network, this will be null.
+ */
+ readonly attribute jsval connectionInformation;
+
+ /**
+ * State notification listeners. These all take an
+ * nsIDOMMozWifiStatusChangeEvent with the new status and a network (which
+ * may be null).
+ *
+ * The possible statuses are:
+ * - connecting: Fires when we start the process of connecting to a
+ * network.
+ * - associated: Fires when we have connected to an access point but do
+ * not yet have an IP address.
+ * - connected: Fires once we are fully connected to an access point and
+ * can access the internet.
+ * - disconnected: Fires when we either fail to connect to an access
+ * point (transition: associated -> disconnected) or
+ * when we were connected to a network but have
+ * disconnected for any reason (transition: connected ->
+ * disconnected).
+ */
+ attribute nsIDOMEventListener onstatuschange;
+
+ /**
+ * An event listener that is called with information about the signal
+ * strength and link speed every 5 seconds.
+ */
+ attribute nsIDOMEventListener connectionInfoUpdate;
+
+ /**
+ * These two events fire when the wifi system is brought online or taken
+ * offline.
+ */
+ attribute nsIDOMEventListener onenabled;
+ attribute nsIDOMEventListener ondisabled;
+};
diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp
index 16f25127238..18977695b4d 100644
--- a/gfx/layers/ipc/CompositableTransactionParent.cpp
+++ b/gfx/layers/ipc/CompositableTransactionParent.cpp
@@ -318,6 +318,11 @@ CompositableParentManager::ReturnTextureDataIfNecessary(CompositableHost* aCompo
aCompositable->GetCompositableBackendSpecificData()->GetPendingReleaseFenceTextureList();
// Return pending Texture data
for (size_t i = 0; i < textureList.size(); i++) {
+ // File descriptor number is limited to 4 per IPC message.
+ // See Bug 986253
+ if (mPrevFenceHandles.size() >= 4) {
+ break;
+ }
TextureHostOGL* hostOGL = textureList[i]->AsHostOGL();
PTextureParent* actor = textureList[i]->GetIPDLActor();
if (!hostOGL || !actor) {
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index abbfcc0f51d..2a63b4092c2 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1238,8 +1238,8 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
AppendUTF8toUTF16(aTempFileExtension, mTempFileExtension);
// replace platform specific path separator and illegal characters to avoid any confusion
- mSuggestedFileName.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
- mTempFileExtension.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
+ mSuggestedFileName.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
+ mTempFileExtension.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
// Remove unsafe bidi characters which might have spoofing implications (bug 511521).
const char16_t unsafeBidiCharacters[] = {
@@ -1436,13 +1436,13 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
// Base64 characters are alphanumeric (a-zA-Z0-9) and '+' and '/', so we need
// to replace illegal characters -- notably '/'
- tempLeafName.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
+ tempLeafName.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
// now append our extension.
nsAutoCString ext;
mMimeInfo->GetPrimaryExtension(ext);
if (!ext.IsEmpty()) {
- ext.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
+ ext.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
if (ext.First() != '.')
tempLeafName.Append('.');
tempLeafName.Append(ext);
diff --git a/xpcom/glue/nsCRTGlue.h b/xpcom/glue/nsCRTGlue.h
index b6a63f89529..8b3b3043501 100644
--- a/xpcom/glue/nsCRTGlue.h
+++ b/xpcom/glue/nsCRTGlue.h
@@ -110,17 +110,22 @@ NS_COM_GLUE void NS_MakeRandomString(char *buf, int32_t bufLen);
#define LFSTR "\012"
#define CRLF "\015\012" /* A CR LF equivalent string */
+// We use the most restrictive filesystem as our default set of illegal filename
+// characters. This is currently Windows.
+#define OS_FILE_ILLEGAL_CHARACTERS "/:*?\"<>|"
+// We also provide a list of all known file path separators for all filesystems.
+// This can be used in replacement of FILE_PATH_SEPARATOR when you need to
+// identify or replace all known path separators.
+#define KNOWN_PATH_SEPARATORS "\\/"
+
#if defined(XP_MACOSX)
#define FILE_PATH_SEPARATOR "/"
- #define OS_FILE_ILLEGAL_CHARACTERS ":"
#elif defined(XP_WIN)
#define FILE_PATH_SEPARATOR "\\"
- #define OS_FILE_ILLEGAL_CHARACTERS "/:*?\"<>|"
#elif defined(XP_UNIX)
#define FILE_PATH_SEPARATOR "/"
- #define OS_FILE_ILLEGAL_CHARACTERS ""
#else
- #error need_to_define_your_file_path_separator_and_illegal_characters
+ #error need_to_define_your_file_path_separator_and_maybe_illegal_characters
#endif
// Not all these control characters are illegal in all OSs, but we don't really