diff --git a/dom/wifi/WifiWorker.js b/dom/wifi/WifiWorker.js index 79390ce84ace..5cda67c34f0e 100644 --- a/dom/wifi/WifiWorker.js +++ b/dom/wifi/WifiWorker.js @@ -11,7 +11,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -const DEBUG = false; // set to true to show debug messages +var DEBUG = false; // set to true to show debug messages const WIFIWORKER_CONTRACTID = "@mozilla.org/wifi/worker;1"; const WIFIWORKER_CID = Components.ID("{a14e8977-d259-433a-a88d-58dd44657e5b}"); @@ -1835,9 +1835,28 @@ function WifiWorker() { handleError: function handleError(aErrorMessage) { debug("Error reading the 'wifi.enabled' setting. Default to wifi on."); self.setWifiEnabled({enabled: true}); - }, + } }; - gSettingsService.createLock().get("wifi.enabled", initWifiEnabledCb); + + var initWifiDebuggingEnabledCb = { + handle: function handle(aName, aResult) { + if (aName !== "wifi.debugging.enabled") + return; + if (aResult === null) + aResult = false; + DEBUG = aResult; + updateDebug(); + }, + handleError: function handleError(aErrorMessage) { + debug("Error reading the 'wifi.debugging.enabled' setting. Default to debugging off."); + DEBUG = false; + updateDebug(); + } + }; + + let lock = gSettingsService.createLock(); + lock.get("wifi.enabled", initWifiEnabledCb); + lock.get("wifi.debugging.enabled", initWifiDebuggingEnabledCb); } function translateState(state) { @@ -2572,6 +2591,11 @@ WifiWorker.prototype = { } let setting = JSON.parse(data); + if (setting.key === "wifi.debugging.enabled") { + DEBUG = setting.value; + updateDebug(); + return; + } if (setting.key !== "wifi.enabled" && setting.key !== "tethering.wifi.enabled") { return; @@ -2596,10 +2620,13 @@ WifiWorker.prototype = { this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiWorker]); let debug; -if (DEBUG) { - debug = function (s) { - dump("-*- WifiWorker component: " + s + "\n"); - }; -} else { - debug = function (s) {}; +function updateDebug() { + if (DEBUG) { + debug = function (s) { + dump("-*- WifiWorker component: " + s + "\n"); + }; + } else { + debug = function (s) {}; + } } +updateDebug();