Bug 1472238: hook up alwaysConnect pref changes r=lina

The original code had a bug in that going from disabled to enabled
would always connect, whereas actually we want to only connect if
there are records (or alwaysConnect is on).

We maintain the existing behavior that if the user has set
dom.push.connection.enabled to false, we don't connect, figuring that
this is the way a privacy-conscious user might indicate that they
don't want to talk to "the mothership".

MozReview-Commit-ID: ClbhYhnHVog

--HG--
extra : rebase_source : b404f4cf327590d9e55e3d9ceefbd2660715f7b3
This commit is contained in:
Ethan Glasser-Camp 2018-06-29 12:33:20 -04:00
Родитель a7990cf932
Коммит 23f3f097ec
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -296,7 +296,7 @@ var PushService = {
CHANGING_SERVICE_EVENT)
);
} else if (aData == "dom.push.connection.enabled") {
} else if (aData == "dom.push.connection.enabled" || aData == "dom.push.alwaysConnect") {
this._stateChangeProcessEnqueue(_ =>
this._changeStateConnectionEnabledEvent(prefs.get("connection.enabled"))
);
@ -501,6 +501,8 @@ var PushService = {
// Used to monitor if the user wishes to disable Push.
prefs.observe("connection.enabled", this);
// Used to load-test the server-side infrastructure for broadcast.
prefs.observe("alwaysConnect", this);
// Prunes expired registrations and notifies dormant service workers.
Services.obs.addObserver(this, "idle-daily");
@ -584,6 +586,7 @@ var PushService = {
}
prefs.ignore("connection.enabled", this);
prefs.ignore("alwaysConnect", this);
Services.obs.removeObserver(this, "network:offline-status-changed");
Services.obs.removeObserver(this, "clear-origin-attributes-data");