зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central and birch
This commit is contained in:
Коммит
94b70a3bcb
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче