Fail to add NPAPI plugin into my extension. please help me

231 views
Skip to first unread message

appleBoy

unread,
Jan 6, 2011, 4:59:08 AM1/6/11
to Chromium-extensions
I create one NPAPI plugin. and it can work fine in FireFox (open the
popup.html ,it can call my plugin function foo.) . and i want to use
it in Chrome. so. follow http://code.google.com/chrome/extensions/npapi.html.
i create the manifest.json:

{
"name": "my_test",
"version": "1.0.0",
"description": "my npapi test sample",
"browser_action": {
"default_icon": "icon_19.png",
"default_title": "npapi sample",
"popup": "popup.html"
},
"plugins": [ {
"path": "plugin/npsimple.so"
} ]
}

and create folder plugin ,put the .so in it. the popup.html:

<!DOCTYPE html>
<html>
<head>
<embed type="application/x-extension-sample" id="pluginId">
</head>
<body>
<script type="text/javascript">
function foo() {
try {
alert(document.getElementById("pluginId").foo());
}
catch(e) {
alert(e);
}
}
</script>
<p>
<button onclick='foo()'>Call foo()</button>
</body>
</html>

then . i can add this extension. but it will show "Missing Plug-in".
why? what is the wrong i made . any reply are welcome. thanks.

And, i found , when add the extension , chrome will call plugin
NP_GetMIMEDescription and NP_GetVaule function for name and description

Arne Roomann-Kurrik

unread,
Jan 6, 2011, 2:19:18 PM1/6/11
to appleBoy, Chromium-extensions
Hm, are you registering the mime type in your NPAPI code correctly?  Does the corresponding mime type show up in navigator.mimeTypes in popup.html?  Does your plugin show up in about:plugins ?

~Arne


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


appleBoy chen

unread,
Jan 6, 2011, 9:25:21 PM1/6/11
to kur...@chromium.org, Chromium-extensions
//Hm, are you registering the mime type in your NPAPI code correctly?
in my NPAPI code , the NP_GetMIMEDescription  return "application/x-extension-sample::extension sample";

//Does the corresponding mime type show up in navigator.mimeTypes in popup.html?
i add these code to detect the minetype , it can find the mineType.
function detectSupport(){ 
var mimetype = navigator.mimeTypes["application/x-extension-sample"];  
if (mimetype) {  
   var plugin = mimetype.enabledPlugin;  
   if (plugin)  
       document.writeln("OK,Plugin hase installed and enabled");  

else {  
   document.writeln("Faild to load plugin.");  
}   
}

//Does your plugin show up in about:plugins ?
Yes, my plugin show in about:plugins.



2011/1/7 Arne Roomann-Kurrik <kur...@chromium.org>

appleBoy chen

unread,
Jan 7, 2011, 1:35:05 AM1/7/11
to kur...@chromium.org, Chromium-extensions
aha, i found it. it need use the XEmbed in plugin work with chrome. 
NPP_GetValue(void *future, NPPVariable variable, void *value)
{
    NPError err = NPERR_NO_ERROR;
    switch (variable) {
    case NPPVpluginNeedsXEmbed:
        *((PRBool *)value) = PR_TRUE;
        break;
    default:
        err = NPERR_GENERIC_ERROR;
    }

    return err;
}



2011/1/7 appleBoy chen <apple...@gmail.com>

Arne Roomann-Kurrik

unread,
Jan 7, 2011, 12:17:19 PM1/7/11
to appleBoy chen, Chromium-extensions
Awesome, thanks for following up with the solution.

~Arne
Reply all
Reply to author
Forward
0 new messages