Bug 917175 - 0003. DOM API implementation. r=mrbkap
authorChuck Lee <chulee@mozilla.com>
Mon, 28 Apr 2014 15:50:11 +0800
changeset 181965 947690de7b62135a04c84d6c86c7cf9f46f687dc
parent 181964 6781b96cca1c3f400999561a0651cfaa1b937dcd
child 181966 8f803659229a8c342d93154046bd9abbd0d8e2fd
push id43178
push usercbook@mozilla.com
push dateWed, 07 May 2014 12:13:50 +0000
treeherdermozilla-inbound@36b2f696ff10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs917175
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 917175 - 0003. DOM API implementation. r=mrbkap
dom/wifi/DOMWifiManager.js
dom/wifi/WifiWorker.js
--- a/dom/wifi/DOMWifiManager.js
+++ b/dom/wifi/DOMWifiManager.js
@@ -91,16 +91,17 @@ DOMWifiManager.prototype = {
                       "WifiManager:associate:Return:OK", "WifiManager:associate:Return:NO",
                       "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:importCert:Return:OK", "WifiManager:importCert:Return:NO",
                       "WifiManager:getImportedCerts:Return:OK", "WifiManager:getImportedCerts:Return:NO",
+                      "WifiManager:deleteCert:Return:OK", "WifiManager:deleteCert:Return:NO",
                       "WifiManager:wifiDown", "WifiManager:wifiUp",
                       "WifiManager:onconnecting", "WifiManager:onassociate",
                       "WifiManager:onconnect", "WifiManager:ondisconnect",
                       "WifiManager:onwpstimeout", "WifiManager:onwpsfail",
                       "WifiManager:onwpsoverlap", "WifiManager:connectionInfoUpdate",
                       "WifiManager:onconnectingfailed"];
     this.initDOMRequestHelper(aWindow, messages);
     this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
@@ -283,16 +284,24 @@ DOMWifiManager.prototype = {
       case "WifiManager:getImportedCerts:Return:OK":
         Services.DOMRequest.fireSuccess(request, this._convertWifiCertificateList(msg.data));
         break;
 
       case "WifiManager:getImportedCerts:Return:NO":
         Services.DOMRequest.fireError(request, msg.data);
         break;
 
+      case "WifiManager:deleteCert:Return:OK":
+        Services.DOMRequest.fireSuccess(request, msg.data);
+        break;
+
+      case "WifiManager:deleteCert:Return:NO":
+        Services.DOMRequest.fireError(request, msg.data);
+        break;
+
       case "WifiManager:wifiDown":
         this._enabled = false;
         this._currentNetwork = null;
         this._fireEnabledOrDisabled(false);
         break;
 
       case "WifiManager:wifiUp":
         this._enabled = true;
@@ -447,16 +456,25 @@ DOMWifiManager.prototype = {
   },
 
   getImportedCerts: function nsIDOMWifiManager_getImportedCerts() {
     var request = this.createRequest();
     this._sendMessageForRequest("WifiManager:getImportedCerts", null, request);
     return request;
   },
 
+  deleteCert: function nsIDOMWifiManager_deleteCert(certNickname) {
+    var request = this.createRequest();
+    this._sendMessageForRequest("WifiManager:deleteCert",
+                                {
+                                  certNickname: certNickname
+                                }, request);
+    return request;
+  },
+
   get enabled() {
     return this._enabled;
   },
 
   get macAddress() {
     return this._macAddress;
   },
 
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -1374,16 +1374,25 @@ var WifiManager = (function() {
     if (callback) {
       controlCallbacks[id] = callback;
     }
 
     wifiCertService.importCert(id, caInfo.certBlob, caInfo.certPassword,
                                caInfo.certNickname);
   }
 
+  manager.deleteCert = function(caInfo, callback) {
+    var id = idgen++;
+    if (callback) {
+      controlCallbacks[id] = callback;
+    }
+
+    wifiCertService.deleteCert(id, caInfo.certNickname);
+  }
+
   return manager;
 })();
 
 // Get unique key for a network, now the key is created by escape(SSID)+Security.
 // So networks of same SSID but different security mode can be identified.
 function getNetworkKey(network)
 {
   var ssid = "",
@@ -1642,16 +1651,17 @@ function WifiWorker() {
   const messages = ["WifiManager:getNetworks", "WifiManager:getKnownNetworks",
                     "WifiManager:associate", "WifiManager:forget",
                     "WifiManager:wps", "WifiManager:getState",
                     "WifiManager:setPowerSavingMode",
                     "WifiManager:setHttpProxy",
                     "WifiManager:setStaticIpMode",
                     "WifiManager:importCert",
                     "WifiManager:getImportedCerts",
+                    "WifiManager:deleteCert",
                     "child-process-shutdown"];
 
   messages.forEach((function(msgName) {
     this._mm.addMessageListener(msgName, this);
   }).bind(this));
 
   Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
 
@@ -2600,16 +2610,19 @@ WifiWorker.prototype = {
         this.setStaticIpMode(msg);
         break;
       case "WifiManager:importCert":
         this.importCert(msg);
         break;
       case "WifiManager:getImportedCerts":
         this.getImportedCerts(msg);
         break;
+      case "WifiManager:deleteCert":
+        this.deleteCert(msg);
+        break;
       case "WifiManager:getState": {
         let i;
         if ((i = this._domManagers.indexOf(msg.manager)) === -1) {
           this._domManagers.push(msg.manager);
         }
 
         let net = this.currentNetwork ? netToDOM(this.currentNetwork) : null;
         return { network: net,
@@ -3152,16 +3165,25 @@ WifiWorker.prototype = {
         continue;
       }
       importedCerts[UsageMapping[certNicknameInfo[1]]].push(certNicknameInfo[2]);
     }
 
     self._sendMessage(message, true, importedCerts, msg);
   },
 
+  deleteCert: function deleteCert(msg) {
+    const message = "WifiManager:deleteCert:Return";
+    let self = this;
+
+    WifiManager.deleteCert(msg.data, function(data) {
+      self._sendMessage(message, data.status === 0, "Delete Cert failed", msg);
+    });
+  },
+
   // This is a bit ugly, but works. In particular, this depends on the fact
   // that RadioManager never actually tries to get the worker from us.
   get worker() { throw "Not implemented"; },
 
   shutdown: function() {
     debug("shutting down ...");
     this.queueRequest({command: "setWifiEnabled", value: false}, function(data) {
       this.setWifiEnabled(false, this._setWifiEnabledCallback.bind(this));