This checkin refactors who owns the nativeWebShell pointer. It used to

be WindowControl, and now it's BrowserControl.  I'm hoping this allows
  us to operate Webclient in a "headless" fashion.  For example, you can
  imagine a web-crawler app that leverages DOM.

A test/automated/src/test/NavigationTest.txt

- fodder for testcase

M build-tests.xml

- reformat

- add NavigationTest (fails)

M classes_spec/org/mozilla/webclient/ImplObject.java

- Refactoring: remove public ivars.  Make them private, provide
  accessor.

M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java

- Refactoring: remove public ivars.  Make them private, provide
  accessor.

- Remove dependence on WindowControl

- leverage new method on WrapperFactory: getNativeBrowserControl().

M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java

- Make BrowserControlImpl the owner of the nativeWebShell pointer.  I'd
  like to see if it's possible for webclient to operate "headless" for
  certain applications, therefore, you may not have a WindowControl
  instance, which used to own the nativeWebShell pointer.

M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java

- reformatting

- Software Practice: avoid downcasting to implementation class.  Since BrowserControlImpl is the owner of the nativeWebShell, but there
  is no mention of that in the public API, we modify the WrapperFactory
  contract to maintain a data structure of BrowserControl to
  nativeWebShell mappings.

- add native{Create,Destroy}BrowserControl(), which is called from
  ImplObjectNative.

M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java
M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java
M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java
M classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java
M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java

- refactoring for removing public ivars.

M classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java

- refactoring for removing public ivars.

- comment out nativeCreateInitContext temporarily

M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java

- implement new methods:

- add native{Create,Destroy}BrowserControl(), which is called from
  ImplObjectNative.

M classes_spec/org/mozilla/webclient/wrapper_nonnative/WrapperFactoryImpl.java

- remove vertigo test

M src_moz/ProfileManagerImpl.cpp

- shutdown the current profile

M src_moz/WrapperFactoryImpl.cpp

- Spinup and Spindown the Appshell

A test/automated/src/classes/org/mozilla/webclient/NavigationTest.java

- new test

M test/automated/src/test/BrowserControlFactoryTest_correct

- new test content
This commit is contained in:
edburns%acm.org 2004-03-05 15:34:25 +00:00
Родитель 3d299efb97
Коммит 01982f4835
18 изменённых файлов: 422 добавлений и 336 удалений

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -59,20 +59,13 @@ public abstract class ImplObject extends Object
// Relationship Instance Variables // Relationship Instance Variables
/**
* My ivars are public for fast access from subclasses in the wrapper_*
* packages.
*/
/** /**
* The BrowserControl to which I'm attached, used for locking and communication. * The BrowserControl to which I'm attached, used for locking and communication.
*/ */
public BrowserControl myBrowserControl = null; private BrowserControl myBrowserControl = null;
// //
@ -86,6 +79,10 @@ public ImplObject(BrowserControl yourBrowserControl)
myBrowserControl = yourBrowserControl; myBrowserControl = yourBrowserControl;
} }
public BrowserControl getBrowserControl() {
return myBrowserControl;
}
/** /**
* I know Java has automatic garbage collection and all, but explicitly * I know Java has automatic garbage collection and all, but explicitly

Просмотреть файл

@ -98,6 +98,7 @@ public BrowserControlImpl(WrapperFactory yourWrapper)
ParameterCheck.nonNull(yourWrapper); ParameterCheck.nonNull(yourWrapper);
wrapperFactory = yourWrapper; wrapperFactory = yourWrapper;
Assert.assert_it(-1 != wrapperFactory.getNativeContext());
} }
@ -168,7 +169,6 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
ParameterCheck.nonNull(interfaceName); ParameterCheck.nonNull(interfaceName);
Assert.assert_it(null != wrapperFactory); Assert.assert_it(null != wrapperFactory);
// wrapperFactory.throwExceptionIfNotInitialized();
// At some point, it has to come down to hard coded string names, // At some point, it has to come down to hard coded string names,
// right? Well, that point is here. There is an extensibility // right? Well, that point is here. There is an extensibility
@ -241,23 +241,6 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
return wrapperFactory.newImpl(interfaceName, this); return wrapperFactory.newImpl(interfaceName, this);
} }
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.1 2003-09-28 06:29:05 edburns%acm.org Exp $");
}
// ----VERTIGO_TEST_END
} // end of class BrowserControlImpl } // end of class BrowserControlImpl

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* *
* The contents of this file are subject to the Mozilla Public * The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file * License Version 1.1 (the "License"); you may not use this file
@ -29,11 +29,11 @@ package org.mozilla.webclient.impl;
import org.mozilla.webclient.BrowserControl; import org.mozilla.webclient.BrowserControl;
public interface WrapperFactory { public interface WrapperFactory {
public static String IMPL_NAME = "WrapperFactoryImpl"; public static String IMPL_NAME = "WrapperFactoryImpl";
public Object newImpl(String interfaceName, public Object newImpl(String interfaceName,
BrowserControl browserControl) throws ClassNotFoundException; BrowserControl browserControl) throws ClassNotFoundException;
/** /**
* *
@ -48,11 +48,23 @@ public interface WrapperFactory {
*/ */
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError; public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError;
public void verifyInitialized() throws IllegalStateException; public void verifyInitialized() throws IllegalStateException;
public void terminate() throws Exception; public void terminate() throws Exception;
public int getNativeContext(); public int getNativeContext();
/**
* <p>I would like this method to be on BrowserControl itself, but
* that would mean exposing native elements on the public java API.
* Therefore, the WrapperFactory needs to be able to return the
* native counterpart given a java BrowserControl.</p>
*
*/
public int getNativeBrowserControl(BrowserControl bc);
public void destroyNativeBrowserControl(BrowserControl bc);
} }

Просмотреть файл

@ -120,7 +120,7 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
BookmarkEntry bookmark) BookmarkEntry bookmark)
{ {
ParameterCheck.nonNull(bookmark); ParameterCheck.nonNull(bookmark);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
if (!(bookmark instanceof BookmarkEntryImpl)) { if (!(bookmark instanceof BookmarkEntryImpl)) {
throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()"); throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()");
@ -149,7 +149,7 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
public TreeModel getBookmarks() throws IllegalStateException public TreeModel getBookmarks() throws IllegalStateException
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
if (null == bookmarksTree) { if (null == bookmarksTree) {
int nativeBookmarks; int nativeBookmarks;
@ -173,8 +173,8 @@ public TreeModel getBookmarks() throws IllegalStateException
public void removeBookmark(BookmarkEntry bookmark) public void removeBookmark(BookmarkEntry bookmark)
{ {
ParameterCheck.nonNull(bookmark); ParameterCheck.nonNull(bookmark);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getPageInfo has not yet been implemented.\n"); throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getPageInfo has not yet been implemented.\n");
} }
@ -185,8 +185,8 @@ public BookmarkEntry newBookmarkEntry(String url)
getBookmarks(); getBookmarks();
int newNode; int newNode;
if (-1 != (newNode = nativeNewRDFNode(nativeWebShell, url, false))) { if (-1 != (newNode = nativeNewRDFNode(getNativeWebShell(), url, false))) {
result = new BookmarkEntryImpl(nativeWebShell, result = new BookmarkEntryImpl(getNativeWebShell(),
newNode, null); newNode, null);
// use put instead of setProperty for jdk1.1.x compatibility. // use put instead of setProperty for jdk1.1.x compatibility.
result.getProperties().put(BookmarkEntry.NAME, url); result.getProperties().put(BookmarkEntry.NAME, url);
@ -212,7 +212,7 @@ public BookmarkEntry newBookmarkFolder(String name)
BookmarkEntry result = null; BookmarkEntry result = null;
getBookmarks(); getBookmarks();
if (null == (result = new BookmarkEntryImpl(nativeWebShell, -1, null))) { if (null == (result = new BookmarkEntryImpl(getNativeWebShell(), -1, null))) {
throw new NullPointerException("Can't create bookmark folder for: " + throw new NullPointerException("Can't create bookmark folder for: " +
name); name);
} }

Просмотреть файл

@ -92,21 +92,21 @@ public CurrentPageImpl(WrapperFactory yourFactory,
public void copyCurrentSelectionToSystemClipboard() public void copyCurrentSelectionToSystemClipboard()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeCopyCurrentSelectionToSystemClipboard(nativeWebShell); nativeCopyCurrentSelectionToSystemClipboard(getNativeWebShell());
} }
} }
public Selection getSelection() { public Selection getSelection() {
Selection selection = new SelectionImpl(); Selection selection = new SelectionImpl();
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeGetSelection(nativeWebShell, selection); nativeGetSelection(getNativeWebShell(), selection);
} }
return selection; return selection;
@ -119,55 +119,55 @@ public void highlightSelection(Selection selection) {
int startOffset = selection.getStartOffset(); int startOffset = selection.getStartOffset();
int endOffset = selection.getEndOffset(); int endOffset = selection.getEndOffset();
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeHighlightSelection(nativeWebShell, startContainer, endContainer, startOffset, endOffset); nativeHighlightSelection(getNativeWebShell(), startContainer, endContainer, startOffset, endOffset);
} }
} }
} }
public void clearAllSelections() { public void clearAllSelections() {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeClearAllSelections(nativeWebShell); nativeClearAllSelections(getNativeWebShell());
} }
} }
public void findInPage(String stringToFind, boolean forward, boolean matchCase) public void findInPage(String stringToFind, boolean forward, boolean matchCase)
{ {
ParameterCheck.nonNull(stringToFind); ParameterCheck.nonNull(stringToFind);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeFindInPage(nativeWebShell, stringToFind, forward, matchCase); nativeFindInPage(getNativeWebShell(), stringToFind, forward, matchCase);
} }
} }
public void findNextInPage() public void findNextInPage()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeFindNextInPage(nativeWebShell); nativeFindNextInPage(getNativeWebShell());
} }
} }
public String getCurrentURL() public String getCurrentURL()
{ {
String result = null; String result = null;
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeGetCurrentURL(nativeWebShell); result = nativeGetCurrentURL(getNativeWebShell());
} }
return result; return result;
} }
public Document getDOM() public Document getDOM()
{ {
Document result = nativeGetDOM(nativeWebShell); Document result = nativeGetDOM(getNativeWebShell());
return result; return result;
} }
@ -175,8 +175,8 @@ public Properties getPageInfo()
{ {
Properties result = null; Properties result = null;
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
result = nativeGetPageInfo(nativeWebShell); result = nativeGetPageInfo(getNativeWebShell());
} }
return result; return result;
*/ */
@ -188,7 +188,7 @@ public Properties getPageInfo()
public String getSource() public String getSource()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
String HTMLContent = new String(); String HTMLContent = new String();
String currURL = getCurrentURL(); String currURL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + currURL); System.out.println("\nThe Current URL is -- " + currURL);
@ -219,7 +219,7 @@ public String getSource()
public byte [] getSourceBytes() public byte [] getSourceBytes()
{ {
byte [] result = null; byte [] result = null;
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
String HTMLContent = new String(); String HTMLContent = new String();
@ -251,37 +251,37 @@ public byte [] getSourceBytes()
public void resetFind() public void resetFind()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeResetFind(nativeWebShell); nativeResetFind(getNativeWebShell());
} }
} }
public void selectAll() public void selectAll()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeSelectAll(nativeWebShell); nativeSelectAll(getNativeWebShell());
} }
} }
public void print() public void print()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativePrint(nativeWebShell); nativePrint(getNativeWebShell());
} }
} }
public void printPreview(boolean preview) public void printPreview(boolean preview)
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativePrintPreview(nativeWebShell, preview); nativePrintPreview(getNativeWebShell(), preview);
} }
} }
@ -332,7 +332,7 @@ public static void main(String [] args)
Assert.setEnabled(true); Assert.setEnabled(true);
Log.setApplicationName("CurrentPageImpl"); Log.setApplicationName("CurrentPageImpl");
Log.setApplicationVersion("0.0"); Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $"); Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
} }

Просмотреть файл

@ -78,7 +78,7 @@ public EventRegistrationImpl(WrapperFactory yourFactory,
// pull out the NativeEventThread from the WindowControl // pull out the NativeEventThread from the WindowControl
try { try {
WindowControl windowControl = (WindowControl) WindowControl windowControl = (WindowControl)
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME); getBrowserControl().queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
if (windowControl instanceof WindowControlImpl) { if (windowControl instanceof WindowControlImpl) {
nativeEventThread = nativeEventThread =
@ -120,8 +120,8 @@ public void delete()
public void addDocumentLoadListener(DocumentLoadListener listener) public void addDocumentLoadListener(DocumentLoadListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -132,7 +132,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.addListener(listenerWrapper); nativeEventThread.addListener(listenerWrapper);
} }
} }
@ -140,8 +140,8 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
public void removeDocumentLoadListener(DocumentLoadListener listener) public void removeDocumentLoadListener(DocumentLoadListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -152,7 +152,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.removeListener(listenerWrapper); nativeEventThread.removeListener(listenerWrapper);
} }
} }
@ -160,8 +160,8 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
public void addMouseListener(MouseListener listener) public void addMouseListener(MouseListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -185,7 +185,7 @@ public void addMouseListener(MouseListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.addListener(listenerWrapper); nativeEventThread.addListener(listenerWrapper);
} }
} }
@ -193,8 +193,8 @@ public void addMouseListener(MouseListener listener)
public void removeMouseListener(MouseListener listener) public void removeMouseListener(MouseListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -213,7 +213,7 @@ public void removeMouseListener(MouseListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.removeListener(listenerWrapper); nativeEventThread.removeListener(listenerWrapper);
} }
} }
@ -221,8 +221,8 @@ public void removeMouseListener(MouseListener listener)
public void addNewWindowListener(NewWindowListener listener) public void addNewWindowListener(NewWindowListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -233,7 +233,7 @@ public void addNewWindowListener(NewWindowListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.addListener(listenerWrapper); nativeEventThread.addListener(listenerWrapper);
} }
} }
@ -241,8 +241,8 @@ public void addNewWindowListener(NewWindowListener listener)
public void removeNewWindowListener(NewWindowListener listener) public void removeNewWindowListener(NewWindowListener listener)
{ {
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(null != nativeEventThread); Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener); ParameterCheck.nonNull(listener);
@ -253,7 +253,7 @@ public void removeNewWindowListener(NewWindowListener listener)
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory."); throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeEventThread.removeListener(listenerWrapper); nativeEventThread.removeListener(listenerWrapper);
} }
} }
@ -271,7 +271,7 @@ public static void main(String [] args)
Log.setApplicationName("EventRegistrationImpl"); Log.setApplicationName("EventRegistrationImpl");
Log.setApplicationVersion("0.0"); Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $"); Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
try { try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]); org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

Просмотреть файл

@ -76,34 +76,34 @@ public HistoryImpl(WrapperFactory yourFactory,
public void back() public void back()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeBack(nativeWebShell); nativeBack(getNativeWebShell());
} }
} }
public boolean canBack() public boolean canBack()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
boolean result = false; boolean result = false;
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeCanBack(nativeWebShell); result = nativeCanBack(getNativeWebShell());
} }
return result; return result;
} }
public HistoryEntry [] getBackList() public HistoryEntry [] getBackList()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
HistoryEntry [] result = null; HistoryEntry [] result = null;
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
result = nativeGetBackList(nativeWebShell); result = nativeGetBackList(getNativeWebShell());
} }
return result; return result;
*/ */
@ -113,11 +113,11 @@ public HistoryEntry [] getBackList()
public void clearHistory() public void clearHistory()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
nativeClearHistory(nativeWebShell); nativeClearHistory(getNativeWebShell());
} }
*/ */
@ -128,22 +128,22 @@ public void clearHistory()
public void forward() public void forward()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeForward(nativeWebShell); nativeForward(getNativeWebShell());
} }
} }
public boolean canForward() public boolean canForward()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
boolean result = false; boolean result = false;
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeCanForward(nativeWebShell); result = nativeCanForward(getNativeWebShell());
} }
return result; return result;
} }
@ -151,11 +151,11 @@ public boolean canForward()
public HistoryEntry [] getForwardList() public HistoryEntry [] getForwardList()
{ {
HistoryEntry [] result = null; HistoryEntry [] result = null;
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
result = nativeGetForwardList(nativeWebShell); result = nativeGetForwardList(getNativeWebShell());
} }
return result; return result;
*/ */
@ -166,11 +166,11 @@ public HistoryEntry [] getForwardList()
public HistoryEntry [] getHistory() public HistoryEntry [] getHistory()
{ {
HistoryEntry [] result = null; HistoryEntry [] result = null;
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
result = nativeGetHistory(nativeWebShell); result = nativeGetHistory(getNativeWebShell());
} }
return result; return result;
*/ */
@ -181,12 +181,12 @@ public HistoryEntry [] getHistory()
public HistoryEntry getHistoryEntry(int historyIndex) public HistoryEntry getHistoryEntry(int historyIndex)
{ {
ParameterCheck.noLessThan(historyIndex, 0); ParameterCheck.noLessThan(historyIndex, 0);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
HistoryEntry result = null; HistoryEntry result = null;
/* synchronized(myBrowserControl) { /* synchronized(getBrowserControl()) {
result = nativeGetHistoryEntry(nativeWebShell, historyIndex); result = nativeGetHistoryEntry(getNativeWebShell(), historyIndex);
} }
return result; return result;
*/ */
@ -196,12 +196,12 @@ public HistoryEntry getHistoryEntry(int historyIndex)
public int getCurrentHistoryIndex() public int getCurrentHistoryIndex()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
int result = -1; int result = -1;
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeGetCurrentHistoryIndex(nativeWebShell); result = nativeGetCurrentHistoryIndex(getNativeWebShell());
} }
return result; return result;
} }
@ -209,22 +209,22 @@ public int getCurrentHistoryIndex()
public void setCurrentHistoryIndex(int historyIndex) public void setCurrentHistoryIndex(int historyIndex)
{ {
ParameterCheck.noLessThan(historyIndex, 0); ParameterCheck.noLessThan(historyIndex, 0);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeSetCurrentHistoryIndex(nativeWebShell, historyIndex); nativeSetCurrentHistoryIndex(getNativeWebShell(), historyIndex);
} }
} }
public int getHistoryLength() public int getHistoryLength()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
int result = -1; int result = -1;
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeGetHistoryLength(nativeWebShell); result = nativeGetHistoryLength(getNativeWebShell());
} }
return result; return result;
} }
@ -232,12 +232,12 @@ public int getHistoryLength()
public String getURLForIndex(int historyIndex) public String getURLForIndex(int historyIndex)
{ {
ParameterCheck.noLessThan(historyIndex, 0); ParameterCheck.noLessThan(historyIndex, 0);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
String result = null; String result = null;
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
result = nativeGetURLForIndex(nativeWebShell, historyIndex); result = nativeGetURLForIndex(getNativeWebShell(), historyIndex);
} }
return result; return result;
} }
@ -246,7 +246,7 @@ public String getURLForIndex(int historyIndex)
// Native methods // Native methods
// //
public native void nativeBack(int nativeWebShell); public native void nativeBack(int webShellPtr);
public native boolean nativeCanBack(int webShellPtr); public native boolean nativeCanBack(int webShellPtr);
@ -283,7 +283,7 @@ public static void main(String [] args)
Assert.setEnabled(true); Assert.setEnabled(true);
Log.setApplicationName("HistoryImpl"); Log.setApplicationName("HistoryImpl");
Log.setApplicationVersion("0.0"); Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $"); Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
} }

Просмотреть файл

@ -36,7 +36,6 @@ import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.ImplObject; import org.mozilla.webclient.ImplObject;
import org.mozilla.webclient.impl.WrapperFactory; import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.BrowserControl; import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WindowControl;
/** /**
@ -67,61 +66,16 @@ public abstract class ImplObjectNative extends ImplObject
// Relationship Instance Variables // Relationship Instance Variables
/** private WrapperFactory myFactory = null;
* My ivars are public for fast access from subclasses in the wrapper_* private int nativeWebShell = -1;
* packages.
*/
/**
* a handle to the actual mozilla webShell, owned, allocated, and
* released by WindowControl
*/
public int nativeWebShell = -1;
protected WrapperFactory myFactory = null;
// //
// Constructors and Initializers // Constructors and Initializers
// //
public ImplObjectNative(WrapperFactory yourFactory, public ImplObjectNative(WrapperFactory yourFactory,
BrowserControl yourBrowserControl) BrowserControl yourBrowserControl) {
{
super(yourBrowserControl);
myFactory = yourFactory;
// If we're a WindowControlImpl instance, we can't ask ourself for
// the nativeWebShell, since it hasn't yet been created!
if (!(this instanceof WindowControlImpl)) {
// save the native webshell ptr
try {
WindowControl windowControl = (WindowControl)
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
nativeWebShell = windowControl.getNativeWebShell();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
/**
* This constructor doesn't initialize the nativeWebshell ivar
*/
public ImplObjectNative(WrapperFactory yourFactory,
BrowserControl yourBrowserControl,
boolean notUsed)
{
super(yourBrowserControl); super(yourBrowserControl);
myFactory = yourFactory; myFactory = yourFactory;
} }
@ -130,9 +84,6 @@ public ImplObjectNative(WrapperFactory yourFactory,
* Note how we call super.delete() at the end. THIS IS VERY IMPORTANT. <P> * Note how we call super.delete() at the end. THIS IS VERY IMPORTANT. <P>
* Also, note how we don't de-allocate nativeWebShell, that is done in
* the class that owns the nativeWebShell reference, WindowControlImpl. <P>
* ImplObjectNative subclasses that further override delete() are <P> * ImplObjectNative subclasses that further override delete() are <P>
<CODE><PRE> <CODE><PRE>
@ -149,8 +100,7 @@ WindowControlImpl.java
public void delete() public void delete()
{ {
nativeWebShell = -1; getWrapperFactory().destroyNativeBrowserControl(getBrowserControl());
System.out.println("ImplObjectNative.delete()");
super.delete(); super.delete();
} }
@ -158,5 +108,19 @@ protected WrapperFactory getWrapperFactory() {
return myFactory; return myFactory;
} }
/**
* <p>We do this lazily to allow for applications that don't use any
* per-window features. </p>
*/
protected int getNativeWebShell() {
if (-1 == nativeWebShell) {
nativeWebShell =
getWrapperFactory().getNativeBrowserControl(getBrowserControl());
}
return nativeWebShell;
}
} // end of class ImplObject } // end of class ImplObject

Просмотреть файл

@ -62,8 +62,7 @@ public class NavigationImpl extends ImplObjectNative implements Navigation2
// //
public NavigationImpl(WrapperFactory yourFactory, public NavigationImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl) BrowserControl yourBrowserControl) {
{
super(yourFactory, yourBrowserControl); super(yourFactory, yourBrowserControl);
} }
@ -82,11 +81,11 @@ public NavigationImpl(WrapperFactory yourFactory,
public void loadURL(String absoluteURL) public void loadURL(String absoluteURL)
{ {
ParameterCheck.nonNull(absoluteURL); ParameterCheck.nonNull(absoluteURL);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeLoadURL(nativeWebShell, absoluteURL); nativeLoadURL(getNativeWebShell(), absoluteURL);
} }
} }
@ -102,11 +101,11 @@ public void loadFromStream(InputStream stream, String uri,
" is out of range. It is should be either -1 or greater than 0."); " is out of range. It is should be either -1 or greater than 0.");
} }
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeLoadFromStream(nativeWebShell, stream, nativeLoadFromStream(getNativeWebShell(), stream,
uri, contentType, contentLength, uri, contentType, contentLength,
loadInfo); loadInfo);
} }
@ -115,32 +114,32 @@ public void loadFromStream(InputStream stream, String uri,
public void refresh(long loadFlags) public void refresh(long loadFlags)
{ {
ParameterCheck.noLessThan(loadFlags, 0); ParameterCheck.noLessThan(loadFlags, 0);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeRefresh(nativeWebShell, loadFlags); nativeRefresh(getNativeWebShell(), loadFlags);
} }
} }
public void stop() public void stop()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeStop(nativeWebShell); nativeStop(getNativeWebShell());
} }
} }
public void setPrompt(Prompt yourPrompt) public void setPrompt(Prompt yourPrompt)
{ {
ParameterCheck.nonNull(yourPrompt); ParameterCheck.nonNull(yourPrompt);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeSetPrompt(nativeWebShell, yourPrompt); nativeSetPrompt(getNativeWebShell(), yourPrompt);
} }
} }
@ -155,8 +154,8 @@ public void post(String absoluteUrl,
String postHeaders) String postHeaders)
{ {
ParameterCheck.nonNull(absoluteUrl); ParameterCheck.nonNull(absoluteUrl);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
int postDataLength = 0; int postDataLength = 0;
int postHeadersLength = 0; int postHeadersLength = 0;
@ -174,8 +173,8 @@ public void post(String absoluteUrl,
postHeadersLength = postHeaders.length(); postHeadersLength = postHeaders.length();
} }
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativePost(nativeWebShell, nativePost(getNativeWebShell(),
absoluteUrl, absoluteUrl,
target, target,
postDataLength, postDataLength,
@ -224,7 +223,7 @@ public static void main(String [] args)
Log.setApplicationName("NavigationImpl"); Log.setApplicationName("NavigationImpl");
Log.setApplicationVersion("0.0"); Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $"); Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
try { try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]); org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

Просмотреть файл

@ -61,7 +61,7 @@ protected NativeEventThread eventThread = null;
public WindowControlImpl(WrapperFactory yourFactory, public WindowControlImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl) BrowserControl yourBrowserControl)
{ {
super(yourFactory, yourBrowserControl, false); super(yourFactory, yourBrowserControl);
} }
/** /**
@ -77,7 +77,6 @@ public void delete()
Assert.assert_it(null != eventThread, "eventThread shouldn't be null at delete time"); Assert.assert_it(null != eventThread, "eventThread shouldn't be null at delete time");
eventThread.delete(); eventThread.delete();
eventThread = null; eventThread = null;
nativeWebShell = -1;
} }
// //
@ -106,11 +105,11 @@ NativeEventThread getNativeEventThread()
public void setBounds(Rectangle newBounds) public void setBounds(Rectangle newBounds)
{ {
ParameterCheck.nonNull(newBounds); ParameterCheck.nonNull(newBounds);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != nativeWebShell); Assert.assert_it(-1 != getNativeWebShell());
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeSetBounds(nativeWebShell, newBounds.x, newBounds.y, nativeSetBounds(getNativeWebShell(), newBounds.x, newBounds.y,
newBounds.width, newBounds.height); newBounds.width, newBounds.height);
} }
} }
@ -119,16 +118,18 @@ public void createWindow(int nativeWindow, Rectangle bounds)
{ {
ParameterCheck.greaterThan(nativeWindow, 0); ParameterCheck.greaterThan(nativeWindow, 0);
ParameterCheck.nonNull(bounds); ParameterCheck.nonNull(bounds);
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
synchronized(this) { synchronized(this) {
nativeWebShell = nativeCreateInitContext(nativeWindow, bounds.x, /**
getNativeWebShell() = nativeCreateInitContext(nativeWindow, bounds.x,
bounds.y, bounds.width, bounds.y, bounds.width,
bounds.height, myBrowserControl); bounds.height, getBrowserControl());
**/
eventThread = new NativeEventThread("EventThread-" + eventThread = new NativeEventThread("EventThread-" +
nativeWebShell, getNativeWebShell(),
myBrowserControl); getBrowserControl());
// IMPORTANT: the nativeEventThread initializes all the // IMPORTANT: the nativeEventThread initializes all the
// native browser stuff, then sends us notify(). // native browser stuff, then sends us notify().
@ -146,23 +147,23 @@ public void createWindow(int nativeWindow, Rectangle bounds)
public int getNativeWebShell() public int getNativeWebShell()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
return nativeWebShell; return getNativeWebShell();
} }
public void moveWindowTo(int x, int y) public void moveWindowTo(int x, int y)
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeMoveWindowTo(nativeWebShell, x, y); nativeMoveWindowTo(getNativeWebShell(), x, y);
} }
} }
public void removeFocus() public void removeFocus()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::removeFocus has not yet been implemented.\n"); throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::removeFocus has not yet been implemented.\n");
@ -170,25 +171,25 @@ public void removeFocus()
public void repaint(boolean forceRepaint) public void repaint(boolean forceRepaint)
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeRepaint(nativeWebShell, forceRepaint); nativeRepaint(getNativeWebShell(), forceRepaint);
} }
} }
public void setVisible(boolean newState) public void setVisible(boolean newState)
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
synchronized(myBrowserControl) { synchronized(getBrowserControl()) {
nativeSetVisible(nativeWebShell, newState); nativeSetVisible(getNativeWebShell(), newState);
} }
} }
public void setFocus() public void setFocus()
{ {
myFactory.verifyInitialized(); getWrapperFactory().verifyInitialized();
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::setFocus has not yet been implemented.\n"); throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::setFocus has not yet been implemented.\n");
} }
@ -217,7 +218,7 @@ public native void nativeSetBounds(int webShellPtr, int x, int y,
*/ */
public native int nativeCreateInitContext(int nativeWindow, public native int nativeCreateInitContext(int nativeWindow,
int x, int y, int width, int height, BrowserControl myBrowserControlImpl); int x, int y, int width, int height, BrowserControl BrowserControlImpl);
public native void nativeDestroyInitContext(int nativeWindow); public native void nativeDestroyInitContext(int nativeWindow);
@ -244,7 +245,7 @@ public static void main(String [] args)
Log.setApplicationName("WindowControlImpl"); Log.setApplicationName("WindowControlImpl");
Log.setApplicationVersion("0.0"); Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.1 2003-09-28 06:29:07 edburns%acm.org Exp $"); Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
try { try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]); org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

Просмотреть файл

@ -35,6 +35,9 @@ import org.mozilla.webclient.ImplObject;
import org.mozilla.webclient.impl.WrapperFactory; import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.impl.Service; import org.mozilla.webclient.impl.Service;
import java.util.HashMap;
import java.util.Map;
public class WrapperFactoryImpl extends Object implements WrapperFactory public class WrapperFactoryImpl extends Object implements WrapperFactory
{ {
// //
@ -54,6 +57,14 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory
protected String platformCanvasClassName = null; protected String platformCanvasClassName = null;
protected boolean initialized = false; protected boolean initialized = false;
protected int nativeContext = -1; protected int nativeContext = -1;
/**
* <p>keys: BrowserControl instances</p>
*
* <p>values: the native counterpart to that BrowserControl
* instance, as an Integer.</p>
*
*/
protected Map nativeBrowserControls = null;
// Relationship Instance Variables // Relationship Instance Variables
@ -84,6 +95,7 @@ protected ProfileManager profileManager = null;
public WrapperFactoryImpl() public WrapperFactoryImpl()
{ {
super(); super();
nativeBrowserControls = new HashMap();
} }
@ -156,21 +168,15 @@ public Object newImpl(String interfaceName,
result = new EventRegistrationImpl(this, browserControl); result = new EventRegistrationImpl(this, browserControl);
} }
if (BrowserControl.BOOKMARKS_NAME == interfaceName) { if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
if (null == bookmarks) { Assert.assert_it(null != bookmarks);
bookmarks = new BookmarksImpl(this);
}
result = bookmarks; result = bookmarks;
} }
if (BrowserControl.PREFERENCES_NAME == interfaceName) { if (BrowserControl.PREFERENCES_NAME == interfaceName) {
if (null == prefs) { Assert.assert_it(null != prefs);
prefs = new PreferencesImpl(this);
}
result = prefs; result = prefs;
} }
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) { if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
if (null == profileManager) { Assert.assert_it(null != profileManager);
profileManager = new ProfileManagerImpl(this);
}
result = profileManager; result = profileManager;
} }
} }
@ -251,6 +257,39 @@ public int getNativeContext() {
return nativeContext; return nativeContext;
} }
public int getNativeBrowserControl(BrowserControl bc) {
verifyInitialized();
Integer result = null;
synchronized(this) {
if (null == (result = (Integer) nativeBrowserControls.get(bc))) {
try {
result = new Integer(nativeCreateBrowserControl(nativeContext));
nativeBrowserControls.put(bc, result);
}
catch (Exception e) {
result = new Integer(-1);
}
}
}
return result.intValue();
}
public void destroyNativeBrowserControl(BrowserControl bc) {
verifyInitialized();
Integer result = null;
synchronized(this) {
if (null != (result = (Integer) nativeBrowserControls.get(bc))) {
try {
nativeDestroyBrowserControl(nativeContext, result.intValue());
}
catch (Exception e) {
}
}
}
}
// //
// helper methods // helper methods
// //
@ -289,12 +328,12 @@ protected String getPlatformCanvasClassName()
/** /**
* This is called only once, at the very beginning of program execution. * <p>This is called only once, at the very beginning of program execution.
* This method allows the native code to handle ONE TIME initialization * This method allows the native code to handle ONE TIME initialization
* tasks. Per-window initialization tasks are handled in the * tasks. Per-window initialization tasks are handled in
* WindowControlImpl native methods. <P> * {@link #nativeCreateBrowserControl}. </p>
* For mozilla, this means initializing XPCOM. * <p>For mozilla, this means initializing XPCOM.</p>
*/ */
@ -330,4 +369,19 @@ native void nativeTerminate(int nativeContext) throws Exception;
native boolean nativeDoesImplement(String interfaceName); native boolean nativeDoesImplement(String interfaceName);
/**
* <p>The one and only entry point to do per-window initialization.</p>
*/
native int nativeCreateBrowserControl(int nativeContext) throws Exception;
/*
* <p>The one and only de-allocater for the nativeBrowserControl</p>
*/
native int nativeDestroyBrowserControl(int nativeContext,
int nativeBrowserControl) throws Exception;
} // end of class WrapperFactoryImpl } // end of class WrapperFactoryImpl

Просмотреть файл

@ -153,23 +153,4 @@ public void terminate() throws Exception
System.out.println("\n\n\n +++++ You should Never have reached Here - in terminate +++++ \n\n\n"); System.out.println("\n\n\n +++++ You should Never have reached Here - in terminate +++++ \n\n\n");
} }
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
WrapperFactory me = new WrapperFactoryImpl();
Log.setApplicationName("WrapperFactoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.1 2001-07-27 21:01:13 ashuk%eng.sun.com Exp $");
}
// ----VERTIGO_TEST_END
} // end of class WrapperFactoryImpl } // end of class WrapperFactoryImpl

Просмотреть файл

@ -150,6 +150,13 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
PR_ASSERT(wcContext); PR_ASSERT(wcContext);
nsresult rv = NS_OK;
rv =
wcContext->sProfile->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("ProfileManagerImpl_nativeShutdown: ShutDownCurrentProfile: rv: %d\n", rv));
NS_RELEASE(wcContext->sProfile); NS_RELEASE(wcContext->sProfile);
wcContext->sProfile = nsnull; wcContext->sProfile = nsnull;
NS_RELEASE(wcContext->sProfileInternal); NS_RELEASE(wcContext->sProfileInternal);

Просмотреть файл

@ -180,10 +180,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetu
return; return;
} }
/************* PENDING(edburns): fix this when someone replies to my
* 20030915 post to n.p.m.embedding
// appshell // appshell
// XXX startup appshell service? // XXX startup appshell service?
// XXX create offscreen window for appshell service? // XXX create offscreen window for appshell service?
@ -218,8 +214,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetu
"Failed to Spinup AppShell"); "Failed to Spinup AppShell");
return; return;
} }
****/
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("WrapperFactoryImpl_nativeAppSetup: exiting\n")); ("WrapperFactoryImpl_nativeAppSetup: exiting\n"));
@ -238,12 +232,15 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeTermina
PR_ASSERT(wcContext); PR_ASSERT(wcContext);
/********* PENDING(edburns): fix this when the above appshell logic if (wcContext->sAppShell) {
is fixed rv = wcContext->sAppShell->Spindown();
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("WrapperFactoryImpl_nativeTerminate: Spindown rv: %d\n",
rv));
NS_RELEASE(wcContext->sAppShell); NS_RELEASE(wcContext->sAppShell);
wcContext->sAppShell = nsnull; wcContext->sAppShell = nsnull;
***/ }
PR_ASSERT(nsnull == wcContext->sProfile); PR_ASSERT(nsnull == wcContext->sProfile);
PR_ASSERT(nsnull == wcContext->sProfileInternal); PR_ASSERT(nsnull == wcContext->sProfileInternal);
@ -294,3 +291,13 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDoesImp
return result; return result;
} }
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeCreateBrowserControl
(JNIEnv *env, jobject obj, jint nativeContext) {
return -1;
}
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDestroyBrowserControl
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeBrowserControl) {
return -1;
}

Просмотреть файл

@ -0,0 +1,74 @@
/*
* $Id: NavigationTest.java,v 1.1 2004-03-05 15:34:24 edburns%acm.org Exp $
*/
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Sun
* Microsystems, Inc. Portions created by Sun are
* Copyright (C) 1999 Sun Microsystems, Inc. All
* Rights Reserved.
*
* Contributor(s): Ed Burns &lt;edburns@acm.org&gt;
*/
package org.mozilla.webclient;
import junit.framework.TestSuite;
import junit.framework.Test;
import java.util.Enumeration;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import java.io.File;
// NavigationTest.java
public class NavigationTest extends WebclientTestCase {
public NavigationTest(String name) {
super(name);
}
public static Test suite() {
return (new TestSuite(NavigationTest.class));
}
//
// Constants
//
//
// Testcases
//
public void testNavigation() throws Exception {
BrowserControl firstBrowserControl = null;
BrowserControlFactory.setAppData(getBrowserBinDir());
firstBrowserControl = BrowserControlFactory.newBrowserControl();
assertNotNull(firstBrowserControl);
Navigation nav = (Navigation)
firstBrowserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
assertNotNull(nav);
File testPage = new File(getBrowserBinDir(),
"../../java/webclient/test/automated/src/test/NavigationTest.txt");
System.out.println("Loading url: " + testPage.toURL().toString());
nav.loadURL(testPage.toURL().toString());
}
}

Просмотреть файл

@ -1,27 +1,33 @@
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: entering 0[18692650]: WrapperFactoryImpl_nativeAppInitialize: entering
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: /home/edburns/Projects/mozilla/MOZILLA_1_4/mozilla/dist/bin 0[18692650]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: D:\Projects\mozilla\MOZILLA_NIH\mozilla\dist\bin
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0 0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding 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
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: exiting 0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
1024[80fc498]: ProfileManagerImpl_nativeStartup: entering 0[18692650]: WrapperFactoryImpl_nativeAppInitialize: exiting
1024[80fc498]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0 0[18692650]: ProfileManagerImpl_nativeStartup: entering
1024[80fc498]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0 0[18692650]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
1024[80fc498]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0 0[18692650]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
1024[80fc498]: ProfileManagerImpl_nativeStartup: exiting 0[18692650]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
1024[80fc498]: PreferencesImpl_nativeStartup: entering 0[18692650]: ProfileManagerImpl_nativeStartup: exiting
1024[80fc498]: PreferencesImpl_nativeStartup: exiting 0[18692650]: PreferencesImpl_nativeStartup: entering
1024[80fc498]: BookmarksImpl_nativeStartup: entering 0[18692650]: PreferencesImpl_nativeStartup: exiting
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188 0[18692650]: BookmarksImpl_nativeStartup: entering
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188 0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
1024[80fc498]: BookmarksImpl_nativeStartup: exiting 0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: entering 0[18692650]: BookmarksImpl_nativeStartup: exiting
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: exiting 0[18692650]: WrapperFactoryImpl_nativeAppSetup: entering
1024[80fc498]: BookmarksImpl_nativeShutdown: entering 0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell create rv: 0
1024[80fc498]: BookmarksImpl_nativeShutdown: exiting 0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell spinup rv: 0
1024[80fc498]: PreferencesImpl_nativeShutdown: entering 0[18692650]: WrapperFactoryImpl_nativeAppSetup: exiting
1024[80fc498]: PreferencesImpl_nativeShutdown: exiting 0[18692650]: BookmarksImpl_nativeShutdown: entering
1024[80fc498]: ProfileManagerImpl_nativeShutdown: entering 0[18692650]: BookmarksImpl_nativeShutdown: exiting
1024[80fc498]: ProfileManagerImpl_nativeShutdown: exiting 0[18692650]: PreferencesImpl_nativeShutdown: entering
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: entering 0[18692650]: PreferencesImpl_nativeShutdown: exiting
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0 0[18692650]: ProfileManagerImpl_nativeShutdown: entering
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: exiting 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,0 +1 @@
This test file is for the NavigationTest.