The churn continues. After this checkin, BrowserControlFactoryTest
runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content. git-svn-id: svn://10.0.0.236/trunk@154953 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -34,7 +34,9 @@ import java.io.FileNotFoundException;
|
||||
* the factory for per-window {@link BrowserControl} instances. This
|
||||
* interface allows a pluggable webclient API implementation. The
|
||||
* static methods in {@link BrowserControlFactory} call through to
|
||||
* methods on this interface.</p>
|
||||
* methods on this interface. The implementation of this interface must
|
||||
* be a singleton and its the lifetime must be the same as the
|
||||
* application.</p>
|
||||
*/
|
||||
|
||||
public interface WebclientFactory {
|
||||
|
||||
@@ -92,16 +92,13 @@ private static ProfileManager profileManager = null;
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public BrowserControlImpl(WrapperFactory yourWrapper)
|
||||
{
|
||||
public BrowserControlImpl(WrapperFactory yourWrapper) {
|
||||
super();
|
||||
ParameterCheck.nonNull(yourWrapper);
|
||||
|
||||
|
||||
wrapperFactory = yourWrapper;
|
||||
Assert.assert_it(-1 != wrapperFactory.getNativeContext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Called from BrowserControlFactory.deleteBrowserControl() <P>
|
||||
@@ -115,8 +112,6 @@ public BrowserControlImpl(WrapperFactory yourWrapper)
|
||||
void delete()
|
||||
{
|
||||
|
||||
wrapperFactory.destroyNativeBrowserControl(this);
|
||||
|
||||
if (null != myCanvas) {
|
||||
// Make sure we're not showing.
|
||||
if (myCanvas.isShowing()) {
|
||||
|
||||
@@ -64,9 +64,6 @@ private String platformCanvasClassName = null;
|
||||
|
||||
protected WrapperFactory wrapperFactory = null;
|
||||
|
||||
protected int browserControlCount = 0;
|
||||
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
@@ -137,20 +134,13 @@ public void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotF
|
||||
|
||||
public void appTerminate() throws Exception
|
||||
{
|
||||
if (0 == browserControlCount) {
|
||||
getWrapperFactory().terminate();
|
||||
}
|
||||
getWrapperFactory().terminate();
|
||||
}
|
||||
|
||||
public BrowserControl newBrowserControl() throws InstantiationException, IllegalAccessException, IllegalStateException
|
||||
{
|
||||
getWrapperFactory().verifyInitialized();
|
||||
browserControlCount++;
|
||||
|
||||
BrowserControl result = null;
|
||||
result = new BrowserControlImpl(getWrapperFactory());
|
||||
|
||||
return result;
|
||||
return getWrapperFactory().newBrowserControl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,8 +159,8 @@ public BrowserControl newBrowserControl() throws InstantiationException, Illegal
|
||||
public void deleteBrowserControl(BrowserControl toDelete)
|
||||
{
|
||||
ParameterCheck.nonNull(toDelete);
|
||||
getWrapperFactory().deleteBrowserControl(toDelete);
|
||||
((BrowserControlImpl)toDelete).delete();
|
||||
browserControlCount--;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -28,9 +28,22 @@ package org.mozilla.webclient.impl;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
|
||||
/**
|
||||
* <p>Defines the interface for the real implementation of the Webclient
|
||||
* API. The implementation of this interface must be a singleton and
|
||||
* must have the same lifetime as {@link WebclientFactory}.</p>
|
||||
*
|
||||
* <p>This interface is intended to be the anchor for all
|
||||
* per-application state.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public interface WrapperFactory {
|
||||
|
||||
public static String IMPL_NAME = "WrapperFactoryImpl";
|
||||
|
||||
public BrowserControl newBrowserControl() throws InstantiationException, IllegalAccessException, IllegalStateException;
|
||||
public void deleteBrowserControl(BrowserControl toDelete);
|
||||
|
||||
public Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException;
|
||||
@@ -52,9 +65,9 @@ public interface WrapperFactory {
|
||||
public void verifyInitialized() throws IllegalStateException;
|
||||
|
||||
public void terminate() throws Exception;
|
||||
|
||||
public int getNativeContext();
|
||||
|
||||
public int getNativeWrapperFactory();
|
||||
|
||||
/**
|
||||
* <p>I would like this method to be on BrowserControl itself, but
|
||||
* that would mean exposing native elements on the public java API.
|
||||
@@ -65,20 +78,5 @@ public interface WrapperFactory {
|
||||
|
||||
public int getNativeBrowserControl(BrowserControl bc);
|
||||
|
||||
/**
|
||||
* <p>I would like this method to be on BrowserControl itself, but
|
||||
* that would mean exposing implementation specific elements on the
|
||||
* public java API. Therefore, the WrapperFactory needs to be able
|
||||
* to return the NativeEventThread given a java BrowserControl.</p>
|
||||
*
|
||||
*/
|
||||
public Object getNativeEventThread(BrowserControl bc);
|
||||
|
||||
/***
|
||||
* <p>Also destroys the NativeEventThread.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public void destroyNativeBrowserControl(BrowserControl bc);
|
||||
|
||||
public Object getNativeEventThread();
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ public BookmarksImpl(WrapperFactory yourFactory)
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext());
|
||||
nativeStartup(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
nativeShutdown(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,11 +156,11 @@ public TreeModel getBookmarks() throws IllegalStateException
|
||||
TreeNode root;
|
||||
if (-1 ==
|
||||
(nativeBookmarks =
|
||||
nativeGetBookmarks(getWrapperFactory().getNativeContext()))) {
|
||||
nativeGetBookmarks(getWrapperFactory().getNativeWrapperFactory()))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't get bookmarks from native browser.");
|
||||
}
|
||||
// if we can't create a root, or we can't create a tree
|
||||
if ((null == (root = new BookmarkEntryImpl(getWrapperFactory().getNativeContext(),
|
||||
if ((null == (root = new BookmarkEntryImpl(getWrapperFactory().getNativeWrapperFactory(),
|
||||
nativeBookmarks, null))) ||
|
||||
(null == (bookmarksTree = new DefaultTreeModel(root)))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't create RDFTreeModel.");
|
||||
|
||||
@@ -63,6 +63,12 @@ public class EventRegistrationImpl extends ImplObjectNative implements EventRegi
|
||||
|
||||
*/
|
||||
|
||||
// PENDING: Currently we rely on NativeEventThread logic to maintain the
|
||||
// list of listeners to add and to add them in a threadsafe manner. In
|
||||
// webclient 2.0, we're going to maintain the list of listeners ourself,
|
||||
// in this class, and use the Runnable trick to make sure they get added
|
||||
// on the right thread.
|
||||
|
||||
private NativeEventThread nativeEventThread = null;
|
||||
|
||||
//
|
||||
@@ -121,7 +127,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +147,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +180,7 @@ public void addMouseListener(MouseListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +208,7 @@ public void removeMouseListener(MouseListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +228,7 @@ public void addNewWindowListener(NewWindowListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +248,7 @@ public void removeNewWindowListener(NewWindowListener listener)
|
||||
}
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
// PENDING nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +265,7 @@ public static void main(String [] args)
|
||||
|
||||
Log.setApplicationName("EventRegistrationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.3 2004-04-10 21:50:38 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.4 2004-04-15 22:58:06 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
||||
@@ -101,7 +101,7 @@ protected int getNativeBrowserControl() {
|
||||
|
||||
protected NativeEventThread getNativeEventThread() {
|
||||
return (NativeEventThread)
|
||||
getWrapperFactory().getNativeEventThread(getBrowserControl());
|
||||
getWrapperFactory().getNativeEventThread();
|
||||
}
|
||||
|
||||
} // end of class ImplObject
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@@ -32,7 +31,8 @@ import org.mozilla.util.ParameterCheck;
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.mozilla.webclient.BrowserControlCanvas;
|
||||
import org.mozilla.webclient.DocumentLoadEvent;
|
||||
import org.mozilla.webclient.DocumentLoadListener;
|
||||
@@ -43,124 +43,102 @@ import org.mozilla.webclient.WebclientEvent;
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
public class NativeEventThread extends Thread
|
||||
{
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
|
||||
//
|
||||
// Class variables
|
||||
//
|
||||
public class NativeEventThread extends Thread {
|
||||
|
||||
private static Object firstThread = null;
|
||||
//
|
||||
// Class variables
|
||||
//
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
/**
|
||||
* store the exception property, set when running a Runnable causes
|
||||
* an exception.
|
||||
*/
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Relationship ivars
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to add.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToAdd;
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to remove.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToRemove;
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained in constructor
|
||||
|
||||
*/
|
||||
|
||||
private int nativeBrowserControl = -1;
|
||||
|
||||
private BrowserControl browserControl;
|
||||
|
||||
private BrowserControlCanvas browserControlCanvas;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Used in run()
|
||||
|
||||
*/
|
||||
|
||||
private Enumeration tempEnum;
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public NativeEventThread(String threadName, int yourNativeWebShell,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(threadName);
|
||||
ParameterCheck.nonNull(yourBrowserControl);
|
||||
|
||||
if (null == firstThread) {
|
||||
firstThread = this;
|
||||
private Exception exception;
|
||||
|
||||
//
|
||||
// Relationship ivars
|
||||
//
|
||||
|
||||
private WrapperFactory wrapperFactory;
|
||||
private int nativeWrapperFactory;
|
||||
|
||||
private BrowserControlCanvas browserControlCanvas;
|
||||
|
||||
private Stack runnablesWithNotify;
|
||||
private Stack runnables;
|
||||
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public NativeEventThread(String threadName,
|
||||
WrapperFactory yourFactory,
|
||||
int yourNativeWrapperFactory) {
|
||||
super(threadName);
|
||||
ParameterCheck.nonNull(yourFactory);
|
||||
|
||||
wrapperFactory = yourFactory;
|
||||
nativeWrapperFactory = yourNativeWrapperFactory;
|
||||
|
||||
runnablesWithNotify = new Stack();
|
||||
runnables = new Stack();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is a very delicate method, and possibly subject to race
|
||||
* condition problems. To combat this, our first step is to set our
|
||||
* wrapperFactory to null, within a synchronized block which
|
||||
* synchronizes on the same object used in the run() method's event
|
||||
* loop. By setting the wrapperFactory ivar to null, we cause
|
||||
* the run method to return.
|
||||
*/
|
||||
|
||||
public void delete() {
|
||||
synchronized(this) {
|
||||
// this has to be inside the synchronized block!
|
||||
wrapperFactory = null;
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.delete: interrupted while waiting\n\t for NativeEventThread to notify() after destruction of initContext: " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
wrapperFactory = null;
|
||||
}
|
||||
|
||||
browserControl = yourBrowserControl;
|
||||
|
||||
nativeBrowserControl = yourNativeWebShell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This is a very delicate method, and possibly subject to race
|
||||
* condition problems. To combat this, our first step is to set our
|
||||
* browserControl to null, within a synchronized block which
|
||||
* synchronizes on the same object used in the run() method's event
|
||||
* loop. By setting the browserControlCanvas ivar to null, we cause the
|
||||
* run method to return.
|
||||
|
||||
*/
|
||||
|
||||
public void delete()
|
||||
{
|
||||
// setting this to null causes the run thread to exit
|
||||
synchronized(this) {
|
||||
// this has to be inside the synchronized block!
|
||||
browserControl = null;
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.delete: interrupted while waiting\n\t for NativeEventThread to notify() after destruction of initContext: " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
public Exception getAndClearException() {
|
||||
synchronized (this) {
|
||||
Exception result = exception;
|
||||
exception = null;
|
||||
}
|
||||
return exception;
|
||||
}
|
||||
// PENDING(ashuk): do any necessary cleanup.
|
||||
listenersToAdd = null;
|
||||
doRemoveListeners();
|
||||
listenersToRemove = null;
|
||||
nativeBrowserControl = -1;
|
||||
browserControl = null;
|
||||
tempEnum = null;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Thread
|
||||
//
|
||||
|
||||
public void setException(Exception e) {
|
||||
synchronized (this) {
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Thread
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* This method is the heart of webclient. It is called from
|
||||
@@ -171,8 +149,6 @@ public void delete()
|
||||
* checks to see if there are any listeners to add, and adds them if
|
||||
* necessary.
|
||||
|
||||
* @see nativeStartup
|
||||
|
||||
* @see nativeProcessEvents
|
||||
|
||||
* @see nativeAddListener
|
||||
@@ -181,22 +157,13 @@ public void delete()
|
||||
|
||||
public void run()
|
||||
{
|
||||
// this.setPriority(Thread.MIN_PRIORITY);
|
||||
Assert.assert_it(-1 != nativeBrowserControl);
|
||||
|
||||
nativeStartup(nativeBrowserControl);
|
||||
|
||||
// IMPORTANT: tell the browserControl, who is waiting for this
|
||||
// message, that we have initialized successfully.
|
||||
synchronized(browserControl) {
|
||||
try {
|
||||
browserControl.notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run: Exception: trying to send notify() to browserControl: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// our owner must have put an event in the queue
|
||||
Assert.assert_it(!runnablesWithNotify.empty());
|
||||
|
||||
//
|
||||
// Execute the event-loop.
|
||||
//
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
@@ -206,11 +173,9 @@ public void run()
|
||||
" while sleeping: " + e.getMessage());
|
||||
}
|
||||
synchronized (this) {
|
||||
|
||||
// this has to be inside the synchronized block!
|
||||
if (null == this.browserControl) {
|
||||
// if we are have been told to delete ourselves
|
||||
if (null == this.wrapperFactory) {
|
||||
try {
|
||||
nativeShutdown(nativeBrowserControl);
|
||||
notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -218,26 +183,22 @@ public void run()
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this == firstThread) {
|
||||
nativeProcessEvents(nativeBrowserControl);
|
||||
}
|
||||
|
||||
if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
|
||||
tempEnum = listenersToAdd.elements();
|
||||
|
||||
while (tempEnum.hasMoreElements()) {
|
||||
WCEventListenerWrapper tempListener =
|
||||
(WCEventListenerWrapper) tempEnum.nextElement();
|
||||
nativeAddListener(nativeBrowserControl,tempListener.listener,
|
||||
tempListener.listenerClassName);
|
||||
}
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.removeAllElements();
|
||||
}
|
||||
doRemoveListeners();
|
||||
|
||||
|
||||
if (!runnables.empty()) {
|
||||
((Runnable)runnables.pop()).run();
|
||||
}
|
||||
if (!runnablesWithNotify.empty()) {
|
||||
((Runnable)runnablesWithNotify.pop()).run();
|
||||
synchronized(wrapperFactory) {
|
||||
try {
|
||||
wrapperFactory.notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run: Exception: trying to send notify() to wrapperFactory: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
nativeProcessEvents(nativeWrapperFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,113 +207,22 @@ public void run()
|
||||
// private methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* this was broken out into a separate method due to the complexity of
|
||||
* handling the case where we are to remove all listeners.
|
||||
|
||||
*/
|
||||
|
||||
private void doRemoveListeners()
|
||||
{
|
||||
if (null != listenersToRemove && !listenersToRemove.isEmpty()) {
|
||||
tempEnum = listenersToRemove.elements();
|
||||
while (tempEnum.hasMoreElements()) {
|
||||
Object listenerObj = tempEnum.nextElement();
|
||||
String listenerString;
|
||||
if (listenerObj instanceof String) {
|
||||
listenerString = (String) listenerObj;
|
||||
if (listenerString.equals("all")) {
|
||||
nativeRemoveAllListeners(nativeBrowserControl);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new UnimplementedException("Webclient doesn't understand how to remove " + ((String)listenerObj) + ".");
|
||||
}
|
||||
}
|
||||
else {
|
||||
WCEventListenerWrapper tempListener =
|
||||
(WCEventListenerWrapper) listenerObj;
|
||||
nativeRemoveListener(nativeBrowserControl,
|
||||
tempListener.listener,
|
||||
tempListener.listenerClassName);
|
||||
|
||||
}
|
||||
}
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.removeAllElements();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Package methods
|
||||
//
|
||||
|
||||
int getNativeBrowserControl() {
|
||||
return nativeBrowserControl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* Takes the abstract WebclientEventListener instance and adds it to a
|
||||
* Vector of listeners to be added. This vector is scanned each time
|
||||
* around the event loop in run(). <P>
|
||||
|
||||
* The vector is a vector of WCEventListenerWrapper instances. In run()
|
||||
* these are unpacked and sent to nativeAddListener like this:
|
||||
* nativeAddListener(nativeBrowserControl,tempListener.listener,
|
||||
* tempListener.listenerClassName); <P>
|
||||
|
||||
* @see run
|
||||
|
||||
*/
|
||||
|
||||
void addListener(WCEventListenerWrapper newListener)
|
||||
{
|
||||
Assert.assert_it(-1 != nativeBrowserControl);
|
||||
|
||||
synchronized (this) {
|
||||
if (null == listenersToAdd) {
|
||||
listenersToAdd = new Vector();
|
||||
}
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.addElement(newListener);
|
||||
void pushRunnable(Runnable toInvoke) {
|
||||
synchronized (this) {
|
||||
runnables.push(toInvoke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* remove a listener
|
||||
|
||||
* @param newListener if null, removes all listeners
|
||||
|
||||
*/
|
||||
|
||||
void removeListener(WCEventListenerWrapper newListener)
|
||||
{
|
||||
Assert.assert_it(-1 != nativeBrowserControl);
|
||||
|
||||
synchronized (this) {
|
||||
if (null == listenersToRemove) {
|
||||
listenersToRemove = new Vector();
|
||||
}
|
||||
if (null == newListener) {
|
||||
String all = "all";
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(all);
|
||||
}
|
||||
else {
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(newListener);
|
||||
}
|
||||
|
||||
void pushNotifyRunnable(Runnable toInvoke) {
|
||||
synchronized (this) {
|
||||
runnablesWithNotify.push(toInvoke);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This method is called from native code when an event occurrs. This
|
||||
@@ -369,7 +239,7 @@ void nativeEventOccurred(WebclientEventListener target,
|
||||
ParameterCheck.nonNull(target);
|
||||
ParameterCheck.nonNull(targetClassName);
|
||||
|
||||
Assert.assert_it(-1 != nativeBrowserControl);
|
||||
Assert.assert_it(-1 != nativeWrapperFactory);
|
||||
|
||||
WebclientEvent event = null;
|
||||
|
||||
@@ -398,43 +268,10 @@ void nativeEventOccurred(WebclientEventListener target,
|
||||
target.eventDispatched(event);
|
||||
}
|
||||
|
||||
//
|
||||
// local methods
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Takes the int from ImplObjectNative.getNativeBrowserControl, the
|
||||
* meaning of which is left up to the implementation, and does any
|
||||
* per-window creation and initialization tasks. <P>
|
||||
|
||||
* For mozilla, this means creating the nsIWebShell instance, attaching
|
||||
* to the native event queue, creating the nsISessionHistory instance, etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeStartup(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Takes the int from ImplObjectNative.getNativeBrowserControl, the
|
||||
* meaning of which is left up to the implementation, and does any
|
||||
* per-window creation and initialization tasks. <P>
|
||||
|
||||
* For mozilla, this means creating the nsIWebShell instance, attaching
|
||||
* to the native event queue, creating the nsISessionHistory instance, etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeShutdown(int webShellPtr);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -446,40 +283,4 @@ public native void nativeShutdown(int webShellPtr);
|
||||
|
||||
public native void nativeProcessEvents(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to add a "listener" to the
|
||||
* underlying browser implementation. The native code should do what's
|
||||
* necessary to add the appropriate listener type. When a listener
|
||||
* event occurrs, the native code should call the nativeEventOccurred
|
||||
* method of this instance, passing the typedListener argument received
|
||||
* from nativeAddListener. See the comments in the native
|
||||
* implementation.
|
||||
|
||||
* @see nativeEventOccurred
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeAddListener(int webShellPtr,
|
||||
WebclientEventListener typedListener,
|
||||
String listenerName);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to remove a listener.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeRemoveListener(int webShellPtr,
|
||||
WebclientEventListener typedListener,
|
||||
String listenerName);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to remove all listeners.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeRemoveAllListeners(int webShellPrt);
|
||||
|
||||
} // end of class NativeEventThread
|
||||
|
||||
@@ -82,11 +82,16 @@ public void loadURL(String absoluteURL)
|
||||
{
|
||||
ParameterCheck.nonNull(absoluteURL);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeBrowserControl());
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeLoadURL(getNativeBrowserControl(), absoluteURL);
|
||||
}
|
||||
final int bc = getNativeBrowserControl();
|
||||
final String url = new String(absoluteURL);
|
||||
Assert.assert_it(-1 != bc);
|
||||
|
||||
Runnable loadURL = new Runnable() {
|
||||
public void run() {
|
||||
NavigationImpl.this.nativeLoadURL(bc, url);
|
||||
}
|
||||
};
|
||||
getNativeEventThread().pushRunnable(loadURL);
|
||||
}
|
||||
|
||||
public void loadFromStream(InputStream stream, String uri,
|
||||
@@ -223,7 +228,7 @@ public static void main(String [] args)
|
||||
|
||||
Log.setApplicationName("NavigationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.3 2004-04-10 21:50:38 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.4 2004-04-15 22:58:06 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
||||
@@ -67,11 +67,11 @@ public PreferencesImpl(WrapperFactory yourFactory)
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext());
|
||||
nativeStartup(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
nativeShutdown(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,26 +109,26 @@ public void setPref(String prefName, String prefValue)
|
||||
// determine the type of pref value: String, boolean, integer
|
||||
try {
|
||||
Integer intVal = Integer.valueOf(prefValue);
|
||||
nativeSetIntPref(getWrapperFactory().getNativeContext(), prefName, intVal.intValue());
|
||||
nativeSetIntPref(getWrapperFactory().getNativeWrapperFactory(), prefName, intVal.intValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// it's not an integer
|
||||
if (null != prefValue &&
|
||||
(prefValue.equals("true") || prefValue.equals("false"))) {
|
||||
Boolean boolVal = Boolean.valueOf(prefValue);
|
||||
nativeSetBoolPref(getWrapperFactory().getNativeContext(), prefName,
|
||||
nativeSetBoolPref(getWrapperFactory().getNativeWrapperFactory(), prefName,
|
||||
boolVal.booleanValue());
|
||||
}
|
||||
else {
|
||||
// it must be a string
|
||||
nativeSetUnicharPref(getWrapperFactory().getNativeContext(), prefName, prefValue);
|
||||
nativeSetUnicharPref(getWrapperFactory().getNativeWrapperFactory(), prefName, prefValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Properties getPrefs()
|
||||
{
|
||||
props = nativeGetPrefs(getWrapperFactory().getNativeContext(), props);
|
||||
props = nativeGetPrefs(getWrapperFactory().getNativeWrapperFactory(), props);
|
||||
//Properties result = new Properties();
|
||||
// result.put("webclientpref", "webclient_value");
|
||||
|
||||
@@ -141,7 +141,7 @@ public void registerPrefChangedCallback(PrefChangedCallback cb,
|
||||
ParameterCheck.nonNull(cb);
|
||||
ParameterCheck.nonNull(prefName);
|
||||
|
||||
nativeRegisterPrefChangedCallback(getWrapperFactory().getNativeContext(), cb, prefName, closure);
|
||||
nativeRegisterPrefChangedCallback(getWrapperFactory().getNativeWrapperFactory(), cb, prefName, closure);
|
||||
}
|
||||
|
||||
public void unregisterPrefChangedCallback(PrefChangedCallback cb,
|
||||
@@ -150,7 +150,7 @@ public void unregisterPrefChangedCallback(PrefChangedCallback cb,
|
||||
ParameterCheck.nonNull(cb);
|
||||
ParameterCheck.nonNull(prefName);
|
||||
|
||||
nativeUnregisterPrefChangedCallback(getWrapperFactory().getNativeContext(), cb, prefName, closure);
|
||||
nativeUnregisterPrefChangedCallback(getWrapperFactory().getNativeWrapperFactory(), cb, prefName, closure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,29 +46,29 @@ public ProfileManagerImpl(WrapperFactory yourFactory)
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext(), null, null);
|
||||
nativeStartup(getWrapperFactory().getNativeWrapperFactory(), null, null);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
nativeShutdown(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
public int getProfileCount()
|
||||
{
|
||||
return nativeGetProfileCount(getWrapperFactory().getNativeContext());
|
||||
return nativeGetProfileCount(getWrapperFactory().getNativeWrapperFactory());
|
||||
}
|
||||
|
||||
public String [] getProfileList()
|
||||
{
|
||||
String [] list = null;
|
||||
list = nativeGetProfileList(getWrapperFactory().getNativeContext());
|
||||
list = nativeGetProfileList(getWrapperFactory().getNativeWrapperFactory());
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean profileExists(String profileName)
|
||||
{
|
||||
boolean exists = false;
|
||||
exists = nativeProfileExists(getWrapperFactory().getNativeContext(),
|
||||
exists = nativeProfileExists(getWrapperFactory().getNativeWrapperFactory(),
|
||||
profileName);
|
||||
return exists;
|
||||
}
|
||||
@@ -77,13 +77,13 @@ public String getCurrentProfile()
|
||||
{
|
||||
String currProfile = null;
|
||||
currProfile =
|
||||
nativeGetCurrentProfile(getWrapperFactory().getNativeContext());
|
||||
nativeGetCurrentProfile(getWrapperFactory().getNativeWrapperFactory());
|
||||
return currProfile;
|
||||
}
|
||||
|
||||
public void setCurrentProfile(String profileName)
|
||||
{
|
||||
nativeSetCurrentProfile(getWrapperFactory().getNativeContext(),
|
||||
nativeSetCurrentProfile(getWrapperFactory().getNativeWrapperFactory(),
|
||||
profileName);
|
||||
}
|
||||
|
||||
@@ -92,20 +92,20 @@ public void createNewProfile(String profileName,
|
||||
String langcode,
|
||||
boolean useExistingDir)
|
||||
{
|
||||
nativeCreateNewProfile(getWrapperFactory().getNativeContext(),
|
||||
nativeCreateNewProfile(getWrapperFactory().getNativeWrapperFactory(),
|
||||
profileName, nativeProfileDir, langcode,
|
||||
useExistingDir);
|
||||
}
|
||||
|
||||
public void renameProfile(String currName, String newName)
|
||||
{
|
||||
nativeRenameProfile(getWrapperFactory().getNativeContext(),
|
||||
nativeRenameProfile(getWrapperFactory().getNativeWrapperFactory(),
|
||||
currName, newName);
|
||||
}
|
||||
|
||||
public void deleteProfile(String profileName, boolean canDeleteFiles)
|
||||
{
|
||||
nativeDeleteProfile(getWrapperFactory().getNativeContext(),
|
||||
nativeDeleteProfile(getWrapperFactory().getNativeWrapperFactory(),
|
||||
profileName, canDeleteFiles);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@@ -36,296 +35,388 @@ import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WrapperFactoryImpl extends Object implements WrapperFactory
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
protected String platformCanvasClassName = null;
|
||||
protected boolean initialized = false;
|
||||
protected int nativeContext = -1;
|
||||
/**
|
||||
* <p>keys: BrowserControl instances</p>
|
||||
*
|
||||
* <p>values: NativeEventThread instances that correspond to this
|
||||
* window.</p>
|
||||
*
|
||||
*/
|
||||
protected Map nativeEventThreads = null;
|
||||
|
||||
// Relationship Instance Variables
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
* <p>This class is the hub of the startup and shutdown sequence for
|
||||
* Webclient. It is a singleton and owns references to other app
|
||||
* singletons:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><p>{@link NativeEventThread}</p></li>
|
||||
*
|
||||
* <li><p>{@link Bookmarks}</p></li>
|
||||
*
|
||||
* <li><p>{@link Preferences}</p></li>
|
||||
*
|
||||
* <li><p>{@link ProfileManager}</p></li>
|
||||
|
||||
* <li><p>the native object singleton corresponding to this java
|
||||
* object (if necessary)</p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* <p>It maintains a set of {@link BrowserControlImpl} instances so that
|
||||
* we may return the native pointer for each one.</p>
|
||||
*
|
||||
* <p>This class is responsible for creating and initializing and
|
||||
* deleting {@link BrowserControlImpl} instances, as well as ensuring
|
||||
* that the native counterpart is proprely maintained in kind.</p>
|
||||
*
|
||||
* <p>This class has a tight contract with {@link
|
||||
* NativeEventThread}.</p>
|
||||
*/
|
||||
|
||||
protected Bookmarks bookmarks = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
protected Preferences prefs = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
|
||||
protected ProfileManager profileManager = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WrapperFactoryImpl()
|
||||
{
|
||||
super();
|
||||
nativeEventThreads = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from webclient.WrapperFactory
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* @param interfaceName IMPORTANT!!!! This method assumes that
|
||||
* interfaceName is one of the actual strings from the interface
|
||||
* definition for BrowserControl. That is, this method is only called
|
||||
* from BrowserControlImpl, and is only invoked like this
|
||||
|
||||
<CODE><PRE>
|
||||
|
||||
// BrowserControlImpl code...
|
||||
|
||||
if (WINDOW_CONTROL_NAME.equals(interfaceName)) {
|
||||
if (null == windowControl) {
|
||||
windowControl =
|
||||
(WindowControl) wrapperFactory.newImpl(WINDOW_CONTROL_NAME,
|
||||
this);
|
||||
}
|
||||
return windowControl;
|
||||
}
|
||||
|
||||
</PRE></CODE>
|
||||
|
||||
* <P>
|
||||
* This is done to avoid a costly string compare. This shortcut is
|
||||
* justified since WrapperFactoryImpl is only called from
|
||||
* BrowserControlImpl <B>and</B> the only values for interfaceName that
|
||||
* make sense are those defined in BrowserControl class variables ending
|
||||
* with _NAME.
|
||||
* </P>
|
||||
|
||||
* @see org.mozilla.webclient.BrowserControl.BROWSER_CONTROL_CANVAS_NAME
|
||||
|
||||
*/
|
||||
|
||||
public Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException
|
||||
{
|
||||
Object result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (!nativeDoesImplement(interfaceName)) {
|
||||
throw new ClassNotFoundException("Can't instantiate " +
|
||||
interfaceName +
|
||||
": not implemented.");
|
||||
}
|
||||
if (BrowserControl.WINDOW_CONTROL_NAME == interfaceName) {
|
||||
result = new WindowControlImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.NAVIGATION_NAME == interfaceName) {
|
||||
result = new NavigationImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.HISTORY_NAME == interfaceName) {
|
||||
result = new HistoryImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.CURRENT_PAGE_NAME == interfaceName) {
|
||||
result = new CurrentPageImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.EVENT_REGISTRATION_NAME == interfaceName) {
|
||||
result = new EventRegistrationImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
|
||||
Assert.assert_it(null != bookmarks);
|
||||
result = bookmarks;
|
||||
}
|
||||
if (BrowserControl.PREFERENCES_NAME == interfaceName) {
|
||||
Assert.assert_it(null != prefs);
|
||||
result = prefs;
|
||||
}
|
||||
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
|
||||
Assert.assert_it(null != profileManager);
|
||||
result = profileManager;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError
|
||||
{
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.loadLibrary("webclient");
|
||||
|
||||
try {
|
||||
nativeContext = nativeAppInitialize(verifiedBinDirAbsolutePath);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
Assert.assert_it(-1 != nativeContext);
|
||||
|
||||
public class WrapperFactoryImpl extends Object implements WrapperFactory {
|
||||
//
|
||||
// create app singletons
|
||||
// Protected Constants
|
||||
//
|
||||
profileManager = new ProfileManagerImpl(this);
|
||||
Assert.assert_it(null != profileManager);
|
||||
((Service)profileManager).startup();
|
||||
|
||||
prefs = new PreferencesImpl(this);
|
||||
Assert.assert_it(null != prefs);
|
||||
((Service)prefs).startup();
|
||||
|
||||
bookmarks = new BookmarksImpl(this);
|
||||
Assert.assert_it(null != bookmarks);
|
||||
((Service)bookmarks).startup();
|
||||
|
||||
try {
|
||||
nativeAppSetup(nativeContext);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
protected String platformCanvasClassName = null;
|
||||
protected boolean initialized = false;
|
||||
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
private NativeEventThread eventThread = null; // OWNER
|
||||
private int nativeWrapperFactory;
|
||||
|
||||
public void verifyInitialized() throws IllegalStateException
|
||||
{
|
||||
if (!initialized) {
|
||||
private Map browserControls;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
|
||||
protected Bookmarks bookmarks = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
protected Preferences prefs = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
|
||||
protected ProfileManager profileManager = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WrapperFactoryImpl()
|
||||
{
|
||||
super();
|
||||
browserControls = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from webclient.WrapperFactory
|
||||
//
|
||||
|
||||
public BrowserControl newBrowserControl() throws InstantiationException, IllegalAccessException, IllegalStateException {
|
||||
verifyInitialized();
|
||||
|
||||
BrowserControl result = new BrowserControlImpl(this);
|
||||
final int nativeBrowserControl = nativeCreateBrowserControl();
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
WrapperFactoryImpl.this.nativeInitBrowserControl(nativeWrapperFactory, nativeBrowserControl);
|
||||
}
|
||||
};
|
||||
eventThread.pushNotifyRunnable(runnable);
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WrapperFactoryImpl.initialize(): interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Exception e = eventThread.getAndClearException();
|
||||
if (null != e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
}
|
||||
|
||||
browserControls.put(result, new Integer(nativeBrowserControl));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void deleteBrowserControl(BrowserControl toDelete) {
|
||||
verifyInitialized();
|
||||
Integer nativeBc;
|
||||
|
||||
if (null != (nativeBc = (Integer) browserControls.get(toDelete))) {
|
||||
final int nativeBrowserControl = nativeBc.intValue();
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
WrapperFactoryImpl.this.nativeDestroyBrowserControl(nativeBrowserControl);
|
||||
}
|
||||
};
|
||||
eventThread.pushNotifyRunnable(runnable);
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WrapperFactoryImpl.deleteBrowserControl(): interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Exception e = eventThread.getAndClearException();
|
||||
if (null != e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* @param interfaceName IMPORTANT!!!! This method assumes that
|
||||
* interfaceName is one of the actual strings from the interface
|
||||
* definition for BrowserControl. That is, this method is only called
|
||||
* from BrowserControlImpl, and is only invoked like this
|
||||
|
||||
<CODE><PRE>
|
||||
|
||||
// BrowserControlImpl code...
|
||||
|
||||
if (WINDOW_CONTROL_NAME.equals(interfaceName)) {
|
||||
if (null == windowControl) {
|
||||
windowControl =
|
||||
(WindowControl) wrapperFactory.newImpl(WINDOW_CONTROL_NAME,
|
||||
this);
|
||||
}
|
||||
return windowControl;
|
||||
}
|
||||
|
||||
</PRE></CODE>
|
||||
|
||||
* <P>
|
||||
* This is done to avoid a costly string compare. This shortcut is
|
||||
* justified since WrapperFactoryImpl is only called from
|
||||
* BrowserControlImpl <B>and</B> the only values for interfaceName that
|
||||
* make sense are those defined in BrowserControl class variables ending
|
||||
* with _NAME.
|
||||
* </P>
|
||||
|
||||
* @see org.mozilla.webclient.BrowserControl.BROWSER_CONTROL_CANVAS_NAME
|
||||
|
||||
*/
|
||||
|
||||
public Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException {
|
||||
Object result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (!nativeDoesImplement(interfaceName)) {
|
||||
throw new ClassNotFoundException("Can't instantiate " +
|
||||
interfaceName +
|
||||
": not implemented.");
|
||||
}
|
||||
if (BrowserControl.WINDOW_CONTROL_NAME == interfaceName) {
|
||||
result = new WindowControlImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.NAVIGATION_NAME == interfaceName) {
|
||||
result = new NavigationImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.HISTORY_NAME == interfaceName) {
|
||||
result = new HistoryImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.CURRENT_PAGE_NAME == interfaceName) {
|
||||
result = new CurrentPageImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.EVENT_REGISTRATION_NAME == interfaceName) {
|
||||
result = new EventRegistrationImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
|
||||
Assert.assert_it(null != bookmarks);
|
||||
result = bookmarks;
|
||||
}
|
||||
if (BrowserControl.PREFERENCES_NAME == interfaceName) {
|
||||
Assert.assert_it(null != prefs);
|
||||
result = prefs;
|
||||
}
|
||||
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
|
||||
Assert.assert_it(null != profileManager);
|
||||
result = profileManager;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.loadLibrary("webclient");
|
||||
|
||||
//
|
||||
// Do the first initialization call
|
||||
//
|
||||
|
||||
nativeWrapperFactory = nativeCreateNativeWrapperFactory();
|
||||
Assert.assert_it(-1 != nativeWrapperFactory);
|
||||
|
||||
eventThread = new NativeEventThread("WebclientEventThread", this,
|
||||
nativeWrapperFactory);
|
||||
|
||||
final String finalStr = new String(verifiedBinDirAbsolutePath);
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
WrapperFactoryImpl.this.nativeAppInitialize(finalStr,
|
||||
nativeWrapperFactory,
|
||||
eventThread);
|
||||
}
|
||||
};
|
||||
|
||||
eventThread.pushNotifyRunnable(runnable);
|
||||
|
||||
eventThread.start();
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WrapperFactoryImpl.initialize(): interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Exception e = eventThread.getAndClearException();
|
||||
if (null != e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
|
||||
//
|
||||
// create app singletons
|
||||
//
|
||||
profileManager = new ProfileManagerImpl(this);
|
||||
Assert.assert_it(null != profileManager);
|
||||
prefs = new PreferencesImpl(this);
|
||||
Assert.assert_it(null != prefs);
|
||||
bookmarks = new BookmarksImpl(this);
|
||||
Assert.assert_it(null != bookmarks);
|
||||
|
||||
runnable = new Runnable() {
|
||||
public void run() {
|
||||
|
||||
((Service)WrapperFactoryImpl.this.profileManager).startup();
|
||||
((Service)WrapperFactoryImpl.this.prefs).startup();
|
||||
|
||||
((Service)WrapperFactoryImpl.this.bookmarks).startup();
|
||||
|
||||
WrapperFactoryImpl.this.nativeAppSetup(nativeWrapperFactory);
|
||||
}
|
||||
};
|
||||
eventThread.pushNotifyRunnable(runnable);
|
||||
|
||||
synchronized (this) {
|
||||
// This causes the above Runnable to be executed.
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception exp) {
|
||||
System.out.println("WrapperFactoryImpl.initialize(): interrupted while waiting\n\t for NativeEventThread to notify(): " + exp +
|
||||
" " + exp.getMessage());
|
||||
}
|
||||
}
|
||||
e = eventThread.getAndClearException();
|
||||
if (null != e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void verifyInitialized() throws IllegalStateException
|
||||
{
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("Webclient has not been initialized.");
|
||||
}
|
||||
}
|
||||
|
||||
public void terminate() throws Exception
|
||||
{
|
||||
Assert.assert_it(null != bookmarks);
|
||||
((Service)bookmarks).shutdown();
|
||||
((ImplObject)bookmarks).delete();
|
||||
bookmarks = null;
|
||||
eventThread.pushNotifyRunnable(new Runnable() {
|
||||
public void run() {
|
||||
Assert.assert_it(null != bookmarks);
|
||||
((Service)bookmarks).shutdown();
|
||||
((ImplObject)bookmarks).delete();
|
||||
bookmarks = null;
|
||||
|
||||
Assert.assert_it(null != prefs);
|
||||
((Service)prefs).shutdown();
|
||||
((ImplObject)prefs).delete();
|
||||
prefs = null;
|
||||
|
||||
Assert.assert_it(null != profileManager);
|
||||
((Service)profileManager).shutdown();
|
||||
((ImplObject)profileManager).delete();
|
||||
profileManager = null;
|
||||
nativeTerminate(nativeWrapperFactory);
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assert_it(null != prefs);
|
||||
((Service)prefs).shutdown();
|
||||
((ImplObject)prefs).delete();
|
||||
prefs = null;
|
||||
|
||||
Assert.assert_it(null != profileManager);
|
||||
((Service)profileManager).shutdown();
|
||||
((ImplObject)profileManager).delete();
|
||||
profileManager = null;
|
||||
|
||||
nativeTerminate(nativeContext);
|
||||
}
|
||||
|
||||
public int getNativeContext() {
|
||||
return nativeContext;
|
||||
}
|
||||
|
||||
public Object getNativeEventThread(BrowserControl bc) {
|
||||
verifyInitialized();
|
||||
NativeEventThread eventThread = null;
|
||||
int nativeBrowserControl = -1;
|
||||
|
||||
synchronized(bc) {
|
||||
// if this is the first time the nativeBrowserControl has been
|
||||
// requested for this Java BrowserControl instance:
|
||||
if (null ==
|
||||
(eventThread = (NativeEventThread) nativeEventThreads.get(bc))) {
|
||||
|
||||
// spin up the NativeEventThread
|
||||
try {
|
||||
nativeBrowserControl =
|
||||
nativeCreateBrowserControl(nativeContext);
|
||||
eventThread = new NativeEventThread("EventThread-" +
|
||||
nativeBrowserControl,
|
||||
nativeBrowserControl, bc);
|
||||
// IMPORTANT: the nativeEventThread initializes all the
|
||||
// native browser stuff, then sends us notify().
|
||||
eventThread.start();
|
||||
try {
|
||||
bc.wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WindowControlImpl.createWindow: interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
|
||||
nativeEventThreads.put(bc, eventThread);
|
||||
}
|
||||
catch (Exception e) {
|
||||
nativeBrowserControl = -1;
|
||||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WrapperFactoryImpl.initialize(): interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return eventThread;
|
||||
Exception e = eventThread.getAndClearException();
|
||||
if (null != e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
}
|
||||
eventThread.delete();
|
||||
eventThread = null;
|
||||
|
||||
}
|
||||
|
||||
public Object getNativeEventThread() {
|
||||
verifyInitialized();
|
||||
return eventThread;
|
||||
}
|
||||
|
||||
public int getNativeWrapperFactory() {
|
||||
return nativeWrapperFactory;
|
||||
}
|
||||
|
||||
public int getNativeBrowserControl(BrowserControl bc) {
|
||||
NativeEventThread eventThread =
|
||||
(NativeEventThread) getNativeEventThread(bc);
|
||||
return eventThread.getNativeBrowserControl();
|
||||
}
|
||||
|
||||
public void destroyNativeBrowserControl(BrowserControl bc) {
|
||||
verifyInitialized();
|
||||
NativeEventThread eventThread = null;
|
||||
int nativeBrowserControl = -1;
|
||||
|
||||
synchronized(this) {
|
||||
if (null !=
|
||||
(eventThread = (NativeEventThread) nativeEventThreads.get(bc))){
|
||||
nativeBrowserControl = eventThread.getNativeBrowserControl();
|
||||
|
||||
eventThread.delete();
|
||||
|
||||
try {
|
||||
nativeDestroyBrowserControl(nativeContext,
|
||||
nativeBrowserControl);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("Exception while destroying nativeBrowserControl:"
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
Integer result = (Integer) browserControls.get(bc);
|
||||
if (null != result) {
|
||||
return result.intValue();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// helper methods
|
||||
@@ -363,6 +454,8 @@ protected String getPlatformCanvasClassName()
|
||||
// Native methods
|
||||
//
|
||||
|
||||
native int nativeCreateNativeWrapperFactory() throws RuntimeException;
|
||||
|
||||
/**
|
||||
|
||||
* <p>This is called only once, at the very beginning of program execution.
|
||||
@@ -374,7 +467,7 @@ protected String getPlatformCanvasClassName()
|
||||
|
||||
*/
|
||||
|
||||
native int nativeAppInitialize (String verifiedBinDirAbsolutePath) throws Exception;
|
||||
native void nativeAppInitialize (String verifiedBinDirAbsolutePath, int nativeWrapperFactory, NativeEventThread nativeThread) throws RuntimeException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -382,7 +475,7 @@ native int nativeAppInitialize (String verifiedBinDirAbsolutePath) throws Except
|
||||
* been started.</p>
|
||||
*/
|
||||
|
||||
native void nativeAppSetup(int nativeContext) throws Exception;
|
||||
native void nativeAppSetup(int nativeWrapperFactory) throws RuntimeException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -391,7 +484,7 @@ native void nativeAppSetup(int nativeContext) throws Exception;
|
||||
|
||||
*/
|
||||
|
||||
native void nativeTerminate(int nativeContext) throws Exception;
|
||||
native void nativeTerminate(int nativeWrapperFactory) throws RuntimeException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -407,18 +500,32 @@ native void nativeTerminate(int nativeContext) throws Exception;
|
||||
native boolean nativeDoesImplement(String interfaceName);
|
||||
|
||||
/**
|
||||
|
||||
* <p>The one and only entry point to do per-window initialization.</p>
|
||||
|
||||
* <p>Takes the int from ImplObjectNative.getNativeBrowserControl, the
|
||||
* meaning of which is left up to the implementation, and does any
|
||||
* per-window creation and initialization tasks. </P>
|
||||
|
||||
* <p>For mozilla, this means creating the nsIWebShell instance,
|
||||
* attaching to the native event queue, creating the nsISessionHistory
|
||||
* instance, etc.</p>
|
||||
|
||||
* <p>This used to be NativeEventThread.nativeStartup().</p>
|
||||
|
||||
*/
|
||||
native int nativeCreateBrowserControl(int nativeContext) throws Exception;
|
||||
|
||||
native int nativeCreateBrowserControl() throws RuntimeException;
|
||||
|
||||
native void nativeInitBrowserControl(int nativeWrapperFactory, int nativeBrowserControl) throws RuntimeException;
|
||||
|
||||
/*
|
||||
|
||||
* <p>The one and only de-allocater for the nativeBrowserControl</p>
|
||||
|
||||
* <p>This used to be NativeEventThread.nativeShutdown().
|
||||
|
||||
*/
|
||||
native int nativeDestroyBrowserControl(int nativeContext,
|
||||
int nativeBrowserControl) throws Exception;
|
||||
|
||||
native int nativeDestroyBrowserControl(int nativeBrowserControl) throws RuntimeException;
|
||||
|
||||
} // end of class WrapperFactoryImpl
|
||||
|
||||
@@ -34,7 +34,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Bookmarks
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeStartup: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsresult rv;
|
||||
@@ -55,7 +55,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Bookmarks
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeShutdown: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsresult rv;
|
||||
@@ -86,7 +86,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Bookmarks
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeGetBookmarks: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(kNC_BookmarksRoot);
|
||||
@@ -106,7 +106,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeNewRDFNode: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
|
||||
@@ -104,7 +104,9 @@ EmbedWindow::ReleaseChildren(void)
|
||||
{
|
||||
ExitModalEventLoop(PR_FALSE);
|
||||
|
||||
mBaseWindow->Destroy();
|
||||
if (mBaseWindow) {
|
||||
mBaseWindow->Destroy();
|
||||
}
|
||||
mBaseWindow = 0;
|
||||
mWebBrowser = 0;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ REQUIRES = xpcom \
|
||||
# HistoryActionEvents.cpp \
|
||||
# ISupportsPeer.cpp \
|
||||
# NativeEventThreadActionEvents.cpp \
|
||||
# NavigationImpl.cpp \
|
||||
# NavigationActionEvents.cpp \
|
||||
# InputStreamShim.cpp \
|
||||
# WindowControlImpl.cpp \
|
||||
@@ -104,8 +103,10 @@ REQUIRES = xpcom \
|
||||
|
||||
CPPSRCS = \
|
||||
NativeBrowserControl.cpp \
|
||||
NativeWrapperFactory.cpp \
|
||||
EmbedWindow.cpp \
|
||||
NativeEventThread.cpp \
|
||||
NavigationImpl.cpp \
|
||||
ns_util.cpp \
|
||||
ns_util_export.cpp \
|
||||
dom_util.cpp \
|
||||
|
||||
@@ -34,22 +34,6 @@
|
||||
#include "NativeBrowserControl.h"
|
||||
#include "ns_util.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <unistd.h>
|
||||
#include "gdksuperwin.h"
|
||||
#include "gtkmozarea.h"
|
||||
|
||||
extern "C" {
|
||||
static int wc_x_error (Display *display,
|
||||
XErrorEvent *error);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
PLEventQueue *NativeBrowserControl::sActionQueue = nsnull;
|
||||
PRThread *NativeBrowserControl::sEmbeddedThread = nsnull;
|
||||
PRBool NativeBrowserControl::sInitComplete = PR_FALSE;
|
||||
|
||||
NativeBrowserControl::NativeBrowserControl(void)
|
||||
{
|
||||
@@ -57,8 +41,6 @@ NativeBrowserControl::NativeBrowserControl(void)
|
||||
mNavigation = nsnull;
|
||||
mSessionHistory = nsnull;
|
||||
mWindow = nsnull;
|
||||
mEnv = nsnull;
|
||||
mNativeEventThread = nsnull;
|
||||
mChromeMask = 0;
|
||||
mIsChrome = PR_FALSE;
|
||||
mChromeLoaded = PR_FALSE;
|
||||
@@ -74,87 +56,8 @@ NativeBrowserControl::~NativeBrowserControl()
|
||||
}
|
||||
|
||||
nsresult
|
||||
NativeBrowserControl::Init(JNIEnv * env, jobject newNativeEventThread)
|
||||
NativeBrowserControl::Init()
|
||||
{
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
|
||||
//
|
||||
// Do java communication initialization
|
||||
//
|
||||
mEnv = env;
|
||||
// store the java NativeEventThread class
|
||||
mNativeEventThread = ::util_NewGlobalRef(env, newNativeEventThread);
|
||||
// This enables the listener to call back into java
|
||||
|
||||
util_InitializeShareInitContext(mEnv, &mShareContext);
|
||||
|
||||
//
|
||||
// create the singleton event queue
|
||||
//
|
||||
|
||||
// create the static sActionQueue
|
||||
if (nsnull == sEmbeddedThread) {
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
|
||||
|
||||
if (!aEventQService) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
// Create the event queue.
|
||||
mFailureCode = aEventQService->CreateThreadEventQueue();
|
||||
sEmbeddedThread = PR_GetCurrentThread();
|
||||
|
||||
if (!sEmbeddedThread) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: Create UI Thread EventQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
mFailureCode = aEventQService->GetThreadEventQueue(sEmbeddedThread, &EQueue);
|
||||
if (NS_FAILED(mFailureCode)) {
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: Get UI Thread EventQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
||||
GDK_INPUT_READ,
|
||||
event_processor_callback,
|
||||
EQueue);
|
||||
#endif
|
||||
|
||||
PLEventQueue * plEventQueue = nsnull;
|
||||
|
||||
EQueue->GetPLEventQueue(&plEventQueue);
|
||||
sActionQueue = plEventQueue;
|
||||
if (!sActionQueue) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: get ActionQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
// The gdk_x_error function exits in some cases, we don't
|
||||
// want that.
|
||||
XSetErrorHandler(wc_x_error);
|
||||
#endif
|
||||
sInitComplete = PR_TRUE;
|
||||
}
|
||||
|
||||
// Create our embed window, and create an owning reference to it and
|
||||
// initialize it. It is assumed that this window will be destroyed
|
||||
@@ -162,6 +65,13 @@ NativeBrowserControl::Init(JNIEnv * env, jobject newNativeEventThread)
|
||||
mWindow = new EmbedWindow();
|
||||
mWindowGuard = NS_STATIC_CAST(nsIWebBrowserChrome *, mWindow);
|
||||
mWindow->Init(this);
|
||||
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
// get a handle on the navigation object
|
||||
mNavigation = do_QueryInterface(webBrowser);
|
||||
|
||||
|
||||
//
|
||||
// create the WindowCreator: see
|
||||
@@ -202,96 +112,25 @@ void
|
||||
NativeBrowserControl::Destroy(void)
|
||||
{
|
||||
mIsDestroyed = PR_TRUE;
|
||||
if (nsnull != mNativeEventThread) {
|
||||
::util_DeleteGlobalRef(mEnv, mNativeEventThread);
|
||||
}
|
||||
|
||||
// PENDING(edburns): take over the stuff from
|
||||
// WindowControlActionEvents
|
||||
// wsDeallocateInitContextEvent::handleEvent()
|
||||
|
||||
// This flag might have been set from
|
||||
// EmbedWindow::DestroyBrowserWindow() as well if someone used a
|
||||
// window.close() or something or some other script action to close
|
||||
// the window. No harm setting it again.
|
||||
|
||||
// Get the nsIWebBrowser object for our embedded window.
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
// destroy our child window
|
||||
mWindow->ReleaseChildren();
|
||||
|
||||
// release navigation
|
||||
mNavigation = nsnull;
|
||||
|
||||
parentHWnd = nsnull;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
NativeBrowserControl::ProcessEventLoop(void)
|
||||
{
|
||||
if (PR_GetCurrentThread() != sEmbeddedThread) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
while(gtk_events_pending()) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
#else
|
||||
// PENDING(mark): Does this work on the Mac?
|
||||
MSG msg;
|
||||
PRBool wasHandled;
|
||||
|
||||
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
|
||||
if (::GetMessage(&msg, nsnull, 0, 0)) {
|
||||
wasHandled = PR_FALSE;
|
||||
::NS_HandleEmbeddingEvent(msg, wasHandled);
|
||||
if (!wasHandled) {
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if (sInitComplete && sActionQueue) {
|
||||
PLEvent * event = nsnull;
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(sActionQueue);
|
||||
if (::PL_EventAvailable(sActionQueue)) {
|
||||
event = ::PL_GetEvent(sActionQueue);
|
||||
}
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(sActionQueue);
|
||||
if (event != nsnull) {
|
||||
::PL_HandleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
// PENDING(edburns): revisit this. Not sure why this is necessary, but
|
||||
// this fixes bug 44327
|
||||
// printf("%c", 8); // 8 is ASCII for backspace
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NativeBrowserControl::GetFailureCode(void)
|
||||
{
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRBool
|
||||
NativeBrowserControl::IsInitialized(void)
|
||||
{
|
||||
return sInitComplete;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
static int
|
||||
wc_x_error (Display *display,
|
||||
XErrorEvent *error)
|
||||
{
|
||||
if (error->error_code)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
XGetErrorText (display, error->error_code, buf, 63);
|
||||
|
||||
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
|
||||
buf,
|
||||
error->serial,
|
||||
error->error_code,
|
||||
error->request_code,
|
||||
error->minor_code);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
// public API
|
||||
//
|
||||
|
||||
nsresult Init (JNIEnv *env, jobject nativeEventThread);
|
||||
nsresult Init ();
|
||||
nsresult Realize (void* parentWinPtr, PRBool *aAlreadyRealized);
|
||||
void Unrealize (void);
|
||||
void Show (void);
|
||||
@@ -67,21 +67,6 @@ public:
|
||||
void Resize (PRUint32 aWidth, PRUint32 aHeight);
|
||||
void Destroy (void);
|
||||
|
||||
/**
|
||||
|
||||
* This function processes methods inserted into NativeBrowserControl's
|
||||
* actionQueue. It is called once during the initialization of the
|
||||
* NativeEventThread java thread, and infinitely in
|
||||
* NativeEventThread.run()'s event loop. The call to PL_HandleEvent
|
||||
* below, ends up calling the nsActionEvent subclass's handleEvent()
|
||||
* method. After which it calls nsActionEvent::destroyEvent().
|
||||
|
||||
*/
|
||||
|
||||
PRUint32 ProcessEventLoop(void);
|
||||
nsresult GetFailureCode (void);
|
||||
static PRBool IsInitialized (void);
|
||||
|
||||
//
|
||||
// Relationship ivars
|
||||
//
|
||||
@@ -97,8 +82,6 @@ public:
|
||||
|
||||
EmbedWindow * mWindow;
|
||||
nsCOMPtr<nsISupports> mWindowGuard;
|
||||
JNIEnv * mEnv;
|
||||
jobject mNativeEventThread;
|
||||
ShareInitContext mShareContext;
|
||||
|
||||
// chrome mask
|
||||
@@ -110,16 +93,6 @@ public:
|
||||
// has someone called Destroy() on us?
|
||||
PRBool mIsDestroyed;
|
||||
|
||||
//
|
||||
// Class vars
|
||||
//
|
||||
static PLEventQueue * sActionQueue;
|
||||
static PRThread * sEmbeddedThread;
|
||||
|
||||
private:
|
||||
nsresult mFailureCode;
|
||||
static PRBool sInitComplete;
|
||||
|
||||
};
|
||||
|
||||
#endif // NativeBrowserControl_h
|
||||
|
||||
@@ -113,75 +113,23 @@ static PRBool gFirstTime = PR_TRUE;
|
||||
nsISHistory *gHistory = nsnull;
|
||||
WindowCreator * gCreatorCallback = nsnull;
|
||||
|
||||
char * errorMessages[] = {
|
||||
"No Error",
|
||||
"Could not obtain the event queue service.",
|
||||
"Unable to create the WebShell instance.",
|
||||
"Unable to initialize the WebShell instance.",
|
||||
"Unable to show the WebShell."
|
||||
};
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeStartup
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (!nativeBrowserControl) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL nativeBCPtr passed to nativeStartup.");
|
||||
return;
|
||||
}
|
||||
rv = nativeBrowserControl->Init(env, obj);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
errorMessages[3]);
|
||||
return;
|
||||
}
|
||||
nativeBrowserControl->ProcessEventLoop();
|
||||
|
||||
while (!nativeBrowserControl->IsInitialized()) {
|
||||
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if (NS_FAILED(nativeBrowserControl->GetFailureCode())) {
|
||||
::util_ThrowExceptionToJava(env, errorMessages[3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeShutdown
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (!nativeBrowserControl) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL nativeBCPtr passed to nativeStartup.");
|
||||
return;
|
||||
}
|
||||
nativeBrowserControl->Destroy();
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeProcessEvents
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr)
|
||||
(JNIEnv *env, jobject obj, jint nativePtr)
|
||||
{
|
||||
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
NativeWrapperFactory * nativeWrapperFactory =
|
||||
(NativeWrapperFactory *) nativePtr;
|
||||
|
||||
if (nsnull == nativeBrowserControl) {
|
||||
if (nsnull == nativePtr) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL nativeBCPtr passed to nativeProcessEvents.");
|
||||
"NULL nativePtr passed to nativeProcessEvents.");
|
||||
return;
|
||||
}
|
||||
|
||||
nativeBrowserControl->ProcessEventLoop();
|
||||
|
||||
nativeWrapperFactory->ProcessEventLoop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
248
mozilla/java/webclient/src_moz/NativeWrapperFactory.cpp
Normal file
248
mozilla/java/webclient/src_moz/NativeWrapperFactory.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "nsIEventQueueService.h" // for PLEventQueue
|
||||
#include "nsIServiceManager.h" // for do_GetService
|
||||
#include "nsEmbedAPI.h" // for NS_HandleEmbeddingEvent
|
||||
|
||||
#include "NativeWrapperFactory.h"
|
||||
|
||||
#include "ns_util.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <unistd.h>
|
||||
#include "gdksuperwin.h"
|
||||
#include "gtkmozarea.h"
|
||||
|
||||
extern "C" {
|
||||
static int wc_x_error (Display *display,
|
||||
XErrorEvent *error);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PLEventQueue *NativeWrapperFactory::sActionQueue = nsnull;
|
||||
PRThread *NativeWrapperFactory::sEmbeddedThread = nsnull;
|
||||
PRBool NativeWrapperFactory::sInitComplete = PR_FALSE;
|
||||
|
||||
NativeWrapperFactory::NativeWrapperFactory(void)
|
||||
{
|
||||
mEnv = nsnull;
|
||||
mNativeEventThread = nsnull;
|
||||
}
|
||||
|
||||
NativeWrapperFactory::~NativeWrapperFactory()
|
||||
{
|
||||
sProfile = nsnull;
|
||||
sProfileInternal = nsnull;
|
||||
sPrefs = nsnull;
|
||||
sAppShell = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NativeWrapperFactory::Init(JNIEnv * env, jobject newNativeEventThread)
|
||||
{
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
if (nsnull == sEmbeddedThread) {
|
||||
//
|
||||
// Do java communication initialization
|
||||
//
|
||||
mEnv = env;
|
||||
// store the java NativeEventThread class
|
||||
mNativeEventThread = ::util_NewGlobalRef(env,
|
||||
newNativeEventThread);
|
||||
//
|
||||
// create the singleton event queue
|
||||
//
|
||||
|
||||
// create the static sActionQueue
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
|
||||
if (!aEventQService) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
// Create the event queue.
|
||||
mFailureCode = aEventQService->CreateThreadEventQueue();
|
||||
sEmbeddedThread = PR_GetCurrentThread();
|
||||
|
||||
if (!sEmbeddedThread) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: Create UI Thread EventQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
mFailureCode = aEventQService->GetThreadEventQueue(sEmbeddedThread, &EQueue);
|
||||
if (NS_FAILED(mFailureCode)) {
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: Get UI Thread EventQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
||||
GDK_INPUT_READ,
|
||||
event_processor_callback,
|
||||
EQueue);
|
||||
#endif
|
||||
|
||||
PLEventQueue * plEventQueue = nsnull;
|
||||
|
||||
EQueue->GetPLEventQueue(&plEventQueue);
|
||||
sActionQueue = plEventQueue;
|
||||
if (!sActionQueue) {
|
||||
mFailureCode = NS_ERROR_FAILURE;
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("NativeBrowserControl_Init: get ActionQueue: %d\n",
|
||||
mFailureCode));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
// The gdk_x_error function exits in some cases, we don't
|
||||
// want that.
|
||||
XSetErrorHandler(wc_x_error);
|
||||
#endif
|
||||
sInitComplete = PR_TRUE;
|
||||
}
|
||||
mFailureCode = NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NativeWrapperFactory::Destroy(void)
|
||||
{
|
||||
if (nsnull != mNativeEventThread) {
|
||||
::util_DeleteGlobalRef(mEnv, mNativeEventThread);
|
||||
}
|
||||
|
||||
// PENDING(edburns): take over the stuff from
|
||||
// WindowControlActionEvents
|
||||
// wsDeallocateInitContextEvent::handleEvent()
|
||||
|
||||
// This flag might have been set from
|
||||
// EmbedWindow::DestroyBrowserWindow() as well if someone used a
|
||||
// window.close() or something or some other script action to close
|
||||
// the window. No harm setting it again.
|
||||
}
|
||||
|
||||
PRUint32
|
||||
NativeWrapperFactory::ProcessEventLoop(void)
|
||||
{
|
||||
if (PR_GetCurrentThread() != sEmbeddedThread) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
while(gtk_events_pending()) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
#else
|
||||
// PENDING(mark): Does this work on the Mac?
|
||||
MSG msg;
|
||||
PRBool wasHandled;
|
||||
|
||||
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
|
||||
if (::GetMessage(&msg, nsnull, 0, 0)) {
|
||||
wasHandled = PR_FALSE;
|
||||
::NS_HandleEmbeddingEvent(msg, wasHandled);
|
||||
if (!wasHandled) {
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if (sInitComplete && sActionQueue) {
|
||||
PLEvent * event = nsnull;
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(sActionQueue);
|
||||
if (::PL_EventAvailable(sActionQueue)) {
|
||||
event = ::PL_GetEvent(sActionQueue);
|
||||
}
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(sActionQueue);
|
||||
if (event != nsnull) {
|
||||
::PL_HandleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
// PENDING(edburns): revisit this. Not sure why this is necessary, but
|
||||
// this fixes bug 44327
|
||||
// printf("%c", 8); // 8 is ASCII for backspace
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NativeWrapperFactory::GetFailureCode(void)
|
||||
{
|
||||
return mFailureCode;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRBool
|
||||
NativeWrapperFactory::IsInitialized(void)
|
||||
{
|
||||
return sInitComplete;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
static int
|
||||
wc_x_error (Display *display,
|
||||
XErrorEvent *error)
|
||||
{
|
||||
if (error->error_code)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
XGetErrorText (display, error->error_code, buf, 63);
|
||||
|
||||
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
|
||||
buf,
|
||||
error->serial,
|
||||
error->error_code,
|
||||
error->request_code,
|
||||
error->minor_code);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
96
mozilla/java/webclient/src_moz/NativeWrapperFactory.h
Normal file
96
mozilla/java/webclient/src_moz/NativeWrapperFactory.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#ifndef NativeWrapperFactory_h
|
||||
#define NativeWrapperFactory_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
class nsIProfile;
|
||||
class nsIProfileInternal;
|
||||
class nsIPref;
|
||||
class nsIAppShell;
|
||||
class NativeBrowserControl;
|
||||
struct PLEventQueue;
|
||||
struct PRThread;
|
||||
|
||||
class NativeWrapperFactory {
|
||||
|
||||
public:
|
||||
NativeWrapperFactory();
|
||||
~NativeWrapperFactory();
|
||||
|
||||
//
|
||||
// public API
|
||||
//
|
||||
|
||||
nsresult Init (JNIEnv *env, jobject nativeEventThread);
|
||||
void Destroy (void);
|
||||
|
||||
/*
|
||||
* This function processes methods inserted into the actionQueue.
|
||||
* It is called once during the initialization of the
|
||||
* NativeEventThread java thread, and infinitely in
|
||||
* NativeEventThread.run()'s event loop. The call to PL_HandleEvent
|
||||
* below, ends up calling the nsActionEvent subclass's handleEvent()
|
||||
* method. After which it calls nsActionEvent::destroyEvent().
|
||||
*/
|
||||
|
||||
PRUint32 ProcessEventLoop(void);
|
||||
nsresult GetFailureCode (void);
|
||||
static PRBool IsInitialized (void);
|
||||
|
||||
//
|
||||
// public ivars
|
||||
//
|
||||
|
||||
JNIEnv * mEnv;
|
||||
jobject mNativeEventThread;
|
||||
ShareInitContext shareContext;
|
||||
|
||||
//
|
||||
// Class vars
|
||||
//
|
||||
nsIProfile * sProfile;
|
||||
nsIProfileInternal * sProfileInternal;
|
||||
nsIPref * sPrefs;
|
||||
nsIAppShell * sAppShell;
|
||||
|
||||
static PLEventQueue * sActionQueue;
|
||||
static PRThread * sEmbeddedThread;
|
||||
|
||||
private:
|
||||
nsresult mFailureCode;
|
||||
static PRBool sInitComplete;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // NativeWrapperFactory_h
|
||||
@@ -30,16 +30,18 @@
|
||||
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NavigationImpl.h"
|
||||
|
||||
#include "NavigationActionEvents.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
#include "NativeBrowserControl.h"
|
||||
#include "ns_util.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadURL
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString)
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jstring urlString)
|
||||
{
|
||||
jobject jobj = obj;
|
||||
|
||||
@@ -55,39 +57,40 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
|
||||
PRUnichar * urlStringChars = (PRUnichar *) ::util_GetStringChars(env,
|
||||
urlString);
|
||||
PRInt32 urlLength = (PRInt32) ::util_GetStringLength(env, urlString);
|
||||
|
||||
|
||||
if (::util_ExceptionOccurred(env)) {
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellLoadURL Exception: unable to extract Java string");
|
||||
if (urlStringChars != nsnull)
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
return;
|
||||
}
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellLoadURL Exception: unable to extract Java string");
|
||||
if (urlStringChars != nsnull)
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellLoadURL");
|
||||
if (nativeBrowserControl == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null passed to nativeLoadURL");
|
||||
if (urlStringChars != nsnull)
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsLoadURLEvent * actionEvent = new wsLoadURLEvent(initContext->webNavigation, urlStringChars, urlLength);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
nsresult rv =
|
||||
nativeBrowserControl->mNavigation->LoadURI(urlStringChars,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't load URL");
|
||||
}
|
||||
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadFromStream
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject stream, jstring uri,
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject stream, jstring uri,
|
||||
jstring contentType, jint contentLength, jobject loadProperties)
|
||||
{
|
||||
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
PRUnichar *uriStringUniChars = nsnull;
|
||||
PRInt32 uriStringUniCharsLength = -1;
|
||||
const char *contentTypeChars = nsnull;
|
||||
@@ -96,8 +99,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
nsString *uriNsString = nsnull;
|
||||
wsLoadFromStreamEvent *actionEvent = nsnull;
|
||||
|
||||
if (initContext == nsnull || !initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeLoadFromStream");
|
||||
if (nativeBrowserControl == nsnull || !nativeBrowserControl->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeLoadFromStream");
|
||||
return;
|
||||
}
|
||||
uriStringUniChars = (PRUnichar *) ::util_GetStringChars(env, uri);
|
||||
@@ -129,7 +132,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
}
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsLoadFromStreamEvent(initContext,
|
||||
if (!(actionEvent = new wsLoadFromStreamEvent(nativeBrowserControl,
|
||||
(void *) globalStream,
|
||||
*uriNsString,
|
||||
contentTypeChars,
|
||||
@@ -139,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: can't create wsLoadFromStreamEvent");
|
||||
goto NLFS_CLEANUP;
|
||||
}
|
||||
::util_PostSynchronousEvent(initContext, (PLEvent *) *actionEvent);
|
||||
::util_PostSynchronousEvent(nativeBrowserControl, (PLEvent *) *actionEvent);
|
||||
|
||||
NLFS_CLEANUP:
|
||||
::util_ReleaseStringChars(env, uri, (const jchar *) uriStringUniChars);
|
||||
@@ -151,10 +154,10 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativePost
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring absoluteURL, jstring target, jint postDataLength,
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jstring absoluteURL, jstring target, jint postDataLength,
|
||||
jstring postData, jint postHeadersLength, jstring postHeaders)
|
||||
{
|
||||
NativeBrowserControl *initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl *nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
const PRUnichar *urlChars = nsnull;
|
||||
PRInt32 urlLen;
|
||||
const PRUnichar *targetChars = nsnull;
|
||||
@@ -173,8 +176,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext == nsnull || !initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativePost");
|
||||
if (nativeBrowserControl == nsnull || !nativeBrowserControl->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativePost");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,7 +242,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
}
|
||||
|
||||
|
||||
if (!(actionEvent = new wsPostEvent(initContext,
|
||||
if (!(actionEvent = new wsPostEvent(nativeBrowserControl,
|
||||
uri,
|
||||
targetChars,
|
||||
targetLen,
|
||||
@@ -252,7 +255,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
goto NPFS_CLEANUP;
|
||||
}
|
||||
|
||||
::util_PostSynchronousEvent(initContext, (PLEvent *) *actionEvent);
|
||||
::util_PostSynchronousEvent(nativeBrowserControl, (PLEvent *) *actionEvent);
|
||||
|
||||
NPFS_CLEANUP:
|
||||
if (urlChars != nsnull)
|
||||
@@ -269,23 +272,23 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jlong loadFlags)
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jlong loadFlags)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRefresh");
|
||||
if (nativeBrowserControl == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellRefresh");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webNavigation, (PRInt32) loadFlags);
|
||||
if (nativeBrowserControl->initComplete) {
|
||||
wsRefreshEvent * actionEvent = new wsRefreshEvent(nativeBrowserControl->webNavigation, (PRInt32) loadFlags);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
::util_PostEvent(nativeBrowserControl, event);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -294,37 +297,37 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeStop
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellStop");
|
||||
if (nativeBrowserControl == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellStop");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsStopEvent * actionEvent = new wsStopEvent(initContext->webNavigation);
|
||||
if (nativeBrowserControl->initComplete) {
|
||||
wsStopEvent * actionEvent = new wsStopEvent(nativeBrowserControl->webNavigation);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
::util_PostEvent(nativeBrowserControl, event);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeSetPrompt
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject userPrompt)
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject userPrompt)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetPrompt");
|
||||
if (nativeBrowserControl == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeSetPrompt");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -333,18 +336,19 @@ Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeSetPrompt
|
||||
return;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
if (!nativeBrowserControl->initComplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
// IMPORTANT: do the DeleteGlobalRef when we set a new prompt!
|
||||
|
||||
PR_ASSERT(initContext->browserContainer);
|
||||
PR_ASSERT(nativeBrowserControl->browserContainer);
|
||||
|
||||
|
||||
wsSetPromptEvent * actionEvent = new wsSetPromptEvent(initContext->browserContainer, userPrompt);
|
||||
wsSetPromptEvent * actionEvent = new wsSetPromptEvent(nativeBrowserControl->browserContainer, userPrompt);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
::util_PostSynchronousEvent(nativeBrowserControl, event);
|
||||
|
||||
}
|
||||
|
||||
********************/
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "ns_util.h"
|
||||
|
||||
typedef struct _peStruct {
|
||||
WebclientContext *cx;
|
||||
NativeWrapperFactory *cx;
|
||||
jobject obj;
|
||||
jobject callback;
|
||||
} peStruct;
|
||||
@@ -53,7 +53,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Preferenc
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeStartup: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -78,7 +78,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Preferenc
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeShutdown: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -102,7 +102,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetUnichar
|
||||
("PreferencesImpl_nativeSetUnicharPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -159,7 +159,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetIntPref
|
||||
("PreferencesImpl_nativeSetIntPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -197,7 +197,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetBoolPre
|
||||
("PreferencesImpl_nativeSetIntPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -236,7 +236,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeGetPrefs
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
jobject newProps = nsnull;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -292,7 +292,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeRegisterPr
|
||||
("PreferencesImpl_nativeRegisterPrefChangedCallback: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
const char *prefNameChars = nsnull;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
@@ -334,7 +334,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Preferenc
|
||||
("PreferencesImpl_nativeRegisterPrefChangedCallback: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
const char *prefNameChars = nsnull;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
@@ -385,7 +385,7 @@ void prefEnumerator(const char *name, void *closure)
|
||||
return;
|
||||
}
|
||||
peStruct *pes = (peStruct *) closure;
|
||||
WebclientContext *wcContext = pes->cx;
|
||||
NativeWrapperFactory *wcContext = pes->cx;
|
||||
jobject props = pes->obj;
|
||||
PRInt32 prefType, intVal;
|
||||
PRBool boolVal;
|
||||
|
||||
@@ -55,7 +55,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -146,7 +146,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeShutdown: entering\n"));
|
||||
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -175,7 +175,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
PRInt32 count = 0;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
nsCOMPtr<nsIProfile> profile = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -199,7 +199,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Profi
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeProfileExists: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -229,7 +229,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeSetCurrentProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -255,7 +255,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Profil
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetCurrentProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -281,7 +281,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_P
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetProfileList: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -325,7 +325,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeCreateNewProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -365,7 +365,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeRenameProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
@@ -397,7 +397,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeDeleteProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
|
||||
@@ -57,7 +57,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeHasMoreElem
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeHasMoreElements: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(nativeRDFNode);
|
||||
@@ -92,7 +92,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeNextElement: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(nativeRDFNode);
|
||||
@@ -156,7 +156,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeFinalize: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint nativeEnum, nativeContainer;
|
||||
|
||||
@@ -50,7 +50,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_RDFTr
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsLeaf: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jboolean result = JNI_FALSE;
|
||||
@@ -77,7 +77,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_RDFTr
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsContainer: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
@@ -110,7 +110,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildAt: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -138,7 +138,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildCount: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
@@ -167,7 +167,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetIndex: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
@@ -191,7 +191,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeToString
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeToString: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -298,7 +298,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeInsertElementA
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeInsertElementAt: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(childProps); // PENDING(edburns): do we need to NewGlobalRef this?
|
||||
@@ -427,7 +427,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeNewFolder
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeNewFolder: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
|
||||
@@ -71,6 +71,15 @@ const char *gImplementedInterfaces[] = {
|
||||
nsnull
|
||||
};
|
||||
|
||||
char * errorMessages[] = {
|
||||
"No Error",
|
||||
"Could not obtain the event queue service.",
|
||||
"Unable to create the WebShell instance.",
|
||||
"Unable to initialize the WebShell instance.",
|
||||
"Unable to show the WebShell."
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Local Functions
|
||||
//
|
||||
@@ -80,15 +89,25 @@ const char *gImplementedInterfaces[] = {
|
||||
//
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
|
||||
JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeCreateNativeWrapperFactory(
|
||||
JNIEnv *env, jobject obj)
|
||||
{
|
||||
prLogModuleInfo = PR_NewLogModule("webclient");
|
||||
NativeWrapperFactory *result = new NativeWrapperFactory();
|
||||
return (jint) result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
|
||||
JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath, jint nativeWF, jobject nativeEventThread)
|
||||
{
|
||||
const char *nativePath = nsnull;
|
||||
WebclientContext *result = new WebclientContext();
|
||||
NativeWrapperFactory *nativeWrapperFactory = (NativeWrapperFactory *) nativeWF;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> binDir;
|
||||
|
||||
|
||||
// PENDING(edburns): We need this for rdf_getChildCount
|
||||
PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");
|
||||
|
||||
@@ -115,7 +134,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInit
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Can't get nsILocalFile from bin directory");
|
||||
return (jint) rv;
|
||||
}
|
||||
}
|
||||
::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, nativePath);
|
||||
@@ -131,7 +149,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInit
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "NS_InitEmbedding() failed.");
|
||||
return (jint) rv;
|
||||
}
|
||||
|
||||
// the rest of the startup tasks are coordinated from the java side.
|
||||
@@ -158,9 +175,12 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInit
|
||||
::util_GetJavaVM(env, &gVm); // save this vm reference
|
||||
}
|
||||
|
||||
util_InitializeShareInitContext(env, &(result->shareContext));
|
||||
|
||||
return (jint) result;
|
||||
util_InitializeShareInitContext(env, &(nativeWrapperFactory->shareContext));
|
||||
rv = nativeWrapperFactory->Init(env, nativeEventThread);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Failed to init NativeWrapperFactory");
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
@@ -170,7 +190,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetu
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -230,7 +250,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeTermina
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeTerminate: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
NativeWrapperFactory *wcContext = (NativeWrapperFactory *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
@@ -247,6 +267,8 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeTermina
|
||||
PR_ASSERT(nsnull == wcContext->sProfileInternal);
|
||||
|
||||
util_DeallocateShareInitContext(env, &(wcContext->shareContext));
|
||||
|
||||
wcContext->Destroy();
|
||||
|
||||
delete wcContext;
|
||||
|
||||
@@ -294,17 +316,54 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDoesImp
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeCreateBrowserControl
|
||||
(JNIEnv *env, jobject obj, jint nativeContext) {
|
||||
(JNIEnv *env, jobject obj) {
|
||||
NativeBrowserControl* initContext = new NativeBrowserControl();
|
||||
|
||||
return (jint) initContext;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeInitBrowserControl
|
||||
(JNIEnv *env, jobject obj, jint nativeWFPtr, jint nativeBCPtr) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NativeWrapperFactory * nativeWrapperFactory = (NativeWrapperFactory *) nativeWFPtr;
|
||||
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (!nativeBrowserControl || !nativeWFPtr) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL nativeBCPtr passed to nativeInitBrowserControl.");
|
||||
return;
|
||||
}
|
||||
rv = nativeBrowserControl->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
errorMessages[3]);
|
||||
return;
|
||||
}
|
||||
nativeWrapperFactory->ProcessEventLoop();
|
||||
|
||||
while (!nativeWrapperFactory->IsInitialized()) {
|
||||
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if (NS_FAILED(nativeWrapperFactory->GetFailureCode())) {
|
||||
::util_ThrowExceptionToJava(env, errorMessages[3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDestroyBrowserControl
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeBrowserControl) {
|
||||
NativeBrowserControl* initContext =
|
||||
(NativeBrowserControl *)nativeBrowserControl;
|
||||
delete initContext;
|
||||
(JNIEnv *env, jobject obj, jint nativeBC) {
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *)nativeBC;
|
||||
if (!nativeBrowserControl) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL nativeBCPtr passed to nativeDestroyBrowserControl.");
|
||||
return -1;
|
||||
}
|
||||
nativeBrowserControl->Destroy();
|
||||
|
||||
delete nativeBrowserControl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,23 +59,23 @@ const char *gSupportedListenerInterfaces[] = {
|
||||
|
||||
void util_PostEvent(NativeBrowserControl * initContext, PLEvent * event)
|
||||
{
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(NativeWrapperFactory::sActionQueue);
|
||||
|
||||
::PL_PostEvent(NativeBrowserControl::sActionQueue, event);
|
||||
::PL_PostEvent(NativeWrapperFactory::sActionQueue, event);
|
||||
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(NativeWrapperFactory::sActionQueue);
|
||||
} // PostEvent()
|
||||
|
||||
|
||||
void *util_PostSynchronousEvent(NativeBrowserControl * initContext, PLEvent * event)
|
||||
void *util_PostSynchronousEvent(NativeWrapperFactory * initContext, PLEvent * event)
|
||||
{
|
||||
void * voidResult = nsnull;
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(NativeWrapperFactory::sActionQueue);
|
||||
|
||||
voidResult = ::PL_PostSynchronousEvent(NativeBrowserControl::sActionQueue, event);
|
||||
voidResult = ::PL_PostSynchronousEvent(NativeWrapperFactory::sActionQueue, event);
|
||||
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(NativeWrapperFactory::sActionQueue);
|
||||
|
||||
return voidResult;
|
||||
} // PostSynchronousEvent()
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
#include "wcIBrowserContainer.h" // our BrowserContainer
|
||||
|
||||
#include "NativeWrapperFactory.h"
|
||||
|
||||
#include "ns_globals.h"
|
||||
|
||||
// Ashu
|
||||
@@ -72,20 +74,6 @@
|
||||
//
|
||||
|
||||
|
||||
class nsIProfile;
|
||||
class nsIProfileInternal;
|
||||
class nsIPref;
|
||||
class nsIAppShell;
|
||||
class NativeBrowserControl;
|
||||
|
||||
struct WebclientContext {
|
||||
nsIProfile *sProfile;
|
||||
nsIProfileInternal *sProfileInternal;
|
||||
nsIPref *sPrefs;
|
||||
nsIAppShell *sAppShell;
|
||||
ShareInitContext shareContext;
|
||||
};
|
||||
|
||||
enum {
|
||||
kEventQueueError = 1,
|
||||
kCreateWebShellError,
|
||||
|
||||
@@ -35,7 +35,7 @@ static PRBool rdf_inited = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIRDFContainerUtils> gRDFCU = nsnull;
|
||||
nsCOMPtr<nsIRDFService> gRDF = nsnull;
|
||||
nsCOMPtr<nsIBookmarksService> gBookmarks = nsnull; // PENDING(edburns): this should be in WebclientContext
|
||||
nsCOMPtr<nsIBookmarksService> gBookmarks = nsnull; // PENDING(edburns): this should be in NativeWrapperFactory
|
||||
nsCOMPtr<nsIRDFDataSource> gBookmarksDataSource = nsnull;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> kNC_BookmarksRoot = nsnull;
|
||||
|
||||
@@ -310,7 +310,7 @@ void util_ThrowExceptionToJava (JNIEnv * env, const char * message)
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
jclass excCls = env->FindClass("java/lang/Exception");
|
||||
jclass excCls = env->FindClass("java/lang/RuntimeException");
|
||||
|
||||
if (excCls == 0) { // Unable to find the exception class, give up.
|
||||
if (env->ExceptionOccurred())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: WrapperFactoryImplTest.java,v 1.2 2004-04-10 21:50:39 edburns%acm.org Exp $
|
||||
* $Id: WrapperFactoryImplTest.java,v 1.3 2004-04-15 22:58:08 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
@@ -68,11 +68,15 @@ public class WrapperFactoryImplTest extends WebclientTestCase {
|
||||
}
|
||||
|
||||
public void testGetNativeBrowserControl() throws Exception {
|
||||
assertTrue(false);
|
||||
/**
|
||||
WrapperFactoryImpl wrapper = new WrapperFactoryImpl();
|
||||
wrapper.initialize(getBrowserBinDir());
|
||||
BrowserControl bc = new BrowserControlImpl(wrapper);
|
||||
|
||||
assertTrue(-1 != wrapper.getNativeBrowserControl(bc));
|
||||
BrowserControlFactory.deleteBrowserControl(bc);
|
||||
**/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: D:\Projects\mozilla\MOZILLA_NIH\mozilla\dist\bin
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
|
||||
0[18692650]: WARNING: Error parsing GRE default preferences. Is this an old-style embedding app?, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/modules/libpref/src/nsPrefService.cpp, line 757
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: exiting
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: entering
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: exiting
|
||||
0[18692650]: PreferencesImpl_nativeStartup: entering
|
||||
0[18692650]: PreferencesImpl_nativeStartup: exiting
|
||||
0[18692650]: BookmarksImpl_nativeStartup: entering
|
||||
0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18692650]: BookmarksImpl_nativeStartup: exiting
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell create rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell spinup rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: exiting
|
||||
0[18692650]: BookmarksImpl_nativeShutdown: entering
|
||||
0[18692650]: BookmarksImpl_nativeShutdown: exiting
|
||||
0[18692650]: PreferencesImpl_nativeShutdown: entering
|
||||
0[18692650]: PreferencesImpl_nativeShutdown: exiting
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: entering
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: ShutDownCurrentProfile: rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: exiting
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: Spindown rv: 0
|
||||
0[18692650]: WARNING: nsExceptionService ignoring thread destruction after shutdown, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/xpcom/base/nsExceptionService.cpp, line 189
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: exiting
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppInitialize: entering
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: D:\Projects\mozilla\MOZILLA_NIH\mozilla\dist\bin
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
|
||||
0[18674240]: WARNING: Error parsing GRE default preferences. Is this an old-style embedding app?, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/modules/libpref/src/nsPrefService.cpp, line 757
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppInitialize: exiting
|
||||
0[18674240]: NativeBrowserControl_Init: Create UI Thread EventQueue: 0
|
||||
0[18674240]: NativeBrowserControl_Init: Get UI Thread EventQueue: 0
|
||||
0[18674240]: NativeBrowserControl_Init: get ActionQueue: 0
|
||||
0[18674240]: ProfileManagerImpl_nativeStartup: entering
|
||||
0[18674240]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
|
||||
0[18674240]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
|
||||
0[18674240]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
|
||||
0[18674240]: ProfileManagerImpl_nativeStartup: exiting
|
||||
0[18674240]: PreferencesImpl_nativeStartup: entering
|
||||
0[18674240]: PreferencesImpl_nativeStartup: exiting
|
||||
0[18674240]: BookmarksImpl_nativeStartup: entering
|
||||
0[18674240]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18674240]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18674240]: BookmarksImpl_nativeStartup: exiting
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppSetup: entering
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppSetup: AppShell create rv: 0
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppSetup: AppShell spinup rv: 0
|
||||
0[18674240]: WrapperFactoryImpl_nativeAppSetup: exiting
|
||||
0[18674240]: WARNING: NS_ENSURE_TRUE(mDocShell) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp, line 429
|
||||
0[18674240]: BookmarksImpl_nativeShutdown: entering
|
||||
0[18674240]: BookmarksImpl_nativeShutdown: exiting
|
||||
0[18674240]: PreferencesImpl_nativeShutdown: entering
|
||||
0[18674240]: PreferencesImpl_nativeShutdown: exiting
|
||||
0[18674240]: ProfileManagerImpl_nativeShutdown: entering
|
||||
0[18674240]: ProfileManagerImpl_nativeShutdown: ShutDownCurrentProfile: rv: 0
|
||||
0[18674240]: ProfileManagerImpl_nativeShutdown: exiting
|
||||
0[18674240]: WrapperFactoryImpl_nativeTerminate: entering
|
||||
0[18674240]: WrapperFactoryImpl_nativeTerminate: Spindown rv: 0
|
||||
0[18674240]: WARNING: nsExceptionService ignoring thread destruction after shutdown, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/xpcom/base/nsExceptionService.cpp, line 189
|
||||
0[18674240]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0
|
||||
0[18674240]: WrapperFactoryImpl_nativeTerminate: exiting
|
||||
0[18674240]: ###!!! ASSERTION: attempt to Exit() thread twice: 'Error', file d:/Projects/mozilla/MOZILLA_NIH/mozilla/xpcom/threads/nsThread.cpp, line 143
|
||||
|
||||
Reference in New Issue
Block a user