WWDC2004 Session 405

Transcript

Kind: captions
Language: en
thank you thank you and good morning got
it I went backwards already
there we go this session is called
understanding document binding and I
thought that I should start by
explaining what we mean by document
binding so we know what we're talking
about one of the breakthrough or
revolutionary features of the original
mac back in nineteen eighty-four was the
ability to let users double-click on a
document and have it open in the right
application or an application that could
work with the document and this was
revolutionary just because the user
didn't have to figure out which tools to
use anymore the user could just start
working on a document and it's still a
very critical feature today so very
narrowly defined document binding is
what makes that work it's how the OS
associates documents with applications
that can view and edit them and on Mac
OS 10 that service is provided by the
launch services framework so that's the
technology we're going to be talking
about for the next hour I'm specifically
going into what's new with launch
services on tiger first I gave a very
narrow definition launch services
actually does more than simply associate
documents and applications and I wanted
to review what those things are it's an
API that is used heavily by the finder
and the doc other applications
third-party applications to open things
there's API that can actually just open
an application open documents and on Mac
OS 10 we added the ability to associate
URLs and specifically URL schemes with
applications that can handle those URLs
and so there's API for opening all of
those things and creating new
applications in the users workspace as I
said it in order to make that work
launch services figures out and keeps
track of application document bindings
so it looks like your application looks
at your info.plist and figures out what
kind of documents and urls you can
handle and it remembers all those
associate
now with so many applications available
today there's often a number of
applications on the system that can
handle any particular type of document
and launch services keeps track of user
preferences so that we know actually
which application is preferred when the
user clicked double clicks on a given
document and then finally because there
are certain things provided or related
to document bindings that appear in the
UI such as in the finder in another
application such as kind strings for a
document localized display names for
documents and applications and folders
there's this abstraction layer a thin
abstraction layer above the file system
that launch services provides additional
attributes that appear in the UI that
give us the nice user experience that we
expect on the Mac so those are the
things that launch services does and I'd
like to talk then about the topics and
get this to work the topics we want to
talk about today as far as what's new in
launch services on tiger now first one
is actually not new uniform type
identifiers were introduced in 10.3 but
they were very specifically introduced
for one purpose which was to support the
new carbon pasteboard api and they're
going to be used much more widely on
tiger and i want to give a quick
overview of what they are how they work
because it's relevant to the rest of the
session uniform talk identifiers are
going to be used in a new way to declare
your document kinds in your info.plist
so that you can simplify your info.plist
and benefit from other features that
UTIs provide and then there's three new
sets of API and launch services first
one is a new way to access item
attributes that's the abstraction layer
over the file system new API for
actually setting and reading user user
binding preferences and new options for
opening things new ways
to open documents URLs and applications
I've got a little spiel about security
and how it relates to launch services
and I want to finish up with some
interesting ways in which we're
extending the whole idea of opening
things and how what kinds of things can
be opened in the users workspace let's
start with uniform type identifiers when
Mac os10 was introduced we wanted to
play really well with the rest of the
computing world one of the controversial
things we did was recognized filename
extensions we also wanted to work really
well with the Internet these things were
all facts of life that we had to
interoperate well with the computing
world and it led to a kind of Tower of
Babel as how as far as how we identify
data and file system object types on the
system and to use an example of this
these are all the different ways that
TIFF data might be identified on 10 on
Mac OS 10 there's a mind type is to
filename extensions that are distinct
but they mean the same thing there's
Coco's and asked if keyboard type for
the NS pasteboard and then there's the
tip OS type which might be on the carbon
scrap or it could be associated with a
file on disk and there was no system
service to kind of tie all these
together and make it clear that they
were related there was internet config
but it didn't didn't cover all of these
namespaces and it was really geared
towards the internet and we wanted to
provide a general service for abstractly
recognizing types and that's what UTIs
are we decided we needed to introduce a
new name space because none of the
existing ones really did the trick they
were too prone to collisions or in order
to avoid collisions like mime types they
required registration and there were all
sorts of mime types that aren't even
declared or don't exist yet that we
wanted to associate with the files on
the system
and so we didn't want to be tied to mind
types and so we create a new naming
convention called uniform type
identifier this is an example of public
TIFF and what's key to making it not
just another name space is that built
into the system use the ability to map
it to other type namespaces and so the
API associated with UTIs allows you to
go back and forth between a UTI and a
mime type filename extension and so on
so it's very easy to give it a file
figure out what its UTI is given some
data on the pasteboard see its UTI and
so on so that's one thing that's built
in that helps us make sense of all this
type identification stuff you have to
bend down like this to get the slides to
go forward what about the namespace well
we Monaco's time was introduced we
borrowed from Java to use the reverse
dns name space for bundle identifier and
in a way bundle identifier is the modern
replacement for the Creator signature on
an application so it's kind of natural
to extend that to type identifiers and
so let me bring up a couple of other
examples for types that are proprietary
are owned by a particular organization
we use the reverse DNS naming convention
so comical depict is a quick draw
picture data and calm dotted OB
photoshop PSD would be an example of a
Photoshop document now the important
thing is that they're unique the name
doesn't imply any sort of type hierarchy
as with mine types but the important
thing is that we using reverse DNS makes
it naturally unique and we're not going
to have to legends they're also kind of
verbose you can read them you know what
organization their associated with who
to go to for more information about a
type you're not familiar with and then
four types that I really are in the
public domain or not owned by any the
standard types we just put those in the
public things are the public domain
public dot so that it's clear that
they're UTIs and that there
standard now I mention the type
hierarchy with mime types we wanted to
go further than that the mime type
hierarchy is very fixed it's built into
the name and fairly simple you've got
images audio video text and we felt it
was important to have a runtime actually
identified types in a hierarchy and as
we go through the session and other
sessions later this week you'll see how
that hierarchy is useful these are all
examples of images the same types i had
on the last slide and so they are
declared as being subtypes or conforming
to public image and abstract type and
this is important because users think of
these files because images and by
associating them as subtypes of
something called public image we can
associate certain attributes that are
associated with images such as the
resolution height width and so on this
is something that spotlight uses a lot
for building the metadata store to go a
step further all images are data streams
and so pretty much every file on disk is
a subtype of public data because it's a
data stream but because it's a multiple
multiple inheritance hierarchy we can
add other tags if you will or names to a
type and content is something that
reflects document content something that
when user double clicks on it it's going
to open as a document something they can
edit just some other examples of
abstract types like that let's look at
sub types of content we've got images of
which I gave few concrete examples we've
also got public text which is anything
which is texting coded now this is by
the way this is not going to be a
complete overview of the type hierarchy
this session is not really supposed to
be about UTIs but it's important to get
a feel for what it's like and there's
some documentation I can point you out
later another one is audio-visual
content which is a way to
of all time based media audio and video
together we can also model different
kinds of directories so we use
directories in a lot of different way a
lot of different ways in the file system
now but the root type for directories is
public directory and everything pretty
much goes into two categories either
it's a folder which is something the
user can navigate into or it's a package
which is something we define as
something that to the user looks like a
file an example of a concrete package is
an application bundle and then finally I
wanted to give another example of how
multiple inheritance can be used there's
several kinds of applications on the
system there's application bumbles
there's also files with type A ppl which
can be applications and so we have an
abstract supertype condotta filled out
application and you can use that for
instance in a file selection dialog if
you filter for just one UTI com app
about application the user will be able
to select any kind of application
whether it's a bundle or a file so it
gives us this very rich type description
model and it's extensible because the
namespace of naturally avoid collisions
you can add your type to the hierarchy
and you do that by putting it a dell
oration your info.plist it's some xml
pretty simple it's similar to how
document types are currently declared
you give the type identifier you say
what it conforms to and then you list
out the different kinds of tags or other
name spaces such as this one has to
filename extensions and one mime type
and that's how you create automatic
mappings between the UTI the abstract
type that is and specific namespace tags
so those are the key points about UTIs
we've got naming conventions that ensure
uniqueness it gives us an abstract idea
of what a type is independent of all the
different namespaces
they also exist in a hierarchy which
gives us a nice model for filtering and
associated metadata and the key is to
declare your own types so that other
applications can take advantage of them
and you'll see some advantages of that
later on in 10.3 there were not a whole
lot of types declared because as I said
it was targeted really in just a
baseboard but we've added a lot more
there are string constants for them
along with some commentary in this
header UT core.typed H so enough of that
let's go on more specifically to launch
services and how UTIs can simplify your
application development when you declare
your document types that is what kinds
of documents you can open in your
application it's fairly laborious you
have to even four basic types like JPEG
TIFF or txt files you have to go through
and you list every possible OS type
every mine type every file name
extension that you want to recognize
it's kind of very literal and there's no
notion of abstractly recognizing the
type and that means every application
that opens JPEGs has to come up with the
right list of JPEG identifiers and more
importantly if you open text well
there's no way in the world you can
possibly list every file name extension
that might be a text type so UTIs allow
us to simplify that process and leverage
the type hierarchy and type knowledge
contributed by other applications on the
system they also let us do nifty things
like inherit icons and kind strings so
to give kind of an extreme example here
is this is pulled from a preview app
this is not even the whole type
declaration but this is just for three
types we've got a tip JPEGs and ticked
and it's saying that it's a viewer for
these three types that lists all of the
different filename extensions and os
types
and it provides an icon and a kind
string and it's a lot of text i
purposely made it unreadable that's the
point it's small because there's a lot
of it and I had to fit it all on one
slide on tiger you can simplify all that
we've got one dictionary here of listing
several document types and he uses a new
key LS item content types and in its
array it's an array of UTIs claiming
JPEG TIFF and picked the same three
types from the last slide and it says
that the application is a viewer for
these types and it doesn't even if you
don't want to you don't even have to
provide an icon or a time string because
the system will provide the default icon
and time string associated with those
types you still can if you want to have
a branded icon when a file is bound to
your app you can provide an icon but you
don't have to you don't risk having a
completely generic document show up
document icon show up by not providing
one so as you can see this is much
simpler it and it allows all
applications using this style of
declaration to have the same definition
of what a JPEG is what a tip is and what
a pict is so everyone's using the same
extensions same OS types because that's
controlled elsewhere by the type
declaration another way to think of it
is that we took what was document type
declaration that we split it up into an
abstract type and then an association of
the type with a role in this case viewer
another example I call this a free lunch
because if you want to claim to open all
plain text files the advantage of doing
this is that you suddenly gained the
ability to open a plain text file
declared by some other application on
the system so you don't even have to
know what the extension is or how is
identified as text you rely on the
system to determine that and you if you
declare this this way then somebody will
take a plain text file try to drop it on
your application and they'll get the
right feedback and Kim then the document
can be dropped even though you might
have no idea what the extension is back
to directories up until now we've had
kind of no modern equivalent of the old
fold and disk OS types that were used to
allow folders and hard disks to be
dropped onto an application now we have
UTIs for those as well as for package
types and so on and those can be listed
as LS item content types in your p list
so i think what i should do now is
switch over to the demo machine and just
give an example here of what I've been
talking about in the example I picked
picked is text of it because everyone
knows what it is and sample code or the
source code is available as an example
on the DVD you received so we're
starting out with stock text edit and
let's see what it can do now I'm going
to show a series of drag and drop
operations because that's an easy way to
test document binding you get feedback
as to whether the application is going
to accept a document and here's a plain
text shopping list so obviously that is
going to work there we go and let's move
along here's a dot C file source code is
it going to be able to handle that
probably here's some HTML i'm not sure
what it's going to do with that but it
is tech
so let's see okay so actually text edit
knows how to render HTML that's kind of
nice gives me a nice rich text display
now here's a PDF that's not really a
text file but let's see what text said
it's going to do looks like maybe it is
going to open it and that's kind of
disappointing isn't it it's kind of a
downer because it looked like it was
going to do the right thing and and it
really did this this just that's not
what I want well so that's not so good I
wonder well I wonder what would happen
if I grabbed a hard disk drag what it
looks like you can open those two at
least it didn't try to display the
contents of my hard disk so it gave me
an error message instead well what's
going on here textedit want to try to
open anything and there might be some
good reasons for doing that because it
can be it gives a stab at recognizing
anything is a text file and trying to
display it but in the only mechanism by
which currently of it is available to be
able to try to open anything is to
essentially claim to open everything
there's a wild card in TextEdit CP list
and let's go take a look at the Xcode
project here if we go to the expert view
of the plist editor barely readable I
can't make it any bigger here's the CF
bundled document types and if we look I
think it's number three yeah this is of
the plain text claim and we look at the
extensions it has txt txt and asterisk
and that asterisk asterisk is really
what they don't even have to list
anything else in there p list if you
just list an asterisk it says let
anything be dropped on this application
and with UTIs we can do a little bit
better than that
and I'm going to go in here and just get
rid of everything and I even want to get
rid of most of these here go to the icon
linetypes typename OS types that we've
got the role it's an editor and i'm
going to create a new key LF item
content types and if I don't get it
exactly right it'll be a sad demo and
this is an array
and let's add a UTI here public text
this is saying open any kind of text
file by the way the difference between
text and plain dash texture that is that
text includes things like HTML or RTF
textbook markup plain text has mil mark
up so I built it I think and let's see
this is the this was actually the build
target right here let's see what happens
we can still open shopping lists you can
open dot C files even though textedit
knows nothing about the dot C extension
or claims to know nothing HTML well the
system recognizes that as a subtype of
text so we can still drop that if we
grab PDF however it won't let us drop it
anymore cuz PDF is not a type of text
and why don't we grab the hard disk and
sure enough it won't let us drop that
either in fact the finder is showing the
that make alias icon because it's going
to make an alias in this folder if I
drop it here so we've improved the user
feedback there and simplified the plist
at the same time now just one more quick
example suppose for some reason we
wanted to add back the ability to open
volumes textedit suddenly could browse
volumes so let's add one more UT IM here
there we go and build that
and we should be able to drop that if we
wanted to so by adding one value to the
plist we can really get very precise
definition or declaration if you will of
what kinds of documents your application
can open and these will these
associations will work back to the
slides I guess even if even for
double-clicking if when you double-click
a particular kind of document if there's
an application that specifically claims
that UTI or document kind it will be
preferred but if there is no specific
applications available like that then an
application say claiming plain text will
become a candidate for opening a text
file so one problem with all this is
that you're going to start getting open
document events Oh doc Apple events for
files that you may not know anything
about you may not recognize any of the
metadata associated with that file so
you need to know what kind of file it is
and for that we were providing new API
and launch services there's a new
content type property associated with
everything on disk it's not actually on
disk but you get at it through launch
services there's really no need to store
yet another type identifier on disk
because we've got filename extensions
we've got our less types and so the
content type is a UTI that is
essentially derived from all the
available metadata and you just have to
have to ask launch services what the
content type is and then you know and it
may be a very specific subtypes again
you don't know anything about that you
can test it for conformance to the types
you do recognize so if you recognize
playing text you say ok I've got its UTI
does it conform to plain text us you ask
us that and we say yes and then you know
what to do with it
now as far as API to get at the content
type attribute we could have just added
a new method and say given this FS ref
what is the content type and the reason
we didn't do that was that we kind of
have been adding a number of those on
with each release of Mac OS 10 first
there was the kind string that you could
get for a file then there was the
display name and the problem is that
each of those introduced io or cause I
owe to happen so if you have to get
several attributes the i/o gets done
over and over again so we've generalized
that to two new functions LS copy item
attribute and more interestingly LF copy
item attributes a bulk call so that
attributes have names and you also have
to provide a role mask which means you
know you're asking for an attribute as
an editor or a viewer because the role
can affect the document binding and you
get back a value which is often a string
that it could be any core foundation
object types such as a boolean a number
in the case of the bulk call you pass in
an array of attribute names and you get
back a dictionary of key value pairs and
the bulk call is really nice if you know
what attributes you need in your ear you
I what you're going to have to display
or work with you can ask for all those
at once and we only have to do the i/o
once on the file to get the attributes
so there's a number of string constants
naming the attributes now in the launch
services headers the attributes include
and there's a few other ones but the
major ones are the content type which is
the UTI and by the way content type is
also the term used for spotlight for the
metadata framework which you'll learn a
bit more about tomorrow and it's very
important property for categorizing
metadata and then the content type is
the only new attribute we also provide
the display name the kind string and
just for completeness in to allow bulk
access you can get the type of the
creator and the extension of the target
object
so that's the attributes API I want to
go on now to the next set of API which
is new and tiger which is setting
handler preferences I didn't want to go
through I probably shouldn't say this I
didn't want to go through another WWDC
without being able to say that we can
essentially replace the internet config
functionality finally I'm Mac os10 and
that's what the Preferences API provides
is a way to do part of what internet
config disz would internet config did
which was associate file types and
extensions with a creator code that
would be the default handler and also
associated schemes with a creator code
which would be the default handler for a
given URL and we've tried to keep it
simple in that spirit but using the type
the data types that are in common use on
Mac OS 10 so the terminology goes like
this a handler is an application which
is capable of opening a particular kind
of document or our particular URL scheme
and for a given a document type or
scheme you can get what the default
handler is that is that the one that the
user prefers you can get all the known
handlers in a list and that's useful for
driving in you I say for a pop-up menu
and you can set the default handler now
handlers are specified not by a specific
application instance but by bundle ID
and so it allows us to pick the user's
preferred say if if if if an app is
already running for instance and the
user prefers that bundle ID we're going
to use the app that's already running
not another one on disk so when you set
preferences you give a bundle identifier
and as I mentioned just pretty much
replaces a key part of the Internet
config API so here's a simple example
contenttype handlers are driven by UTIs
expressed as
the content type in this case a JPEG if
you were to ask launch services for a
list of possible handlers you would
actually get back a pretty long list of
JPEG handlers on the system but to
simplify here 3 preview of course which
is the one that ships out of the box is
the default bbedit can actually display
JPEGs I found and Internet Explorer and
each content or each handler has a role
so this is saying that the default
viewer for jpg is condotta Apple dot
preview and so if you ask the default
viewer you'll get back that bundle
identifier if you set the default viewer
to BB edit it will create an association
to handle JPEGs by default in BB at it
now here the API is real quick all I
need to say about them is that there's
three functions for utis you can get the
default role handler copy all the role
handlers to get a list of bundle
identifier and you can set the default
role handler these are in the headers so
you don't need to like type fees or
anything it's a little bit simpler for
URL schemes but the same idea you just
you can pass any URL scheme there's no
roles with you are handling URLs but you
pass any URL scheme you can get the
default handler you can get a list of
all the available handlers for a given
scheme so you passing HTTP you give up
all the browsers on the system for
example and you can set what the default
handler is so very simple API and this
is something that developers have
requested for some time there are
various reasons why in your preferences
dialog or add application launch you
might want to give the user some choice
about us making your app the default but
I want to put some guidelines out there
for setting handlers that you need to
remember these are because we're taking
a little bit of a risk by making all
these pub
because they can be abused the idea of
these AP is is that they set user
preferences not developer preferences
you may want all of your documents and
URLs to go to your application but this
is not an invitation to just slam the
settings all of these should be used
with the users dishes in mind so you're
going to be changing preferences you
should be informative about what you're
doing what you're changing give the user
a choice and make sure that you have the
users consent you follow what the user
asks for and don't pester the user I
know that there's a desire sometimes on
first launch of an application to ask
you you know if you want the app to be
the default handler and you know that's
okay throwing up an alert ism isn't the
ideal you I but just don't do it every
time if the user says no the user has
said no the user says yes great the
third set of new API for that I want to
talk about today is opening things we've
had a bunch of developer requests over
the last couple of years and they've
piled up enough so that we can provide
to them all in one fell swoop so I
actually tried to include everything we
had a record of in our bug database for
the things people wanted from the ls
open calls those include getting back
that getting back to process serial
number when you open a document or an
application shut up he works with me the
initial apple event so you can you can
put together any arbitrary apple event
you want and pass it to an application
that you're launching passing in
arguments which eventually get sent to
your main which is useful if you're
launching some unix or unix oriented
utility and is also setting up an
environment any arbitrary environment
that you want for the launched
application and then finally being able
to open a document with a specific role
so if you want to open a document for
viewing or specifically for editing or
for some other role this API lets you do
that so what does it look like well
first of all there's a structure which
is used by the three functions which are
going to follow and inside the structure
is everything related to specifically
launching in applications that is
nothing related to documents or URLs but
just specifying an application and how
it should be launched its called LF
application parameters and there's
launch flags which are already used in
the old LS open API there is an FS ref
for which application should be launched
and then there's some other things like
the environment has a dictionary of key
value pairs are the command line
arguments as an array of strings and the
initial apple event and this is nice you
don't even have to flatten the apple
event like you did with the process
manager api's you just create an apple
event and pass it into this in this
structure and it will get delivered as a
first Apple event to the target ad and
so if you want to open an application
you have this simple function to call LS
open application you passing the
parameters structure that we just looked
at and you get back a process serial
number that's a nice simple one but you
can also open an array of items or
documents I don't call them documents
because they might be folders or
packages they could even be an array of
applications I suppose but it takes an
array of FS Restless of FS reps and a
role to open it in you can pass in all
roles if you don't really care you can
set the application parameters if you
want is that is if you want to open the
document in a specific application you
can specify that or you can leave the
apt params no and let launch services
pick the application and you get back
actually an array of process serial
numbers this is usually you passing one
item and you get back one process stereo
memory but if you
ft in 10 documents like sometimes the
finder does they can each go off to a
different application and so you get
back an array of process serial numbers
which is a parallel array telling you
where each document was sent to and then
there's a similar API for URLs in this
case it's very similar except that you
have an array of URLs to open these
could be document URLs by the way which
is especially convenient for say Koko
apps you can pass in file URLs here and
they'll be handled as documents okay
that's all the new API want to talk
about there's a few other odds and ends
but that is the bulk of it it's new in
Tiger now I want to talk about security
just earlier this month there was a
security update that went out and launch
services was in that security update in
fact it was it was happening just as I
was trying to gear up for WWDC so it
distracted me for a while but we
actually want we had to change the
launch services behavior in order to
avoid running an application that the
user didn't trust it is an application
which the user may have downloaded
perhaps accidentally and then maybe the
user clicked on a URL on a web page and
that application was a handler for the
URL and it would get launched so there's
a small chance there could be a
malicious application that got launched
this way we didn't actually have any
cases of this but we wanted to close
that up as soon as possible so the
important thing I want to pass along is
kind of what changed in launch services
and and also how you guys participate in
maintaining security with respect to
launching things the main goal was don't
run untrusted code without user consent
in this context untrusted code we define
as an application which is never before
been launched if the application has
been launched we take that as kind of an
implicit statement
trust the user asked for that
application to be launched if it's a
malicious app once it's launched kids
done its thing running it again probably
even going to be any worse and
furthermore it's the user system we have
to allow the user to do what the user
wants to do so once an app is launched
its trusted but if it's never been
launched before then we don't
necessarily want to trust its bindings
that is we don't want to use it in
particular when user double clicks a
document or open the URL which is bound
only to that application so the design
principles we kind of to be really
careful because we didn't want to ruin
the user experience but the design
principles are do what the user is
asking for when we're evaluating
document bindings and URL bindings
always prefer trusted applications if
there's several choices of applications
pick a trusted one one that is the user
has run before if there are no trusted
apps then give the user a chance to
intervene and stop an app from launching
that they may not be expecting but then
once an app does launch trust that
application in the future so this
results in a minimal I guess disruption
of the user experience but now if the
user double clicks essentially winner
winner an app is first installed on the
system or it's downloaded it's in an
untrusted state and if the user launches
that application there's no intervention
know you I if the user drag something
and drops it on that application that's
an explicit gesture to launch an
application but if the user just put the
URL in the browser and we're about to
launch an untrusted app then we actually
will show some UI and it's a warning the
internet location you are opening will
open the application malware for the
first time are you sure you want to open
this application and this is the chance
we're giving the user to intervene and
say no and there's no default button
they have to make a choice
and so this this is the the way we came
up with to minimally disrupt the user
experience but also give the user a
chance to stop an application from
running unexpectedly so what are your
responsibilities in making all this work
well as I said if the user double-click
same application we're going to launch
it and all the Finder is doing is
calling LS opened on the application so
likewise if you are going to launch an
application we're not going to put up a
dialog asking the user if this is what
they really want to do so it's up to you
guys to make sure that you're launching
an application which is trusted either
it's an application you know about like
it's one of one of the applications in
your suite of applications when your
helper apps or it's something that was
explicitly selected by the user like in
James Thompson's drag drag thing is a
launcher app so the user clicks the tile
there it's essentially user consent so
those are the main things if you launch
an application either it's one of your
trusted apps or something the user
explicitly asked for if you are going to
open a document or a URL generally just
let launch services choose which
application if you pass in a document
and a specific application to use it's
like a dragon job Chester its
interpreted as an explicit request to
launch an app and we're not going to
pester the user with an alert in that
case but if you just say open a document
and let launch services choose that is
specify no for the application then
you'll get two benefits first of all
it'll be respecting the users binding
preferences because LS will follow that
choice and it will also enable us to
show the consent alert if it's necessary
to block an untrusted app from launch
is one other new thing in Tiger which we
want to build awareness of and over time
will help us improve security we want to
encourage people to use a new role of
shell role shell in your info.plist be
prior to tiger the only two roles you
could list in your info.plist where
editor and viewer and it turns out that
there's really another kind of document
commonly in use which isn't really a
document it's an executable which isn't
an application it could be a jar file a
Java you know a java application or an
apple script or any other kind of
proprietary scripting language and
double-clicking it is going to execute
the program in that document and if you
are offering that kind of service for
one of your documents put it in your
info.plist as rural shell this will
allow us to know that you're not
actually going to edit or view the
document you're going to execute the
document and so there may be special
security measures that we want to
provide in the future in order to help
the user know what's going to happen for
instance we might change the appearance
of things which are going to get
executed when they're double clicked I
might look a little bit different than
regular documents I'm not saying we're
going to do that in fact we haven't even
tried that but it's a possibility so
likewise if you if if all executable
files are claimed with rural shell then
when you go to LS open something if you
don't you want to make sure it's not
executed you can just specify roll
editor a roll viewer and will refuse to
pick an app that claims roll shell for
the type of document that you're opening
so that's something new to tiger and we
just are encouraging people to start
using it it will become more useful over
time now the last topic today I want to
talk about is extending the open
metaphor
this is something I've been wanting to
do for a while and it's fun to show it
in Tiger now since the doc was
introduced it's this really nice access
point for applications and from the
beginning we've been able to drag
documents down to the dock and drop them
onto application tiles and it's a great
drop target because it's always there
it's always at the top layer it's never
hidden behind anything and I found that
there were times when I was frustrated
because there were other things I wanted
to drag down to the dock and nothing
would happen I would get hover over an
application tile and there's no feedback
you can't drop anything and so by
extending the open metaphor I'm looking
at what other kinds of things can we
open currently we can open applications
documents and URLs and we can do that
through various methods such as the open
menu command in the finder single
clicking a URL double-clicking a
document and then there's drag and drop
and drag and drop is something that you
can do with documents but you can also
drag content out of an application
window you can drag the URL out of an
application window and when to be nice
if we could do something with that in
the dock and in order to really help you
understand I'm just going to show it to
you
I've done this demo a couple of times
now for various people at Apple and a
common reaction is can't we do that
already and that's very promising very I
like that reaction because it means it's
a natural thing and amazingly all the
other stuff I'm about to do we can't do
in panther in 10.3 so I'm in mail and my
friend keith has sent me an email which
I want to take a look at it says Chris
did you see this morning's news about
spaceship one this was last week and no
I hadn't seen the name is about
spaceship one but I'm wondering what he
means and then I noticed Keith kind of a
knucklehead and he put the URL up in the
subject line and you know male doesn't
expect a URL in subject line so it's not
a live link like it would be in the body
and invariably this happens right you
get into some context where there's not
a live link you've got a URL you have to
copy it out onto the pasteboard go to a
browser paste it in press return to get
there and it would be much smoother if
we could just grab that URL and drag it
down say to Safari and have it open the
URL so it's much faster and it got me
here to this article about spaceship won
the first privately-funded spaceship to
leave the atmosphere and that's pretty
cool and there's some control about the
first successful test flight and some
photos but I really actually would like
to get to the spaceship one official
website and I'm wondering if there's any
way I can do that well maybe I can grab
this and drag it down here that's not a
URL so what is Safari do with it well it
does a google search on it and the first
the first hit here is the spaceship one
home page so let's go there and see what
we've got here it is they've got a bunch
of information about the spaceship and
the test flight and let us at other some
photos whole photo gallery and I happen
to know because I've rehearsed this that
on this page there's a photo of the
cockpit which was kind of interesting
it's it's pretty simple for a spaceship
don't you think but I kind of would like
to get a closer look so I'm going to
grab that photo and drag it down to
preview and drop it on preview and I get
a new window here in preview whoops
subscribe to preview and that's kind of
useful because I can zoom in I'm not
really getting more resolution but I can
see it a little bit better and I can
grab it around so it was just a nice
simple way to get an image into another
application maybe I want to save it at
this point or I can even drag it into an
image editor now let's go back to the
website and here's the press release
page and here's their press release for
their announcing the first successful
flight and maybe I want to send that
back to keep my friend Keith I'm going
to do select all and grab that and drag
it down to mail and I get a new message
ready to be addressed to mail doesn't
have the image yet but we're working on
that and so you can see it's all very
natural gestures saves time and it
really leverages the dock as a great
drop destination now if I can go back to
the slides now I get to one of the
coolest parts about this is that i
didn't have to change those applications
except for preview i made no changes to
those applications to make that demo
work i added about five lines to preview
in order to allow it to accept the drop
but otherwise mail and safari were
already set up to do
you wonder how can that be and the way
it works is that we already have a very
well-established mechanism for working
with data on the pasteboard coming from
another application and that is the
services menu applications in there
info.plist can declare services and they
show up under the under the application
menu who say for male you can select
some text go to the services menu and
you see a bunch of services offered by
other applications that operate on text
for example and this is really then just
a new way to invoke a service so we're
integrating existing technology with the
doc and this is the details of how it
works some of the details I guess we do
use an apple event in order to send the
data between applications because we
want it to be all asynchronous and so
there's a new apple event ka e open
content or Oh calm and it is simply it's
very similar to an ER doc event except
instead of a list of document references
it's a list of data items of AE desk and
each desk contains the data to be open
so when I drag that image out of Safari
down to preview we created an open event
we stuffed the entire image into the
yoke I'm event and we very efficiently
moved it between processes delivered it
to preview but preview doesn't have a no
con event handler and none of those
applications have a note on event
handler you can choose to handle the
hook on event directly if you want or
you can allow look you can allow launch
services to handle it for you and what
launch services does in Tiger is it
installed a system default handler for
the Oakland event and when an old kind
of event goes unhandled we look at the
current applications list of services
and we look to see if they're a service
that the app provides which can handle
this type of data and if there is we
just invoke the service so if you adopt
services not only where you appear in
the services menu but now you will also
be able to
you have the service invoked as a drop
target on your application icon and
we'll also integrate this into the
finder for dropping things in the finder
as well that is dropping things on
application icons in the finder and that
might be hit oh one more slide so you
know some of this already went over you
add a services declaration to your pee
list and handle the Oakland event only
if you want to and one other thing I
want to say about how to respond to it
usually the response in many
applications will be open an untitled
window you essentially get a new
document untitled and it has all of the
data in the okanagan but you can be a
little more creative than that if you
wish in Safari was a good example there
it got some plain text it was able to
take that and figure out that it should
do a Google search on it because that's
the most logical thing to happen in
safari with a chunk of plain text so
feel free to be creative so what are the
main points i want to take want you to
take away today they are the following
uniform type identifiers are used much
more widely and tired than they were on
Panther both in launch services-karbonn
pasteboard what else the trans-
translation services carbon API we have
plans and tiger to use them in
navigation services for filtering and
Coco has plans to adopt them more widely
also in its API oh yeah Thank You Alan
spotlight also is organizes its metadata
around uniform type identifiers so it's
a great foundational technology on the
system we have new API for setting
handler preferences use them don't abuse
them we have new Ellis open functions
with a bunch of features that you guys
have asked for please try to follow our
new guidelines for opening things and
help us maintain security and the sister
and finally using services now with
integration with drag-and-drop gives you
a great new kind of portal into your
application increasing the value of your
application to the user and I am done
now I think we have one more is
documentation we have some documentation
now on uniform type identifiers we just
finished a couple of weeks ago and it's
available on the wdc reference library
site and also it didn't make the DVD but
I encourage you to read the release
notes also the launch services release
notes not everything you've seen is
implemented yet and so it's good to read
the release notes before you get
frustrated we're going to get it to you
as soon as we can