nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &res)); if(NS_SUCCEEDED(res) && (nsnull != prefs)) { PRBool js; res = prefs->GetBoolPref("javascript.enabled", &js); if(NS_SUCCEEDED(res)) *(NPBool*)result = js;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &res)); if(NS_SUCCEEDED(res) && (nsnull != prefs)) { PRBool js; res = prefs->GetBoolPref("javascript.enabled", &js); if(NS_SUCCEEDED(res)) *(NPBool*)result = js; } return NPERR_NO_ERROR;
_getvalue(NPP npp, NPNVariable variable, void *result){  nsresult res;  if(!npp || !npp->ndata)		return NPERR_INVALID_INSTANCE_ERROR;  switch(variable)  {#ifdef XP_UNIX  case NPNVxDisplay : return NPERR_GENERIC_ERROR;  case NPNVxtAppContext : return NPERR_GENERIC_ERROR;#endif#ifdef XP_PC  case NPNVnetscapeWindow :  {     ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;     nsIPluginInstancePeer *peer;                    if (NS_SUCCEEDED(inst->GetPeer(&peer)) && peer)     {       res = peer->GetValue(nsPluginInstancePeerVariable_NetscapeWindow, result);       NS_RELEASE(peer);       return res;     }                    return NPERR_GENERIC_ERROR;  }#endif  case NPNVjavascriptEnabledBool:   {    *(NPBool*)result = PR_TRUE;     nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &res));    if(NS_SUCCEEDED(res) && (nsnull != prefs))    {      PRBool js;      res = prefs->GetBoolPref("javascript.enabled", &js);      if(NS_SUCCEEDED(res))        *(NPBool*)result = js;     }    return NPERR_NO_ERROR;  }  case NPNVasdEnabledBool:     *(NPBool*)result = FALSE;     return NPERR_NO_ERROR;  case NPNVisOfflineBool:     *(NPBool*)result = FALSE;     return NPERR_NO_ERROR;  default : return NPERR_GENERIC_ERROR;  }#if 0  nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;  NS_ASSERTION(inst != NULL, "null instance");  if (inst == NULL)      return NPERR_INVALID_INSTANCE_ERROR;  nsIPluginInstancePeer *peer;  if (NS_OK == inst->GetPeer(&peer))  {    nsresult rv;    // XXX Note that for backwards compatibility, the old NPNVariables    // map correctly to NPPluginManagerVariables.    rv = peer->GetValue((nsPluginInstancePeerVariable)variable, result);    NS_RELEASE(peer);    return rv;  }  else    return NPERR_GENERIC_ERROR;#endif}