diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c022c9dcb01a..a597c7892c5f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "e4d8c96f60dc17c64cf5374ab4e7f030de585bfa", + "revision": "dfacedfab9048c0b0e7235aa4d8a19714d5a8d54", "repo_path": "/integration/gaia-central" } diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index d641f088108a..4224c2660ab2 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -4,7 +4,12 @@ "use strict"; -const DEBUG = false; +let DEBUG = false; + +function updateDebug(aResult) { + DEBUG = !!aResult; +} + function debug(s) { dump("-*- ContactManager: " + s + "\n"); } const Cc = Components.classes; @@ -27,6 +32,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm", "@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender"); +XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService", + "@mozilla.org/settingsService;1", + "nsISettingsService"); + const CONTACTS_SENDMORE_MINIMUM = 5; function stringOrBust(aObj) { @@ -919,6 +928,16 @@ ContactManager.prototype = { "PermissionPromptHelper:AskPermission:OK", "Contacts:GetAll:Next", "Contacts:Revision", "Contacts:Count"]); + + let lock = gSettingsService.createLock(); + lock.get("dom.mozContacts.debugging.enabled", { + handle: function(aName, aResult) { + updateDebug(aResult); + }, + handleError: function(aErrorMessage) { + if (DEBUG) debug("Error reading dom.mozContacts.debugging.enabled setting: " + aErrorMessage); + } + }); }, // Called from DOMRequestIpcHelper diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm index 7e9b51902e52..4f50733ad28c 100644 --- a/dom/contacts/fallback/ContactDB.jsm +++ b/dom/contacts/fallback/ContactDB.jsm @@ -6,7 +6,7 @@ this.EXPORTED_SYMBOLS = ['ContactDB']; -const DEBUG = false; +let DEBUG = false; function debug(s) { dump("-*- ContactDB component: " + s + "\n"); } const Cu = Components.utils; @@ -945,6 +945,10 @@ ContactDB.prototype = { this.substringMatching = aDigits; }, + enableDebugging: function(aEnable) { + DEBUG = aEnable; + }, + init: function init(aGlobal) { this.initDBHelper(DB_NAME, DB_VERSION, [STORE_NAME, SAVED_GETALL_STORE_NAME, REVISION_STORE], aGlobal); } diff --git a/dom/contacts/fallback/ContactService.jsm b/dom/contacts/fallback/ContactService.jsm index 9bd5bc4dfb51..659da8c6ef95 100644 --- a/dom/contacts/fallback/ContactService.jsm +++ b/dom/contacts/fallback/ContactService.jsm @@ -4,7 +4,7 @@ "use strict"; -const DEBUG = false; +let DEBUG = false; function debug(s) { dump("-*- Fallback ContactService component: " + s + "\n"); } const Cu = Components.utils; @@ -22,6 +22,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm", "@mozilla.org/parentprocessmessagemanager;1", "nsIMessageListenerManager"); +XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService", + "@mozilla.org/settingsService;1", + "nsISettingsService"); + let myGlobal = this; let ContactService = { @@ -52,17 +56,33 @@ let ContactService = { } } + let lock = gSettingsService.createLock(); + lock.get("dom.mozContacts.debugging.enabled", { + handle: function(aName, aResult) { + updateDebug(aResult); + }, + handleError: function(aErrorMessage) { + if (DEBUG) debug("Error reading dom.mozContacts.debugging.enabled setting: " + aErrorMessage); + } + }); + Services.obs.addObserver(this, "profile-before-change", false); + Services.obs.addObserver(this, "mozsettings-changed", false); Services.prefs.addObserver("dom.phonenumber.substringmatching", this, false); }, + enableDebugging: function(aResult) { + this._db.enableDebugging(aResult); + }, + observe: function(aSubject, aTopic, aData) { - if (aTopic === 'profile-before-change') { + if (aTopic === "profile-before-change") { myGlobal = null; this._messages.forEach(function(msgName) { ppmm.removeMessageListener(msgName, this); }.bind(this)); Services.obs.removeObserver(this, "profile-before-change"); + Services.obs.removeObserver(this, "mozsettings-changed"); Services.prefs.removeObserver("dom.phonenumber.substringmatching", this); ppmm = null; this._messages = null; @@ -71,7 +91,7 @@ let ContactService = { this._db = null; this._children = null; this._cursors = null; - } else if (aTopic === 'nsPref:changed' && aData.contains("dom.phonenumber.substringmatching")) { + } else if (aTopic === "nsPref:changed" && aData.contains("dom.phonenumber.substringmatching")) { // We don't fully support changing substringMatching during runtime. This is mostly for testing. let countryName = PhoneNumberUtils.getCountryName(); if (Services.prefs.getPrefType("dom.phonenumber.substringmatching." + countryName) == Ci.nsIPrefBranch.PREF_INT) { @@ -80,6 +100,11 @@ let ContactService = { this._db.enableSubstringMatching(val); } } + } else if (aTopic === "mozsettings-changed") { + let data = JSON.parse(aData); + if (data.key === "dom.mozContacts.debugging.enabled") { + updateDebug(data.value); + } } }, @@ -251,3 +276,8 @@ let ContactService = { } ContactService.init(); + +function updateDebug(aResult) { + DEBUG = !!aResult; + ContactService.enableDebugging(DEBUG); +}