Reputation:
I'm using the SWT browser widget to embed a Mozilla browser inside a Java process, and I'd like to modify the browser's about:config preferences programmatically from Java, at run time. Is this possible to do? And if so, how?
Upvotes: 3
Views: 895
Reputation: 57681
You can probably use JavaXPCOM for that. Something like this should work:
import org.mozilla.xpcom.Mozilla;
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsIPrefBranch;
...
Mozilla mozilla = Mozilla.getInstance();
nsIServiceManager serviceManager = mozilla.getServiceManager();
nsIPrefBranch prefs = (nsIPrefBranch)serviceManager
.getServiceByContractID("@mozilla.org/preferences-service;1",
nsIPrefBranch.NS_IPREFBRANCH_IID);
prefs.setBoolPref("javascript.enabled", false);
If you cannot access JavaXPCOM then this likely isn't doable.
Upvotes: 2