I'm developing an application (download manager-type) on OS X that I would like to integrate with the major Mac browers (Safari, Firefox, Chrome, Opera, Camino) via the Mozilla plug-in API, NPAPI. I have a basic understanding of how to register my app on the Mac to handle specific URL's and file types (via the Launch Services API, the info.plist file, etc.), and I also understand that I can register for specific MIME types in the NPAPI. However, I see almost no hooks in the NPAPI docs for integration with external applications, i.e. getting a URL via NPN_GetURL() when a hyperlink is clicked and passing this data on to an external application. The only references I've found to calling external applications is the system function in C, and I'm finding it hard to believe this is the only way it can be done. I know that other Mac apps (download managers) are able to integrate with browsers in this fashion, but there seems to be very little documentation about it. Am I misunderstanding the purpose of the NPAPI?
Yes, you are misunderstanding NPAPIs purpose. For things like intercepting clicking of links and changing the browsers behavior you need to write browser extensions, not a plugin.
See:
Plug-ins and extensions
Browser Plugins vs Extensions – the difference
The actual API of NPAPI is very limited; much of what plugins do they do through direct system calls. system isn't your only option—you can use anything you would use any any OS X application (NSWorkspace, Apple Events, IPC to a launchd-registered service, etc.)—but you won't find a call in NPAPI to do what you want.
Related
My Firefox extension is parsing big chunks of data. I would usually use WebWorkers to do this, however in XPCOM I seems that this is not an option. The ChromeWorker, https://developer.mozilla.org/en-US/docs/Web/API/ChromeWorker, seems to be obsolete and "discouraged in new projects".
Are there any options to use workers in a Firefox extension?
Short version: no, you cannot access XPCOM from a different thread. But that doesn't mean that you cannot use chrome workers.
Long version: Firefox used to allow accessing XPCOM from other threads, e.g. via ChromeWorker. This led to all kinds of issues like weird crashes or just plain inconsistent behavior. In the end Mozilla decided that supporting multithreaded XPCOM access was too complicated and error-prone, as was documenting its limitations and stopping people from shooting themselves in the feet.
With current Firefox versions, accessing XPCOM from ChromeWorker is no longer possible. ChromeWorker itself however isn't deprecated however even though the MDN comment can be easily misread as a general deprecation statement. The idea is that you would use ChromeWorker in combination with js-ctypes which will allow you to use native libraries (the ones provided by the operating system, libraries included in Firefox like NSS and libraries distributed with your extension) on a different thread.
Depending on what you are trying to achieve, this might work for you. E.g., if you need XPCOM for file access then you don't even need to use js-ctypes directly - OS.File API will do that for you. However, XPCOM access is limited to the main thread.
I have a Windows desktop application which must work in collaboration with my Chrome extension.
Can I send a message to my desktop app somehow from Google Chrome extension?
Which IPC objects can I use?
I see three options:
You could use the internet. You can have a remote service that both the chrome extension and your desktop app talk to, to communicate.
You could have your desktop app have a simple server built into it so that the chrome extension can make local http requests to it to communicate with it.
Use the Google NPAPI plugin functionality to have full access to the computer. Now deprecated
These days you would use Chrome's native messaging API to send the message from your extension to a native messaging host. The latter can be a "real" executable that then passes the message on to your desktop application.
Documentation: http://developer.chrome.com/extensions/messaging#native-messaging-host
chrome extension has a native massage api to communicate to native process,
see here:
https://developer.chrome.com/apps/nativeMessaging
This almost certainly requires a custom NPAPI plugin and cannot be done with the basic extension API. NPAPI development is fairly daunting and outside my area of expertise, but feel free to read over Google's documentation on the subject.
As an alternative, perhaps you can have your desktop application poll the internals of the extension. For example, the extension's could have a file in its sandboxed filesystem where it leaves messages for the desktop application to find. This approach is suboptimal, since it requires polling instead of pushing, but it does save you the hassle of coding an NPAPI plugin.
I'd like to develop a stand-alone desktop application targeting Windows (XP through 7) and Mac (Tiger through Snow Leopard), and if possible iPhone and Android. In order to make it all work with as much common code as possible (and because it's the only thing I'm good at), I'd like to handle the main logic with HTML and JS. Using Adobe AIR is a possibility. And I think I can do this with various application wrappers, using .NET for Windows XP, Objective C for iPhone, Java for Android and native "widget" platform support for Mac and Windows Vista & 7 (though I'd like to keep the widget in the foreground, so the Mac dashboard isn't ideal). Does anyone have any suggestions on where to start? The two sticking points are:
I'll certainly need some form of persistent storage (cookies perhaps) to keep state between sessions
I'll also probably need access to remote data files, so if I use AJAX and the hosting HTML file resides on the device, it will need to be able to do cross-domain requests. I've done this on the iPhone without any problems, but I'd be surprised if this were possible on other platforms.
For me, Android and iPhone will be the easiest to handle, and it looks like I can use Adobe AIR to handle the rest. But I wanted to know if there are any other alternatives. Does anyone have any suggesions?
You might be interested in Appcelerator's Titanium. It's an alternative to Adobe AIR that lets you build native mobile and desktop apps using HTML and JS (with the WebKit rendering engine, so you can take full advantage of HTML5 and CSS3). It also satisfies your two sticking points:
SQLite is available for persistence storage.
There are no restrictions on cross-domain requests.
I used Titanium Desktop for a recent project and it was a relatively smooth development process. It's also open source so you have access to the full application at all times.
Check it out and let me know if it works for you.
You can create a desktop application with HTML, CSS & Javascript using either of the following two frameworks
TideSDK
AppJS
For mobile you can use the similar HTML and Javascript using PhoneGap
I need to write quickly this application: a simple window that wraps
a web browser control, that runs html pages.
The Browser UI (e.g. Navigation buttons) should be suppressed.
As a .net developer, I would embed the WebBrowser OCX in a Windows Form.
But this has to run on Mac as well!
I found the following cross-platform candidates.
Which one would you choose (in terms of simplicity, stableness, community support, etc.):
wxWidgets: http://www.kirix.com/labs/wxwebconnect.html
QT: http://www.youtube.com/watch?v=Ee8eRwjbcFk&feature=related
MONO: http://www.mono-project.com/WebBrowser
Why not to use embedded Webkit?
QtWebkit:
The Qt port of WebKit currently compiles and runs on Linux (including Maemo), Windows, Mac OS X and Symbian.
Click here for build instructions.
A very simple test browser is built along with the port.
Since you have (assumption made from your post) .Net experience I'd go with Mono.
Have you considered Adobe AIR?
http://www.adobe.com/products/air/
Mono is probably the best choice if you're primarily a .NET developer and don't care very much about making a well-integrated Mac app (one that behaves like a Mac app in all the many ways Mac users expect). Given your problem space, that sounds like where you are. That said, pay special attention to this limitation from the WebBrowser page if it applies to your problem:
The Mono Webbrowser currently lacks
support for window.external, the
bridge that allows Javascript code
embedded in the browser to communicate
with the managed world using the
ObjectForScripting.
QT is very well established, and a great platform if you want to develop this in C++. Remember that there are licensing fees if this is a commercial app.
I've played a bit with wxWidgets. It's big advantage here is that it's probably going to be the smallest distribution, since you only have to include what you need. If all you need is the web browser, I'd look at this, but in my experience it's hard to make wxWidgets programs look good or act correctly on Mac (or on Windows for that matter).
Another option may be to write it as a Java app using the Eclipse Standard Widget Toolkit. This includes a browser control that embeds IE, Safari or Firefox, depending on the current platform, and generally behaves well on OS X.
Now I want to develop a safari plugin use SIMBL , but I searched a lot of webpage not found some sourcecode or simple sample , someone can give me or point to a location ? Thank you very much!!!
Did you consider writing a WebKit Plugin?
As far as I understand, SIMBL plug-ins are still some kind of Input Manager and therefore not well supported on new Mac OS X versions, and not supported at all if Safari runs as 64-bit process.
A good starting point to write a WebKit plug-in:
Creating Plug-ins with Cocoa and WebKit
You can also peek into the ClickToFlash source.
ClickToFlash is implemented as WebKit plug-in.