|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mozilla.jrex.liveconnect.JRexLiveConnectSessionImpl
Implementation of JRexLiveConnectSession. JRexLiveConnectSessionImpl is public for accesibility from jni.
JRexLiveConnectSession
Constructor Summary | |
JRexLiveConnectSessionImpl()
Creates an instance of JRexLiveConnectSessionImpl. |
|
JRexLiveConnectSessionImpl(JRexCanvas browser)
Creates an instance of JRexLiveConnectSessionImpl and invokes setBrowser. |
|
JRexLiveConnectSessionImpl(JRexCanvas browser,
boolean useRootDocShell)
Creates an instance of JRexLiveConnectSessionImpl and invokes setBrowser. |
Method Summary | |
boolean |
equals(Object obj)
|
String |
evalUntrusted(String script)
Evaluates javascript in the browser. |
protected void |
finalize()
|
int |
getJRexPeerID()
|
netscape.javascript.JSObject |
getJSWindow()
Retrieves a JSObject implementation for the JRexCanvas window. |
int |
getSessionID()
|
void |
grantBrowserAccessToJVM()
Makes the LiveConnectSession a 2-way session. |
int |
hashCode()
|
String |
invokeStringMethod(String functionName,
String arg)
Invokes a javascript method which accepts a single string and returns a string. |
void |
setBrowser(JRexCanvas browser)
Sets the browser and intializes live connect for the browser. |
void |
setBrowser(JRexCanvas browser,
boolean useRootDocShell)
Sets the browser and intializes live connect for the browser. |
Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JRexLiveConnectSessionImpl()
setBrowser(org.mozilla.jrex.ui.JRexCanvas)
must be called before any javascript can be invoked.
public JRexLiveConnectSessionImpl(JRexCanvas browser) throws JRexException
browser
- the JRexCanvas used to access javascript
JRexException
- if an error occurs while initializing the javascript
bridge.public JRexLiveConnectSessionImpl(JRexCanvas browser, boolean useRootDocShell) throws JRexException
browser
- the JRexCanvas used to access javascriptuseRootDocShell
- whether or not to use the root doc shell, or the primary content doc shell
JRexException
- if an error occurs while initializing the javascript
bridge.Method Detail |
public int getSessionID()
public int getJRexPeerID()
public boolean equals(Object obj)
public int hashCode()
protected void finalize()
public void setBrowser(JRexCanvas browser) throws JRexException
JRexLiveConnectSession
setBrowser
in interface JRexLiveConnectSession
browser
- the JRexCanvas, which must already be initialized
JRexException
- if an error occurs while initializing live connectJRexLiveConnectSession.setBrowser(JRexCanvas, boolean)
public void setBrowser(JRexCanvas browser, boolean useRootDocShell) throws JRexException
JRexLiveConnectSession
setBrowser
in interface JRexLiveConnectSession
browser
- the JRexCanvas, which must already be initializeduseRootDocShell
- if true
, then the document's root nsIDocShell
is used. If false
, then the nsIDocShell for the primary content is used.
If using JRexLiveConnectSession on a XUL window, and you want to invoke javascript
on the XUL top-level window, this argument must be true
. Otherwise,
if you have an html document, or you only want to use JRexLiveConnectSession on the
primary content, set this argument to False
. Note that the primary content
in a XUL window is the browser or editor tagged with "content-primary".
JRexException
- if an error occurs while initializing live connectpublic void grantBrowserAccessToJVM() throws JRexException
JRexLiveConnectSession
JRexLiveConnectSession.getJSWindow()
. After this method is invoked, the javascript will be
able to create java objects and invoke methods on those objects, and the
caller will be able to use the method JRexLiveConnectSession.getJSWindow()
to retrieve the
JSObject instance for the javascript window.
Only call this method if the web page loaded into the JRexCanvas is trusted.
grantBrowserAccessToJVM
in interface JRexLiveConnectSession
JRexException
- if an error occurs while granting access to the JRex JVMpublic String invokeStringMethod(String functionName, String arg) throws JRexException
JRexLiveConnectSession
JRexLiveConnectSession.evalUntrusted(java.lang.String)
should
be used for untrusted javascript, and the JSObject class returned from
JRexLiveConnectSession.getJSWindow()
should be used for trusted javascript.
invokeStringMethod
in interface JRexLiveConnectSession
functionName
- the name of the javascript functionarg
- the argument to pass to the javascript function
JRexException
- if an error occurs while invoking the javascriptJRexLiveConnectSession.getJSWindow()
public String evalUntrusted(String script) throws JRexException
JRexLiveConnectSession
JRexLiveConnectSession.grantBrowserAccessToJVM()
followed by JRexLiveConnectSession.getJSWindow()
and invoke the
eval method on the JSObject instance. Only use this method if the javascript is not
trusted.
evalUntrusted
in interface JRexLiveConnectSession
script
- the javascript to evaluate
JRexException
- if an error occurs while evaulatingpublic netscape.javascript.JSObject getJSWindow() throws JRexException
JRexLiveConnectSession
Note that this method will throw a security violation exception unless the
method JRexLiveConnectSession.grantBrowserAccessToJVM()
is invoked before this method.
Make sure to invoke JRexLiveConnectSession.grantBrowserAccessToJVM()
before invoking this
method.
getJSWindow
in interface JRexLiveConnectSession
JRexException
- if an error prevents the JSObject from being createdJRexLiveConnectSession.grantBrowserAccessToJVM()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |