How cast HWND to NSWindow * in FireBreath? - npapi

Is there any way to cast HWND FB::PluginWindowWin::getBrowserHWND to NSWindow *? The reason why I need this, is to interact with Browser window, from my Cocoa app for OSX, (like open sheet on it,etc..). If there is no way, how else it can be done, any idea?
Thanks a lot.

You can't get the NSWindow from a Mac NPAPI plugin. Back in the day of carbon it used to be possible to get some of them, but it was never a supported feature, just something that happened to work in some versions.
Sorry for the bad news

Related

Chrome extension to enable flash plugin

I am working for a game which runs in Adobe Flash. From Chrome 69, sites using Flash will require explicit permission to run it, every time the user restarts the browser. We are expecting lot of our players will get dropped off as they need to go through click-to-play flow every time they restart the browser.(Flash Roadmap -> https://www.chromium.org/flash-roadmap)
So we came up with an idea of using chrome extension which can enable flash plugin in background for our game website. We used 'chrome.contentSettings' for creating this extension.
Can someone please confirm if there is any roadmap plan from chrome to stop controlling of 'adobe-flash-player' plugin from 'chrome.contentSettings'.
Other words pls tell me how long below api code will work ?
var flashResIdentifier;
chrome.contentSettings.plugins.getResourceIdentifiers(function(resIdentifiers) {
for (var i=0; ihttps://abc.xyz.com/', 'resourceIdentifier':flashResIdentifier, 'setting':'allow'});
This will re-enable Flash manual white-listing
in the latest Chrome 69+ and higher
chrome://flags/#enable-ephemeral-flash-permission
Set to DISABLED
then use Flash manual white-listing by going here:
chrome://settings/content/flash
Then manually add all website URL links
that you need like before
in Chrome 68 and lower
After Chrome 71, you can persistently reenable flash for specific websites on Windows via a registry setting. Go to or create HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls, and add string values starting with a name of "1" and a value of the URL you wish to enable flash for (so, HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls\1 = "http://myawesomesite.com/*" to enable Flash for everything under myawesomesite.com).
There is a similar setting for OSX and Android. See here for more information.
I had the same problem in version 72 of Chrome, and the solution I found is the following:
Click the paddlock icon, and go to Site settings:
Then, on Flash option, select Allow
Refresh page, and that's all! :)
Reference: https://www.lifewire.com/enable-flash-in-chrome-4160696

GeoLocation from gpsd

The gpsd program lets linux users cleanly organize their GPS peripheral data, such that a command line program like cgps or a graphical one like xgps can read the data, and write to a socket, like /var/run/gpsd.sock.
There's a nice tutorial on the net for rigging a raspberry pi to use this data. This is all well and good, but how can I integrate this data in firefox or chromium, as the geolocation API? Is there a specific build process I might need? For instance, setting a ./configure flag or something? Is there a way to integrate this data in a prebuilt version of either browser?
Firefox on Linux supports gpsd - it was added in Firefox 4, removed in Firefox 23 and added back in Firefox 50.
However, it still needs to be enabled during build, with --enable-gpsd (which seems not to be the case yet in Ubuntu) and in the configuration, by following these steps:
Navigate to about:config
Create a new string preference, name geo.location.use_gpsd value true
Prior to Firefox 23, you had to:
Create a new string preference, name geo.gpsd.host.ipaddr value localhost
Create a new boolean value, name geo.gpsd.logging.enabled value true
Google Chrome had gpds support added in November 2011 and removed in October 2013. It looks like hardware GPS support is not a priority. If this was handled in Chrome OS, it might be possible to use the same mechanism, but I don't see support there either.
Someone built an extension which attempts to provide support in recent versions, requiring to install a script system-side.
Firefox on linux used to support gpsd.
Navigate to about:config
Create a new string preference, name geo.gpsd.host.ipaddr value localhost
Create a new boolean value, name geo.gpsd.logging.enabled value true
However, it seems that the gpsd support has been removed
Chromium seems to have had gpsd support in the past, but I can't find anything about it now. It looks like hardware gps support is not a priority. If this was handled in ChromeOS, it might be possible to use the same mechanism, but I don't see support there either.
In both cases, it should be possible to write an extension to fake the GPS coordinates, which could read from your real GPS.

NPAPI mozilla plugin loading issue

I have successfully compiled and created npapi dll in MS based on mozilla npruntime project. Reference from: https://developer.mozilla.org/en-US/docs/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio.
Starting mozilla and open about:plugins shows the plugin. But when I open "test.html" the plugin does'nt come up.
I have tested the dll by making a separate test app, where i can access the entry point functions through
NP_INIT l_pInit= (NP_INIT)GetProcAddress(hModule, "NP_Initialize");
and i am able to step into my plugin dll function.
But with mozilla it doesn't work. Please suggest.
You can debug directly the mozilla process. Just attach to the process. However, modern browsers uses separate process for loading the third party plugins, so you will have to attach to that process. Than you can set breakpoints to loading routine (NP_GetEntryPoints, NP_Initialize) and see what is happening in there.
Also, if you have trouble with attaching to the process, you can simply show debug dialogs from your code and narrow the problem area.
UPDATE 1:
It seems like the browser does nto know that it should use the plugin. Did you specify the MIME type of hwat your plugin is for? If so, run the following script in an HTML page:
<embed type="application/x-my-extension" id="pluginId">
<script>
var plugin = document.getElementById("pluginId");
var result = plugin.myPluginMethod(); // call a method in your plugin
console.log("my plugin returned: " + result);
</script>
x-my-extensionreplace with your extension which you used in NP_GetMimeDescription. You shoudl check in about:plugins if the browser registered your plugin correctly for correct MIME type.
Sounds like there is most likely something wrong in your plugin initialization; you might try using FireBreath to create a npapi plugin, as it will be a lot less work and work on IE as well. If you don't like that idea, you could look at other npapi plugins (including FireBreath) to make sure you're doing things correctly. Add logging (of whichever type you like) to the main entrypoints and see which point it fails at.
Another trick is to go to about:config and find the plugins ipc settings and disable them; then you can attach to the main firefox process and it should hit your breakpoints if they are being called.
See the FireBreath Debugging Plugins page for other ideas.
Thanks guyz. Finally i am able to load and access the functionality of my plugin in the browser. Following are the findings:-
1. Even though my plugin's MIME type in resource file was 'application/mozilla-npruntime-scriptable-plugin'. But i need to access it from javascript embed element through 'application/x-npruntime-scriptable-plugin'. After this step the debugger started breaking on my plugin's break points.
2. The check of size of NPPluginFuncs and NPNetscapeFuncs was failing, may be because of different version of NPAPI implemented in my firefox.
At the end i got startup and thank you all for your support.

Accessing NPN_ methods from NPAPI plugin

I have a NPAPI plugin developed for Chrome. It works ok. But now I need to call NPN_GetValue from the plugin. The question is, how can I link (either statically, or dynamically) my code and what library/binary should be used for imports? I searched through all Chrome binaries and I did not find a single one, which contains NPN_ exports. Surely NPN_ methods must be provided by hosting browser.
Thanks in advance.
The function pointers are provided to you as an argument to NP_Initialize; it's your job to keep them around so that you can call them later. The functions aren't exported for you to link to.

How would I go about creating a custom protocol that would always open an address with a specific browser?

Okay, so I'm a student programmer in my college's IT department, and I'm doing browser compatibility for a web form my boss wrote. I need the user to be able to open a local file from a shared drive with a single click.
The problem is that Firefox and Chrome don't allow that for security reasons. Thus, I'm trying to write a custom protocol of my own to open an address in Internet Explorer regardless of the browser being used.
Can anyone help me with this? I'd also be willing to try an alternative solution to the problem.
The below worked for me, is this what you mean?
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo]
#="URL: foo Protocol"
"URL Protocol"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\DefaultIcon]
#="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell\open\command]
#="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe \"%1\""
Just to note, I'm running Win7Pro, so you may have to move around file path(s) to conform to your environment.
And if that doesn't work, create a proxy between the protocol and the browser, pass the argument(s) from foo:// to that, parse what's necessary, then hand it off to IE using start iexplorer.exe "args".
I'm unsure whether I understand your question, if it is how do I open local files using chrome/firefox, this is your anwser:
First a disclaimer, I have never done this and cannot vouch for the accuracy of my response
IE
Microsoft's security model is pretty fail so you can go right ahead and open these files
FireFox
Some quick googling found that Firefox can do this after either editing prefs.js as outlined here or installing an addon called LocalLink
Chrome
Practically impossible due to its security, until now when locallink was ported to chrome.