Re: Defining custom mime type in WebView?
Re: Defining custom mime type in WebView?
- Subject: Re: Defining custom mime type in WebView?
- From: Sherm Pendley <email@hidden>
- Date: Sun, 29 Feb 2004 05:33:33 -0500
On Feb 29, 2004, at 4:11 AM, Ken Tozier wrote:
I'd like to create a custom html tag (for use in an internal corporate
site) that's similar in functionality to the "<a href="">" tag but
instead of jumping to another page or opening another window, I'd like
to be able to send "open file" or "import file" messages with the url
of the clicked items to applications on the user's machine.
Just use an ordinary HTML <a href="..."></a> element. Implement the
WebPolicyDelegate protocol in your app, and respond to the
"-webView:decidePolicyForNavigationAction:request:frame:
decisionListener:" message. For URLs you want to handle yourself, just
do whatever it is you want to do with the target URL, and then tell the
web view to ignore it by sending the decisionListener object an
"ignore" message.
How to pass the URL to the other application will depend on how that
app is (or can be) told to open URL's. It's probably worth trying the
simplest thing first, using simple file:// URLs and opening them with
NSWorkspace's -openURL: method. If the file has the correct extension
and/or creator code, NSWorkspace should be able to figure out what app
to open it with.
After reading all WebView related posts of the last few months, it
looks like the best solution would be to define and register a custom
mime type and a class to handle it. What I'm really confused about
though is how to represent this in the html.
That's a different topic entirely. That's not how you handle resources
that are external to your app. It's what you'd do to handle *inline*
content that's displayed as part of the page, and marked up with
<object type="application/x-myapp"></object> - sort of like how
embedded QuickTime, Flash, or Java applets are handled without
launching an external player app.
WebView might want you to use the "codetype" attribute instead of
"type" - the HTML reference I have is a bit vague on which one is
preferred, and I've no idea which one WebView supports, if not both.
You'd probably need to configure the correct MIME type on the server as
well, using Apache's "AddType application/x-myapp .myapp" directive.
A related question is, once a mime type is registered, does WebView
notify registered classes of every event that happens to that object?
Classes that are registered to handle mime types have to implement the
WebDocumentView protocol, and according to the docs for the protocol,
classes that implement it are expected to be a subclass of NSView. So
it should be capable of sending whatever action messages are
appropriate for your application and the view's contents.
For resources loaded externally, it depends entirely on the app that
opened them. If it's an app of your own design, you could code it to
communicate back to you via Distributed Objects or some other means. If
it's a third-party app like PhotoShop, you're limited to whatever means
the author has provided - if any - for being notified of what it does.
sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.