MozillaZine

Firefox 3.6 How to Enable/Disable Java from an extension?

Talk about add-ons and extension development.
DaemonUI
 
Posts: 19
Joined: January 26th, 2010, 6:09 am

Post Posted January 26th, 2010, 8:32 am

Hi,
I figured out that the Firefox 3.6 has no longer a
"security.enable_java" pref setting.
I have an little extension which shows a checkbox where I can enable/disable java
on the fly, and I would like to keep this functionality.

I tried by nsIExtensionManager but the plugins are not listed there (I tried
both getItemList and datasource), but neither returns plugins in the list.

Has anyone an idea how to do?

Thanks in advance.
Harry

DaemonUI
 
Posts: 19
Joined: January 26th, 2010, 6:09 am

Post Posted January 27th, 2010, 1:41 pm

Code: Select all
var PH=Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
var P=PH.getPluginTags({});
for(var i=0; i<P.length; i++)
{
  var p=P[i];
  if(/^Java.*Platform/i.test(p.name)) // toggle jave
   p.disabled=!p.disabled;
  if(/^Shockwave.*Flash/i.test(p.name))  // toggle flash
   p.disabled=!p.disabled;
}


After reading the change documents again I could answer my question by myself.

LoudNoise
New Member

User avatar
 
Posts: 40048
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Post Posted January 27th, 2010, 2:21 pm

Thanks for getting back to us with that.
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."

DaemonUI
 
Posts: 19
Joined: January 26th, 2010, 6:09 am

Post Posted January 27th, 2010, 5:34 pm

YW
But I'm just halfway :(
Now I know only how to enable/disable, but not how to observe changes of that state.
I found "plugins-list-updated" notification, but it has a different purpose.
If I didn't miss something .. I guess it's not yet possible to observe that changes, because even FF itself changes the state directly (here http://mxr.mozilla.org/mozilla1.9.2/sou ... ns.js#1114).

If nobody has an idea I'll put this into a feature request.
(I really want to avoid a timer-pulling solution)

Best regards,
Harry

DaemonUI
 
Posts: 19
Joined: January 26th, 2010, 6:09 am

Post Posted February 12th, 2010, 4:46 pm

I've found out for what "plugins-list-updated" notification is useful...
After refreshing the plugins list using navigator.plugin.refresh() references to nsiPluginTags are invalid.
In current 3.6 navigator.plugin.refresh() always causes a list refresh / "plugins-list-updated" pair.
Just in case somebody wonders ;)

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 2 guests

cron