WebKitPlug-InProgrammingTopicsAppleApplicationsSafari2008-10-15AppleInc.©2005,2008AppleInc.Allrightsreserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans,mechanical,electronic,photocopying,recording,orotherwise,withoutpriorwrittenpermissionofAppleInc.,withthefollowingexceptions:AnypersonisherebyauthorizedtostoredocumentationonasinglecomputerforpersonaluseonlyandtoprintcopiesofdocumentationforpersonaluseprovidedthatthedocumentationcontainsApple’scopyrightnotice.TheApplelogoisatrademarkofAppleInc.Useofthe“keyboard”Applelogo(Option-Shift-K)forcommercialpurposeswithoutthepriorwrittenconsentofApplemayconstitutetrademarkinfringementandunfaircompetitioninviolationoffederalandstatelaws.Nolicenses,expressorimplied,aregrantedwithrespecttoanyofthetechnologydescribedinthisdocument.Appleretainsallintellectualpropertyrightsassociatedwiththetechnologydescribedinthisdocument.ThisdocumentisintendedtoassistapplicationdeveloperstodevelopapplicationsonlyforApple-labeledcomputers.Everyefforthasbeenmadetoensurethattheinformationinthisdocumentisaccurate.Appleisnotresponsiblefortypographicalerrors.AppleInc.1InfiniteLoopCupertino,CA95014408-996-1010Apple,theApplelogo,Carbon,Cocoa,Mac,MacOS,Objective-C,QuickTime,Safari,andXcodearetrademarksofAppleInc.,registeredintheUnitedStatesandothercountries.WebScriptisatrademarkofAppleInc.JavaandallJava-basedtrademarksaretrademarksorregisteredtrademarksofSunMicrosystems,Inc.intheU.S.andothercountries.SimultaneouslypublishedintheUnitedStatesandCanada.EventhoughApplehasreviewedthisdocument,APPLEMAKESNOWARRANTYORREPRESENTATION,EITHEREXPRESSORIMPLIED,WITHRESPECTTOTHISDOCUMENT,ITSQUALITY,ACCURACY,MERCHANTABILITY,ORFITNESSFORAPARTICULARPURPOSE.ASARESULT,THISDOCUMENTISPROVIDED“ASIS,”ANDYOU,THEREADER,AREASSUMINGTHEENTIRERISKASTOITSQUALITYANDACCURACY.INNOEVENTWILLAPPLEBELIABLEFORDIRECT,INDIRECT,SPECIAL,INCIDENTAL,ORCONSEQUENTIALDAMAGESRESULTINGFROMANYDEFECTORINACCURACYINTHISDOCUMENT,evenifadvisedofthepossibilityofsuchdamages.THEWARRANTYANDREMEDIESSETFORTHABOVEAREEXCLUSIVEANDINLIEUOFALLOTHERS,ORALORWRITTEN,EXPRESSORIMPLIED.NoAppledealer,agent,oremployeeisauthorizedtomakeanymodification,extension,oradditiontothiswarranty.Somestatesdonotallowtheexclusionorlimitationofimpliedwarrantiesorliabilityforincidentalorconsequentialdamages,sotheabovelimitationorexclusionmaynotapplytoyou.Thiswarrantygivesyouspecificlegalrights,andyoumayalsohaveotherrightswhichvaryfromstatetostate.ContentsIntroductiontoWebKitPlug-inProgrammingTopics7WhoShouldReadThisDocument?7OrganizationofThisDocument7SeeAlso8AboutWebBrowserPlug-ins9Netscape-StylePlug-ins9WebKit–BasedPlug-ins9WhatKindOfPlug-inShouldIDevelop?10RegisteringYourPlug-in10InstallingYourPlug-in11DeployingYourPlug-in11CreatingPlug-inswithCocoaandWebKit13IntroductionToWebKitPlug-ins13BecomingAPlug-in13UsingPlug-inScripting14ImplementingaPlug-in15CreatingPlug-inswiththeNetscapeAPI19UsingPlug-inScripting19DocumentRevisionHistory2132008-10-15|©2005,2008AppleInc.AllRightsReserved.42008-10-15|©2005,2008AppleInc.AllRightsReserved.ListingsAboutWebBrowserPlug-ins9Listing1Plug-indescriptionintheInfo.plistfile10Listing2RegisteringMIMEtypesintheInfo.plistfile11Listing3NameThatPlug-in11Listing4EmbeddingamovieintoanHTMLpage11CreatingPlug-inswithCocoaandWebKit13Listing1PlugInMovieViewheader(PlugInMovieView.h)15Listing2Returningyourplug-in’sview15Listing3Initializingthemovieplug-in16Listing4LoadingandplayingamoviefromaURL16Listing5Stoppingthemovie16Listing6Openingtheplug-intoJavaScript1652008-10-15|©2005,2008AppleInc.AllRightsReserved.62008-10-15|©2005,2008AppleInc.AllRightsReserved.Webbrowserplug-insarecompiledbundlesthathelpextendthecontenttypessupportedbycommonwebbrowsers.Installedlocallyonacomputer,theycanruncodenativetotheuser’soperatingsystemandprovideapowerfulwaytoexpandonstandardwebcontent.WhoShouldReadThisDocument?Thisdocumentisdesignedforanumberofdifferentaudiences:■IfyouareaCocoaandWebKitdeveloper,youshouldreadabouttheWebKitplug-inarchitectureandlearnhowcompiledplug-insoperatewithinWebKit-basedapplications,includingSafari.■Ifyouareadeveloperwhoisconcernedwithcross-platformcompatibilityforyoursoftware,butwhoalsowantstodeployspecialcontentviaawebbrowser,youshouldreadabouttheNetscape-basedplug-inarchitectureandlearnhowitissupportedinavarietyofbrowsers.■Ifyouareawebcontentdeveloper,youshouldreadaboutbothplug-inarchitecturesandlearnhowtointegratetheirfeaturesintocustomplug-instosupportyourcontent.Note:Safarisupportsthelatestwebstandards,whichmayserveyourneedsmoreeasilythanaplug-in.Ifyouaredevelopingaplug-intoembedaudioorvideo,youcaninsteadtakeadvantageofSafari’ssupportfortheaudioandvideotagsinHTML5.Client-sidestorageisavailableinSafarithroughtheStorageandSQLAPIs,alsodefinedinHTML5.Ifyouaredevelopingarichuserinterface,SafarisupportsCSStransforms,transitions,andanimations.MoreinformationonSafariandCSScanbefoundinSafariCSSReference.OrganizationofThisDocumentThetopiccontainsthefollowingarticles:■“AboutWebBrowserPlug-ins”(page9)de