Mac Developer Library

Developer

WebKit Framework Reference WebPlugIn Protocol Reference

Options
Deployment Target:

On This Page
Language:

WebPlugIn

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import WebKit

Objective-C

@import WebKit;

Availability


Available in OS X v10.3.9 and later.

The WebPlugIn informal protocol defines methods that enable interaction between an application using the WebKit framework and any WebKit-based plug-ins it may use.

  • Returns an object that exposes the plug-in’s scripting interface.

    Declaration

    Swift

    var objectForWebScript: AnyObject! { get }

    Objective-C

    @property(nonatomic, readonly, strong) id objectForWebScript

    Return Value

    An object representing the plug-in’s scripting interface.

    Discussion

    The methods of the object are exposed to the script environment. Messages sent to the returned object will be invoked in the scripting environment. See the WebScripting Protocol Reference informal protocol for more details.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Controls plug-in behavior based on its selection.

    Declaration

    Swift

    func webPlugInSetIsSelected(_ isSelected: Bool)

    Objective-C

    - (void)webPlugInSetIsSelected:(BOOL)isSelected

    Parameters

    isSelected

    If YEStrue, the plug-in is currently selected. Otherwise, it is not selected.

    Discussion

    This may be used, for example, to change the plug-in’s appearance when it is selected by the user.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Prepares the plug-in for deallocation.

    Declaration

    Swift

    func webPlugInDestroy()

    Objective-C

    - (void)webPlugInDestroy

    Discussion

    Typically, this method frees the memory and other resources used by the plug-in. For example, if the plug-in had a copy of a WebPlugInContainer object, this method should relinquish ownership of that object. Do not send any other messages to the plug-in after invoking this method, because calling this method destroys the plug-in. No other methods in this interface may be called after the application has called this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Initializes the plug-in.

    Declaration

    Swift

    func webPlugInInitialize()

    Objective-C

    - (void)webPlugInInitialize

    Discussion

    Tells the plug-in to perform one-time initialization. This method must be called only once per instance of the plug-in object, before any other methods in the protocol are called.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Tells the plug-in to start normal operation.

    Declaration

    Swift

    func webPlugInStart()

    Objective-C

    - (void)webPlugInStart

    Discussion

    The plug-in usually begins its primary task (such as drawing, playing sounds, or animating) in this method. This method may be called more than once, provided that the application has already called webPlugInInitialize and that each call to this method is followed later by a call to webPlugInStop.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Tells the plug-in to stop normal operation.

    Declaration

    Swift

    func webPlugInStop()

    Objective-C

    - (void)webPlugInStop

    Discussion

    This method may be called more than once, provided that the application has already called webPlugInInitialize and that each call to this method is preceded by a call to webPlugInStart.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Invoked when an error occurs loading the main resource.

    Declaration

    Swift

    func webPlugInMainResourceDidFailWithError(_ error: NSError!)

    Objective-C

    - (void)webPlugInMainResourceDidFailWithError:(NSError *)error

    Parameters

    error

    An error object containing details of why the connection failed to load the request successfully.

    Discussion

    This message is invoked when the underlying NSURLConnection object for the main resource sends the connection:didFailWithError: message to its delegate.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.6 and later.

  • Invoked when the connection successfully finishes loading data.

    Declaration

    Swift

    func webPlugInMainResourceDidFinishLoading()

    Objective-C

    - (void)webPlugInMainResourceDidFinishLoading

    Discussion

    This message is invoked when the WebPlugInShouldLoadMainResourceKey plug-in command-line argument is set to NOfalse and the underlying NSURLConnection object for the main resource sends the connectionDidFinishLoading: message to its delegate.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.6 and later.

  • Invoked when the connection loads data incrementally.

    Declaration

    Swift

    func webPlugInMainResourceDidReceiveData(_ data: NSData!)

    Objective-C

    - (void)webPlugInMainResourceDidReceiveData:(NSData *)data

    Parameters

    data

    The newly available data.

    Discussion

    This message is invoked when the WebPlugInShouldLoadMainResourceKey plug-in command-line argument is set to NOfalse and the underlying NSURLConnection object for the main resource sends the connection:didReceiveData: message to its delegate.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.6 and later.

  • Invoked when the connection receives sufficient data to construct the URL response for its request.

    Declaration

    Swift

    func webPlugInMainResourceDidReceiveResponse(_ response: NSURLResponse!)

    Objective-C

    - (void)webPlugInMainResourceDidReceiveResponse:(NSURLResponse *)response

    Parameters

    response

    The URL response for the connection's request.

    Discussion

    This message is invoked when the WebPlugInShouldLoadMainResourceKey plug-in command-line argument is set to NOfalse and the underlying NSURLConnection object for the main resource sends the connection:didReceiveResponse: message to its delegate.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.6 and later.