3

I have gone through the questions in this forum regarding this issues, but I have not found any query related to the kind of issue that I am facing. I have written a NPAPI plugin which works fine with GtkLauncher (comes with webkit) and firefox, but with google-chrome (18.0.1025.151), the plugin is not even showing up in about:plugins. I am running on Ubuntu 10.10.

When I am loading the plugin in google-chrome, in the browser I am getting failed to load plugin error but nothing is shown on the console. I doubt whether my NP_Initialize function is getting called.

Here is the NP_Initialize code:

-------------------------------
NPError OSCALL
NP_Initialize(NPNetscapeFuncs *npnf
#if !defined(_WINDOWS) && !defined(WEBKIT_DARWIN_SDK) 
    , NPPluginFuncs *nppfuncs)
#else
)
#endif

{
MEDIA_DEBUG_PRINT("\nwcf Media plugin: NP_Initialize");
    if(npnf == NULL)
        return NPERR_INVALID_FUNCTABLE_ERROR;
    if(HIBYTE(npnf->version) > NP_VERSION_MAJOR)
        return NPERR_INCOMPATIBLE_VERSION_ERROR;

    npnfuncs = npnf;

    #if !defined(_WINDOWS) && !defined(WEBKIT_DARWIN_SDK)
        NP_GetEntryPoints(nppfuncs);                            
    #endif

    return NPERR_NO_ERROR;

}

NPError OSCALL
NP_GetEntryPoints(NPPluginFuncs *nppfuncs) 
{

    MEDIA_DEBUG_PRINT("\nwcf Media plugin: NP_GetEntryPoints"); 
    nppfuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; 
    nppfuncs->newp = nevv; 
    nppfuncs->destroy = destroy; 
    nppfuncs->getvalue = getValue; 
    nppfuncs->event = handleEvent; 
    nppfuncs->setwindow = setWindow; 

    return NPERR_NO_ERROR;
}

I know there is a Firebreath framework for cross browser development which I have plan to use but at present I need to get my plugin running on chrome.

Can some one please help me to solve my issue?

Thanks and Regards, Souvik

taxilian
  • 14,229
  • 4
  • 34
  • 73
Souvik
  • 151
  • 3
  • 14

2 Answers2

3

Chrome tends to be a bit pickier about how things start up. I don't see anything here that would be likely to cause your issue, but Chrome is notorious for rejecting plugins that don't behave as it expects. Most likely your issue is later on; you say you doubt that your NP_Initialize is getting called, if I were you I'd verify that. Have it write to a file in /tmp/ or something to make sure.

Also you haven't provided any of your other entrypoints such as NP_GetPluginVersion or NP_GetMimeDescription. Those are needed as well for a linux plugin and could very possibly be responsible for an issue like this. For reference, take a look at FireBreath's X11 entrypoint file.

Finally, it's possible that the way you installed the plugin it is found by mozilla and not by chrome; how did you install it?

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • Thanks for your response. Actually, I have given a console print - MEDIA_DEBUG_PRINT("\nwcf Media plugin: NP_Initialize"); in NP_Initialize() function which is not getting printed when loading in Chrome. – Souvik Apr 09 '12 at 04:26
  • Yes, I'm aware that you have a console print; however, I'm not at all certain that you're likely to *see* the results of that print since you're in a seperate process from chrome and my experience is that stdout often gets redirected somewhere in those cases. If you send it to a file, then you can be certain. – taxilian Apr 09 '12 at 04:34
  • Ok I will check that immediately. I am creating a soft link of my .so files to /usr/lib/mozilla/plugins folder. I also have entry functions for MIME and version. Here are the contents: char* NP_GetMIMEDescription(void){return (char*)"application/x-wcfconn:wcf:This is a Connectivity plugin";} char * NP_GetPluginVersion(){return (char*)PLUGIN_VERSION;} – Souvik Apr 09 '12 at 04:51
  • In NP_Initialize, I have created a file /tmp/test and wrote a string. This file is not getting created when I am trying to load the plugin in Chrome. But the same file is getting created and written to when I am loading the plugin in GtkLauncher. So it seems my NP_Initialize function is not getting called in Chrome. – Souvik Apr 09 '12 at 05:04
  • If you're adding code and details it's better to edit your original question and put them there; it's hard to read here. Try putting your plugin in /usr/lib/chromium-browser/plugins instead of /usr/lib/mozilla/plugins; it might be that6 chrome just doesn't look there. Also I hope you meant a symlink and not a softlink =] – taxilian Apr 09 '12 at 14:55
2

If your plugin isn't showing in chrome://plugins, then it's failing during the initial plugin scan. Try running with the --debug-plugin-loading flag, which should give you a log statement at the point where registering your plugin is failing.

smorgan
  • 20,228
  • 3
  • 47
  • 55
  • Thanks a lot. After starting google-chrome with --debug-plugin-loading, I can get some console logs. In the console log I notice that my plugin is not able to load another library DBAccessLib (my own library which I use to access database by binding to sqlite3). and it is giving error : undefined symbol:sqlite3_sprintf), skipping . May be google chrome is not able to find libsqlite3 library. – Souvik Apr 10 '12 at 08:40