How to add plugin to safari using cocoa?

I want to develop a Safari plugin using xCode, which API should I use? Someone can give me some docs or code samples, thanks very much!

+2


source to share


2 answers


The answer is rather complicated, I'm afraid.

Unfortunately, in Safari, the web browser does not have a plugin API. This means that you technically cannot distribute Safari's user interface or features using plugins.

However, WebKit for the web rendering engine (which includes Safari and many other browsers / apps) has a plugin API (it actually has 2) that allows you to create plugins for rendering web content in webkit webviews.

You can find documentation on developing WebKit plugins in Apple docs here . (PDF Link!)

Also note that Safari's lack of a true plugin API has not stopped many developers from developing various software products that they call "Safari plugins", even if they are not technically Safari plugins. They are commonly referred to as "input managers", which are widely regarded as rather dubious pieces of software. Input Managers always seem to be on the cusp of something that Apple doesn't or doesn't support Apple. It's not entirely clear if the entrance managers are kosher with Apple or not.



Then again several "Safari plugin" input managers are quite popular, so ....

Input managers are another topic. I am sure that if you do this, you can find a lot of information about them. However, I personally would advise against creating an Input Manager because of their questionable status in the Mac software world and their constant danger of becoming unsupported or severely broken.

Update . A few years after I originally answered this question, Apple did provide its own API for the Safari browser itself. However, they are called "extensions" and not plugins.

See the Apple Safari Extension Programming Guide for details .

+3


source


Check out Rentzsch's ClickToFlash , this is a plugin that is reasonably well documented along with neat source code.



+2


source







All Articles