Commit a48f1fd8 authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb36019' into 'master'

[embedlite-components] Add means to register preference observers. Contributes to JB#36019

Proxy "nsPref:changed" topic changes to global observer. In order
to recieve "nsPref:changed" you need to register preference
observer with "embed:addPrefChangedObserver" message.

See merge request !27
parents 39893b08 70d45392
......@@ -71,6 +71,8 @@ EmbedPrefService.prototype = {
Services.obs.addObserver(this, "embedui:allprefs", true);
Services.obs.addObserver(this, "embedui:setprefs", true);
Services.obs.addObserver(this, "embedui:clearprefs", true);
Services.obs.addObserver(this, "embed:addPrefChangedObserver", true);
Services.obs.addObserver(this, "embed:removePrefChangedObserver", true);
break;
}
case "embedui:prefs": {
......@@ -112,6 +114,21 @@ EmbedPrefService.prototype = {
}
break;
}
case "embed:addPrefChangedObserver": {
let pref = JSON.parse(aData);
Services.prefs.addObserver(pref.name, this, true);
Services.obs.notifyObservers(null, "embed:nsPrefChanged", JSON.stringify(this._getPref(pref.name)));
break;
}
case "embed:removePrefChangedObserver": {
let pref = JSON.parse(aData);
Services.prefs.removeObserver(pref.name, this);
break;
}
case "nsPref:changed": {
Services.obs.notifyObservers(null, "embed:nsPrefChanged", JSON.stringify(this._getPref(aData)));
break;
}
case "embedui:setprefs": {
let prefs = JSON.parse(aData).prefs;
for (var i = 0; i < prefs.length; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment