Question

I have coded a browser helper object in C# for IE, and would like to wrap up that code to implement a chrome/firefox extension. My research led me to Firebreath. I am now loading a content_script file which will fire an onSubmit event and send a message to backgound.htm,js files which handles my firebreath plugin. However, sure enough, m_host now points to the background htm file rather than the original website (from which the user pressed submit button). I tried replacing the html code form the native plugin, but it is not working..

test setup:

content_script:

document.addEventListener('DOMContentLoaded', function () {
alert(document.forms.length);
for (var i = 0; i < document.forms.length; i++) {
    document.forms[i].addEventListener("submit", function () {
        var documentHTML = "<html>" + document.documentElement.innerHTML + "</html>";
        chrome.runtime.sendMessage({ inputElement: documentHTML }, function (response) {        }); }); } });

background.js:

chrome.runtime.onMessage.addListener(
   function (request, sender, sendResponse) {
     document.getElementById('plugin0').sethtml(request.inputElement); });

firebreath code:

void coolnewtestpluginAPI::setInnerHTML(const FB::variant& innerHTML)
{
    m_host->getDOMDocument()->setInnerHTML(innerHTML.convert_cast<std::string>());
}

The native plugin is being called, and I can debug through it. "setInnerHTML()" returns successfully without any errors, but the html code is not being updated, and refers to the original background.htm file. Any ideas?

PS: I'm not that fluent in javascript, so I'd rather offload as much as possible to c# / c++

Was it helpful?

Solution

The only way to put an NPAPI/FireBreath plugin into the actual page is to inject the object tag into that page using javascript from the extension. Otherwise the plugin will know nothing about that page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top