Bug 1460874 - Part 8: Allow setting prefs via GeckoRuntimeSettings in Fennec, too. r=geckoview-reviewers,snorp

Differential Revision: https://phabricator.services.mozilla.com/D17748

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2019-02-14 20:42:51 +00:00
parent 51fe895ba7
commit a2454b987a
2 changed files with 29 additions and 0 deletions

View File

@ -9,7 +9,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
ActorManagerParent: "resource://gre/modules/ActorManagerParent.jsm",
AppConstants: "resource://gre/modules/AppConstants.jsm",
DelayedInit: "resource://gre/modules/DelayedInit.jsm",
EventDispatcher: "resource://gre/modules/Messaging.jsm",
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
Preferences: "resource://gre/modules/Preferences.jsm",
Services: "resource://gre/modules/Services.jsm",
});
@ -174,6 +176,32 @@ BrowserCLH.prototype = {
});
break;
}
case "profile-after-change": {
EventDispatcher.instance.registerListener(this, "GeckoView:SetDefaultPrefs");
break;
}
}
},
onEvent(aEvent, aData, aCallback) {
switch (aEvent) {
case "GeckoView:SetDefaultPrefs": {
// While we want to allow setting certain preferences via GeckoView, we
// don't want to let it take over completely the management of those
// preferences. Therefore we don't handle the "ResetUserPrefs" message,
// and consequently we also apply any pref changes directly, i.e. *not*
// on the default branch.
const prefs = new Preferences();
for (const name of Object.keys(aData)) {
try {
prefs.set(name, aData[name]);
} catch (e) {
Cu.reportError(`Failed to set preference ${name}: ${e}`);
}
}
break;
}
}
},

View File

@ -65,6 +65,7 @@ contract @mozilla.org/helperapplauncherdialog;1 {e9d277a0-268a-4ec2-bb8c-10fdf3e
component {be623d20-d305-11de-8a39-0800200c9a66} BrowserCLH.js application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
contract @mozilla.org/browser/browser-clh;1 {be623d20-d305-11de-8a39-0800200c9a66}
category app-startup BrowserCLH service,@mozilla.org/browser/browser-clh;1
category profile-after-change BrowserCLH @mozilla.org/browser/browser-clh;1
# ContentDispatchChooser.js
component {5a072a22-1e66-4100-afc1-07aed8b62fc5} ContentDispatchChooser.js