ESNetscapePluginView

Inherits fromNSView : NSResponder : NSObject
FrameworkFlashInApp.framework
Declared in ESNetscapePluginView.h
Companion guideFlash’In’App Programming Guide 
Required system version Mac OS X 10.4 and higher

 

Class description of ESNetscapePluginView


ESNetscapePluginView is an abstract class for working and displaying plugin, which works through NetscapePlugin API.

 

Class constants of ESNetscapePluginView


The following constants of StreamLoadType type are used to return external resources loading type:

StreamLoad_NoneDo not load data
StreamLoad_InternalAllow loading data by Flash’In’App itself
StreamLoad_External Allow loading data by delegate

 

The following constants of type TargetsValues are used to be passed to netscapeView:shouldLoadRequest:onTarget:

Target_NullLoads external resource into itself
Target_BlankLoads URL into the new window
Target_NewThe same as Target_Blank
Target_TopLoads URL into topmost window
Target_SelfLoads URL into the same window, where the URL was opened
Target_CurrentThe same as Target_Self
Target_ParentLoads URL into the parental window

 

Internal loading is processed by Target_Null only.
 

Tasks


Initializing Views

Configuring Views

Getting and Setting Delegates

Loading Content

Starting and stopping

Getting and setting attributes

Taking a snapshot

Background Drawing

 

Instance Methods


setBackgroundColor:

Sets the color of the background which is reflected when nothing is loaded.

– (void)setBackgroundColor:(NSColor *)aColor;

Parameters

aColor – the color used to draw the background

 

backgroundColor

Returns background color of the view.

– (NSColor *)backgroundColor;

Return Value

The background color of the view.

 

initWithFrame:pluginPackage:MIMEType:attributeKeys:attributeValues:loadManually:

Initializes and returns a newly allocated ESNetscapePluginView object with a specified frame.

– (id)initWithFrame:(NSRect)frame

pluginPackage: (ESNetscapePlugin *)thePluginPackage

MIMEType: (NSString *)MIME

attributeKeys: (NSArray *)keys

attributeValues: (NSArray *)values

loadManually: (BOOL)loadManually;

Discussion

 

You shouldn’t create the object of this type directly; use [ESFlashView initWithFrame:] instead.

 

isTransparent

Indicates whether the receiver is transparent.

– (BOOL)isTransparent;  

Return Value

YES when the receiver is transparent, NO otherwise.

 

setBackgroundImage:

This method is used to set the background image which is reflected when nothing is loaded.

 – (void) setBackgroundImage:(NSImage*)image;

Parameters

image – image to set as the receiver’s background color when nothing is loaded

 

backgroundImage

Identifies background image of the view, when nothing is loaded.

 – (NSImage *)backgroundImage;

Return Value

The background image of the view, when nothing is loaded.

 

setSendRightClick:

Specifies if the mouse right-click will be redirected to plugin.

 – (void) setSendRightClick:(BOOL)value;

Parameters

value – YES to specify that NetscapeView will redirect right mouse click to plugin, NO to permit redirection of right-click .

Discussion

I f you specify YES then plugin contextual menu will be displayed on right-click, if the plugin did not receive the right-click the menu will not be displayed. If you specify NO then you can set your own contextual menu with setMenu: (NSResponder)

 

sendRightClick

Returns a Boolean value that indicates whether the receiver redirects Right-button mouse click to plugin.

 – (BOOL) sendRightClick;

Return Value

YES when ESNetscapePluginView redirects click of Right-button mouse to plugin; otherwise, NO.

 

snapshot

This method gets the snapshot of the current frame.

– (NSImage *) snapshot;

Return Value

The snapshot of the current frame.

 

loadMovie:atUrl:withBaseURL:  

This method loads file into plugin.  

– (BOOL) loadMovie:(NSData *)movieData atURL:(NSURL *)movieURL withBaseURL:(NSURL *)movieBaseURL;  

Parameters

movieData – file contents

movieURL – URL to file

movieBaseURL – base URL to file (may be nil)  

Return Value

YES if the file was loaded successfully; otherwise, NO.

 

loadMovieAtPath:

This method loads file at aPath to plugin.

– (BOOL) loadMovieAtPath:(NSString *)aPath;

Return Value

YES if the file was loaded successfully; otherwise, NO.

 

snapshotFromRect:

Gets the snapshot of the current frame in the specified rectangle (crop frame).

– (NSImage *) snapshotFromRect:(NSRect)sourceRect;

Return Value

The object with the image of the current frame (in the receiver’s coordinates) will be returned.

 

start 

This method loads the plugin.

– (BOOL)start; 

Return Value

YES if loading is successful; otherwise, NO.

Discussion

This is done automatically with loadMovie:atURL:withBaseURL:

 

setDelegate:

Sets the receiver’s delegate to a given object or removes an existing delegate.

 – (void) setDelegate:(id)value;

Parameters

value – the delegate for the receiver. Pass nil to remove an existing delegate.

Discussion

An ESNetscapePluginView object’s delegate is informed of various actions by the plugin through delegation messages.

 

delegate

Returns the receiver’s delegate.  

– (id) delegate;

Return Value

The receiver’s delegate, or nil if it doesn’t have a delegate.

 

isStarted

Checks if plugin is running.

 – (BOOL)isStarted;

Return value

YES when the receiver is started, NO otherwise.

 

setBaseURL:

Sets the new base URL.

– (void)setBaseURL:(NSURL *)theBaseURL;

Parameters

theBaseURL – value for new base URL (may be nil)

Discussion

It’s the URL where resources will be searched for in case the movie loads them by relative paths; it’s the host URL which user accesses to see the movie, not the one it is physically located at.

 

baseURL

Returns current value of base URL. 

– (NSURL *) baseURL;

Return Value

The current value of base URL.

 

stop

The stop command stops and tries unloading plugin.

– (void)stop;

Discussion

By trying to unload the plugin we mean that in case there are several Netscape plugin views running that use the same plugin, it will be unloaded when all the views are stopped.

 

setSourceURL:

Sets the new URL to file (cannot be nil).

– (void)setSourceURL:(NSURL *)theSourceURL;

Parameters

theSourceURL – the source URL

 

sourceURL

Returns current value of URL to file.

– (NSURL *) sourceURL;

Return Value

The current value of URL to file.

 

Delegate Methods


userAgentStringForNetscapeView:

This message will be sent to delegate when plugin wants to receive UserAgent string from the host application.

– (NSString *)userAgentStringForNetscapeView:(ESNetscapePluginView *)netscapeView;

Parameters

netscapeView – the Netscape view that sent the message

Return Value

The object which will be sent to the plugin when plugin wants to receive UserAgent string from the host application.

Discussion

You shouldn’t use this method, unless you are sure what you are doing.

 

netscapeView:shouldLoadRequest:onTarget:

This message will be sent to delegate when NetscapeView is trying to load the data for ‘request’. If target is Target_Null – plugin wants to load data into itself, otherwise it’s an attempt to open a web-page.

 – (StreamLoadType) netscapeView:(ESNetscapePluginView *)netscapeView shouldLoadRequest:(NSURLRequest *)request onTarget:(TargetsValues)target;

Parameters

netscapeView – the Netscape view that sent the message

request – request object, which represents source

target – where URL should be opened

Return Value

Returns the value that defines how the ‘request’ should be loaded.
Discussion
To load external resources for a SWF file, delegate should implement netscapeView:shouldLoadRequest:onTarget: and return StreamLoad_Internal or StreamLoad_External.
 

netscapeView:loadStream:

This message will be sent to delegate for data loading to stream object.

– (void) netscapeView:(ESNetscapePluginView *)netscapeView loadStream:(ESNetscapePluginStream *)stream;

Parameters

netscapeView – the Netscape view that sent the message

stream – ESNetscapePluginStream, which data should be loaded in

Discussion

This message will be sent to delegate only if netscapeView:shouldLoadRequest:onTarget: returns StreamLoadType_External.

For instance, subsequence of calling by delegate may be the following:

[stream startStreamWithResponse:response] – when it receives a response for [stream requestURL]

[stream receivedData:data] – to pass the data into plugin (data type should be NSData).

[stream finishedLoadingWithData:nil] – when data loading is finished.

 

netscapeView:startLoadingRequest:

Informs the delegate that netscapeView starts loading request.

– (void) netscapeView:(ESNetscapePluginView *)netscapeView startLoadingRequest:(NSURLRequest *)request;

Parameters

netscapeView – the Netscape view that sent the message

request – request, which started loading

Discussion

This message will be sent to delegate only if netscapeView:shouldLoadRequest:onTarget: returns StreamLoadType_Internal.

 

netscapeView:finishLoadingRequest:

This method is called during the end of resource loading.

 – (void) netscapeView:(ESNetscapePluginView *)netscapeView finishLoadingRequest:(NSURLRequest *)request;

Parameters

netscapeView – the Netscape view that sent the message

request – request, which finished loading

Discussion

This message will be sent to delegate only if netscapeView:shouldLoadRequest:onTarget: returns StreamLoadType_Internal.

 

netscapeView:failLoadingRequest:withError:  

This method is called during the error of resource loading.  

– (void) netscapeView:(ESNetscapePluginView *)netscapeView failLoadingRequest:(NSURLRequest *)request withError:(NSError *)error;

Parameters

netscapeView – the Netscape view that sent the message
request – request, for which error was received

error – an error object containing details of request loading failure

Discussion

This message will be sent to delegate only if netscapeView:shouldLoadRequest:onTarget: returns StreamLoadType_Internal.

 

netscapeView:didReceiveData:forRequest:

This method is called during internal resources loading when data packet is received for request.

 – (void) netscapeView:(ESNetscapePluginView *)netscapeView didReceiveData:(NSData *)aData forRequest:(NSURLRequest *)request

Parameters

netscapeView – the Netscape view that sent the message

aData – data packet received

request – request, the data was received for

Discussion

This message will be sent to delegate only if netscapeView:shouldLoadRequest:onTarget: returns StreamLoadType_Internal.