diff --git a/build.sh b/build.sh index 6d2ffaf..ea4a70f 100644 --- a/build.sh +++ b/build.sh @@ -87,9 +87,9 @@ else fi if [ -z "${GECKO_INCLUDES}" -a -z "${GECKO_LIBS}" ]; then - if [ x`pkg-config --exists mozilla-xpcom && echo YES` = "xYES" ]; then - GECKO_INCLUDES=`pkg-config --cflags mozilla-xpcom` - GECKO_LIBS=`pkg-config --libs mozilla-xpcom` + if [ x`pkg-config --exists firefox-xpcom && echo YES` = "xYES" ]; then + GECKO_INCLUDES=`pkg-config --cflags firefox-xpcom` + GECKO_LIBS=`pkg-config --libs firefox-xpcom` export GECKO_INCLUDES export GECKO_LIBS MAKE_MOZILLA=make_mozilla diff --git a/make_linux.mak b/make_linux.mak index 82d1dbd..054e1ab 100644 --- a/make_linux.mak +++ b/make_linux.mak @@ -202,7 +202,7 @@ gnome_stats.o: gnome_stats.c gnome_stats.h # # Mozilla lib # -make_mozilla:$(MOZILLA_LIB) $(PROFILE14_LIB) $(PROFILE17_LIB) $(PROFILE18_LIB) +make_mozilla:$(MOZILLA_LIB) $(MOZILLA_LIB): $(MOZILLA_OBJECTS) $(CXX) -o $(MOZILLA_LIB) $(MOZILLA_OBJECTS) $(MOZILLALIBS) ${GECKO_LIBS} @@ -220,22 +220,22 @@ xpcom_stats.o: xpcom_stats.cpp $(CXX) $(MOZILLACFLAGS) ${GECKO_INCLUDES} -c xpcom_stats.cpp $(PROFILE14_OBJECTS): xpcom_profile.cpp - $(CXX) -o $(PROFILE14_OBJECTS) $(MOZILLACFLAGS) ${PROFILE14_INCLUDES} -c xpcom_profile.cpp + $(CXX) -o $(PROFILE14_OBJECTS) $(MOZILLACFLAGS) ${PROFILE14_INCLUDES} ${GECKO_INCLUDES} -c xpcom_profile.cpp $(PROFILE17_OBJECTS): xpcom_profile.cpp - $(CXX) -o $(PROFILE17_OBJECTS) $(MOZILLACFLAGS) ${PROFILE17_INCLUDES} -c xpcom_profile.cpp + $(CXX) -o $(PROFILE17_OBJECTS) $(MOZILLACFLAGS) ${PROFILE17_INCLUDES} ${GECKO_INCLUDES} -c xpcom_profile.cpp $(PROFILE18_OBJECTS): xpcom_profile.cpp - $(CXX) -o $(PROFILE18_OBJECTS) $(MOZILLACFLAGS) ${PROFILE18_INCLUDES} -c xpcom_profile.cpp + $(CXX) -o $(PROFILE18_OBJECTS) $(MOZILLACFLAGS) ${PROFILE18_INCLUDES} ${GECKO_INCLUDES} -c xpcom_profile.cpp $(PROFILE14_LIB): $(PROFILE14_OBJECTS) - $(CXX) -o $(PROFILE14_LIB) $(PROFILE14_OBJECTS) $(MOZILLALIBS) ${PROFILE14_LIBS} + $(CXX) -o $(PROFILE14_LIB) $(PROFILE14_OBJECTS) $(MOZILLALIBS) ${PROFILE14_LIBS} ${GECKO_LIBS} $(PROFILE17_LIB): $(PROFILE17_OBJECTS) - $(CXX) -o $(PROFILE17_LIB) $(PROFILE17_OBJECTS) $(MOZILLALIBS) ${PROFILE17_LIBS} + $(CXX) -o $(PROFILE17_LIB) $(PROFILE17_OBJECTS) $(MOZILLALIBS) ${PROFILE17_LIBS} ${GECKO_LIBS} $(PROFILE18_LIB): $(PROFILE18_OBJECTS) - $(CXX) -o $(PROFILE18_LIB) $(PROFILE18_OBJECTS) $(MOZILLALIBS) ${PROFILE18_LIBS} + $(CXX) -o $(PROFILE18_LIB) $(PROFILE18_OBJECTS) $(MOZILLALIBS) ${PROFILE18_LIBS} ${GECKO_LIBS} # # GLX lib @@ -264,4 +264,4 @@ install: all # Clean # clean: - rm -f *.o *.so + rm -f *.o *.so \ No newline at end of file diff --git a/src/org/eclipse/swt/browser/Browser.java b/src/org/eclipse/swt/browser/Browser.java index 3d700c1..f3730e6 100644 --- a/src/org/eclipse/swt/browser/Browser.java +++ b/src/org/eclipse/swt/browser/Browser.java @@ -10,15 +10,75 @@ *******************************************************************************/ package org.eclipse.swt.browser; -import java.io.*; -import java.util.*; -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; -import org.eclipse.swt.internal.gtk.*; -import org.eclipse.swt.internal.mozilla.*; -import org.eclipse.swt.layout.*; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.util.Locale; +import java.util.StringTokenizer; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTError; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.Callback; +import org.eclipse.swt.internal.Converter; +import org.eclipse.swt.internal.Library; +import org.eclipse.swt.internal.gtk.GdkEvent; +import org.eclipse.swt.internal.gtk.LONG; +import org.eclipse.swt.internal.gtk.OS; +import org.eclipse.swt.internal.mozilla.XPCOM; +import org.eclipse.swt.internal.mozilla.XPCOMObject; +import org.eclipse.swt.internal.mozilla.nsEmbedString; +import org.eclipse.swt.internal.mozilla.nsIAppShell; +import org.eclipse.swt.internal.mozilla.nsIBaseWindow; +import org.eclipse.swt.internal.mozilla.nsICategoryManager; +import org.eclipse.swt.internal.mozilla.nsIComponentManager; +import org.eclipse.swt.internal.mozilla.nsIComponentRegistrar; +import org.eclipse.swt.internal.mozilla.nsIContextMenuListener; +import org.eclipse.swt.internal.mozilla.nsICookie; +import org.eclipse.swt.internal.mozilla.nsICookieManager; +import org.eclipse.swt.internal.mozilla.nsID; +import org.eclipse.swt.internal.mozilla.nsIDOMEvent; +import org.eclipse.swt.internal.mozilla.nsIDOMMouseEvent; +import org.eclipse.swt.internal.mozilla.nsIDOMWindow; +import org.eclipse.swt.internal.mozilla.nsIDirectoryService; +import org.eclipse.swt.internal.mozilla.nsIDocShell; +import org.eclipse.swt.internal.mozilla.nsIEmbeddingSiteWindow; +import org.eclipse.swt.internal.mozilla.nsIFile; +import org.eclipse.swt.internal.mozilla.nsIIOService; +import org.eclipse.swt.internal.mozilla.nsIInterfaceRequestor; +import org.eclipse.swt.internal.mozilla.nsILocalFile; +import org.eclipse.swt.internal.mozilla.nsIPrefBranch; +import org.eclipse.swt.internal.mozilla.nsIPrefLocalizedString; +import org.eclipse.swt.internal.mozilla.nsIPrefService; +import org.eclipse.swt.internal.mozilla.nsIProperties; +import org.eclipse.swt.internal.mozilla.nsIRequest; +import org.eclipse.swt.internal.mozilla.nsIServiceManager; +import org.eclipse.swt.internal.mozilla.nsISimpleEnumerator; +import org.eclipse.swt.internal.mozilla.nsISupports; +import org.eclipse.swt.internal.mozilla.nsISupportsWeakReference; +import org.eclipse.swt.internal.mozilla.nsITooltipListener; +import org.eclipse.swt.internal.mozilla.nsIURI; +import org.eclipse.swt.internal.mozilla.nsIURIContentListener; +import org.eclipse.swt.internal.mozilla.nsIWeakReference; +import org.eclipse.swt.internal.mozilla.nsIWebBrowser; +import org.eclipse.swt.internal.mozilla.nsIWebBrowserChrome; +import org.eclipse.swt.internal.mozilla.nsIWebBrowserChromeFocus; +import org.eclipse.swt.internal.mozilla.nsIWebBrowserFocus; +import org.eclipse.swt.internal.mozilla.nsIWebBrowserStream; +import org.eclipse.swt.internal.mozilla.nsIWebNavigation; +import org.eclipse.swt.internal.mozilla.nsIWebProgress; +import org.eclipse.swt.internal.mozilla.nsIWebProgressListener; +import org.eclipse.swt.internal.mozilla.nsIWindowWatcher; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Widget; /** * Instances of this class implement the browser user interface @@ -175,40 +235,43 @@ public Browser(Composite parent, int style) { * - mozilla17profile/mozilla17profile-gcc should succeed for mozilla 1.7.x and firefox * - mozilla18profile/mozilla18profile-gcc should succeed for mozilla 1.8.x (seamonkey) */ - try { - Library.loadLibrary ("swt-mozilla14-profile"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e1) { - try { - Library.loadLibrary ("swt-mozilla17-profile"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e2) { - try { - Library.loadLibrary ("swt-mozilla14-profile-gcc3"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e3) { - try { - Library.loadLibrary ("swt-mozilla17-profile-gcc3"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e4) { - try { - Library.loadLibrary ("swt-mozilla18-profile"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e5) { - try { - Library.loadLibrary ("swt-mozilla18-profile-gcc3"); //$NON-NLS-1$ - usingProfile = true; - } catch (UnsatisfiedLinkError e6) { - /* - * fail silently, the Browser will still work without profile support - * but will abort any attempts to navigate to HTTPS pages - */ - } - } - } - } - } - } +// Library.loadLibrary("swt-mozilla17-profile"); + // We build the profile stuff without the need for a separate DSO + usingProfile = true; +// try { +// Library.loadLibrary ("swt-mozilla14-profile"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e1) { +// try { +// Library.loadLibrary ("swt-mozilla17-profile"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e2) { +// try { +// Library.loadLibrary ("swt-mozilla14-profile-gcc3"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e3) { +// try { +// Library.loadLibrary ("swt-mozilla17-profile-gcc3"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e4) { +// try { +// Library.loadLibrary ("swt-mozilla18-profile"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e5) { +// try { +// Library.loadLibrary ("swt-mozilla18-profile-gcc3"); //$NON-NLS-1$ +// usingProfile = true; +// } catch (UnsatisfiedLinkError e6) { +// /* +// * fail silently, the Browser will still work without profile support +// * but will abort any attempts to navigate to HTTPS pages +// */ +// } +// } +// } +// } +// } +// } long /*int*/[] retVal = new long /*int*/[1]; nsEmbedString pathString = new nsEmbedString(mozillaPath); @@ -218,11 +281,11 @@ public Browser(Composite parent, int style) { if (retVal[0] == 0) error(XPCOM.NS_ERROR_NULL_POINTER); nsILocalFile localFile = new nsILocalFile(retVal[0]); - rc = XPCOM.NS_InitEmbedding(localFile.getAddress(), 0); + rc = XPCOM.NS_InitXPCOM3(0, localFile.getAddress(), 0, 0, 0); localFile.Release(); if (rc != XPCOM.NS_OK) { dispose(); - SWT.error(SWT.ERROR_NO_HANDLES, null, " [NS_InitEmbedding "+mozillaPath+" error "+rc+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SWT.error(SWT.ERROR_NO_HANDLES, null, " [NS_InitXPCOM3 "+mozillaPath+" error "+rc+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } rc = XPCOM.NS_GetComponentManager(result); @@ -283,7 +346,7 @@ public Browser(Composite parent, int style) { rc = properties.Get(buffer, nsIFile.NS_IFILE_IID, result); if (rc != XPCOM.NS_OK) error(rc); if (result[0] == 0) error(XPCOM.NS_NOINTERFACE); - properties.Release(); + // properties.Release() is now after the Set below nsIFile profileDir = new nsIFile(result[0]); result[0] = 0; @@ -305,24 +368,15 @@ public Browser(Composite parent, int style) { pathString.dispose(); // profileDir = new nsIFile(result[0]); - result[0] = 0; - rc = XPCOM_PROFILE.NS_NewProfileDirServiceProvider(true, result); + // Set the profile dir property so that it's initialized for + // things like password manager and https + buffer = Converter.wcsToMbcs(null, XPCOM.NS_APP_USER_PROFILE_50_DIR, true); + rc = properties.Set(buffer, profileDir.getAddress()); if (rc != XPCOM.NS_OK) error(rc); - if (result[0] == 0) error(XPCOM.NS_NOINTERFACE); + properties.Release(); - final long /*int*/ dirServiceProvider = result[0]; result[0] = 0; - rc = XPCOM_PROFILE.ProfileDirServiceProvider_Register(dirServiceProvider); - if (rc != XPCOM.NS_OK) error(rc); - rc = XPCOM_PROFILE.ProfileDirServiceProvider_SetProfileDir(dirServiceProvider, profileDir.getAddress()); - if (rc != XPCOM.NS_OK) error(rc); - - getDisplay().addListener(SWT.Dispose, new Listener() { - public void handleEvent(Event e) { - XPCOM_PROFILE.ProfileDirServiceProvider_Shutdown(dirServiceProvider); - } - }); } /* @@ -1354,27 +1408,6 @@ void onDispose(Display display) { tip = null; BrowserCount--; - /* - * This code is intentionally commented. It is not possible to reinitialize - * Mozilla once it has been terminated. NS_InitEmbedding always fails after - * NS_TermEmbedding has been called. The workaround is to call NS_InitEmbedding - * once and never call NS_TermEmbedding. - */ -// if (BrowserCount == 0) { -// if (AppShell != null) { -// // Shutdown the appshell service. -// rc = AppShell.Spindown(); -// if (rc != XPCOM.NS_OK) error(rc); -// AppShell.Release(); -// AppShell = null; -// } -// WindowCreator.Release(); -// WindowCreator = null; -// PromptService.Release(); -// PromptService = null; -// XPCOM.NS_TermEmbedding(); -// mozilla = false; -// } } void Activate() { diff --git a/src/org/eclipse/swt/internal/mozilla/XPCOM.java b/src/org/eclipse/swt/internal/mozilla/XPCOM.java index 7ff45cb..633f55e 100644 --- a/src/org/eclipse/swt/internal/mozilla/XPCOM.java +++ b/src/org/eclipse/swt/internal/mozilla/XPCOM.java @@ -89,6 +89,7 @@ public class XPCOM extends Platform { public static final int NS_ERROR_HTMLPARSER_UNRESOLVEDDTD = 0x804e03f3; public static final int NS_ERROR_FILE_NOT_FOUND = 0x80520012; public static final String NS_APP_APPLICATION_REGISTRY_DIR = "AppRegD"; //$NON-NLS-1$ + public static final String NS_APP_USER_PROFILE_50_DIR = "ProfD"; //$NON-NLS-1$ public static final native void memmove(nsID dest, long /*int*/ src, int nbytes); public static final native void memmove(long /*int*/ dest, nsID src, int nbytes); @@ -103,9 +104,8 @@ public static final native void memmove(long /*int*/ dest, char[] src, int nbyte public static final native void memmove(byte[] dest, char[] src, int nbytes); public static final native int NS_GetComponentManager(long /*int*/[] result); public static final native int NS_GetServiceManager(long /*int*/[] result); -public static final native int NS_InitEmbedding(long /*int*/ aMozBinDirectory, long /*int*/ aAppFileLocProvider); +public static final native int NS_InitXPCOM3(long /*int*/ result, long /*int*/ binDirectory, long /*int*/ appFileLocationProvider, long /*int*/ staticComponents, int componentCount); public static final native int NS_NewLocalFile(long /*int*/ path, boolean followLinks, long /*int*/[] result); -public static final native int NS_TermEmbedding(); public static final native int strlen_PRUnichar(long /*int*/ s); public static final native long /*int*/ nsEmbedCString_new(); public static final native long /*int*/ nsEmbedCString_new(byte[] aString, int length); diff --git a/xpcom.cpp b/xpcom.cpp index 1423dab..3f42d90 100644 --- a/xpcom.cpp +++ b/xpcom.cpp @@ -113,18 +113,6 @@ fail: } #endif -#ifndef NO_NS_1TermEmbedding -JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1TermEmbedding) - (JNIEnv *env, jclass that) -{ - jint rc = 0; - XPCOM_NATIVE_ENTER(env, that, NS_1TermEmbedding_FUNC); - rc = (jint)NS_TermEmbedding(); - XPCOM_NATIVE_EXIT(env, that, NS_1TermEmbedding_FUNC); - return rc; -} -#endif - #ifndef NO_PR_1Free JNIEXPORT void JNICALL XPCOM_NATIVE(PR_1Free) (JNIEnv *env, jclass that, jlong arg0) diff --git a/xpcom.h b/xpcom.h index 938c8f8..b328610 100644 --- a/xpcom.h +++ b/xpcom.h @@ -15,7 +15,6 @@ #define NDEBUG #include "nsXPCOM.h" -#include "nsEmbedAPI.h" #include "nsEmbedString.h" #include "nsIInputStream.h" #include "nsISupportsUtils.h" diff --git a/xpcom_profile.h b/xpcom_profile.h index d45d95e..7afe1dd 100644 --- a/xpcom_profile.h +++ b/xpcom_profile.h @@ -15,7 +15,7 @@ #define NDEBUG #include "nsCOMPtr.h" -#include "nsProfileDirServiceProvider.h" +#include "profdirserviceprovider/nsProfileDirServiceProvider.h" #include "xpcom_stats.h" #endif /* INC_xpcom_profile_H */ diff --git a/xpcom_stats.cpp b/xpcom_stats.cpp index 2fc6e1a..f065412 100644 --- a/xpcom_stats.cpp +++ b/xpcom_stats.cpp @@ -31,15 +31,14 @@ #ifdef NATIVE_STATS -int XPCOM_nativeFunctionCount = 132; -int XPCOM_nativeFunctionCallCount[132]; +int XPCOM_nativeFunctionCount = 131; +int XPCOM_nativeFunctionCallCount[131]; char * XPCOM_nativeFunctionNames[] = { "Call", "NS_1GetComponentManager", "NS_1GetServiceManager", - "NS_1InitEmbedding", + "NS_1InitXPCOM3_FUNC", "NS_1NewLocalFile", - "NS_1TermEmbedding", "PR_1Free", "PR_1Malloc", "VtblCall__IJ", diff --git a/xpcom_stats.h b/xpcom_stats.h index d773d25..c118691 100644 --- a/xpcom_stats.h +++ b/xpcom_stats.h @@ -41,9 +41,8 @@ typedef enum { Call_FUNC, NS_1GetComponentManager_FUNC, NS_1GetServiceManager_FUNC, - NS_1InitEmbedding_FUNC, + NS_1InitXPCOM3_FUNC, NS_1NewLocalFile_FUNC, - NS_1TermEmbedding_FUNC, PR_1Free_FUNC, PR_1Malloc_FUNC, VtblCall__IJ_FUNC,