Search code examples
pluginscookiesnpapifirebreath

How to get an NPP instance in a Firebreath plugin?


From within a class derived from FB::PluginCore (or FB::JSAPIAuto), for example in onPluginReady() or a JS method handler, I'd like to have access to the NPP instance. What is the best practice for getting this pointer?

The underlying goal is to be able to call NPN_SetValueForURL, to set cookies.


Solution

  • You can call any of the NPN functions on the NpapiBrowserHost object, which is what the BrowserHost actually is.

    FB::Npapi::NpapiBrowserHostPtr npapiHost = FB::ptr_cast<FB::Npapi::NpapiBrowserHost>(m_host);
    

    I think it has SetValueForURL on it, but if it's missing you can always add it and submit a pull request; I'll accept it as long as it's reasonable.