diff options
author | Grant Gayed <ggayed> | 2007-02-07 17:33:14 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2007-02-07 17:33:14 +0000 |
commit | 9f77d34da8ea742407b09f5a6eb0074cca334552 (patch) | |
tree | 2bc74d4a476f6dd81f17116a79438637716420f0 /bundles/org.eclipse.swt/Eclipse SWT Mozilla | |
parent | e71979ddce40601be5242cafb3047257ce4832b4 (diff) | |
download | eclipse.platform.swt-9f77d34da8ea742407b09f5a6eb0074cca334552.tar.gz eclipse.platform.swt-9f77d34da8ea742407b09f5a6eb0074cca334552.tar.xz eclipse.platform.swt-9f77d34da8ea742407b09f5a6eb0074cca334552.zip |
add Mozilla do-not-init system propertyv3325b
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Mozilla')
5 files changed, 73 insertions, 37 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java index d7424d0d87..4fb01f0c48 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java @@ -124,6 +124,10 @@ int getHandle () { return embedHandle; } +String getLibraryName () { + return "libxpcom.dylib"; +} + void onDispose (int embedHandle) { handles.remove (new LONG (embedHandle)); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java index 8a8fbb89e2..207e4f53c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java @@ -78,6 +78,10 @@ class Mozilla extends WebBrowser { static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ static final String STARTUP = "startup"; //$NON-NLS-1$ + // TEMPORARY CODE + static final String XULRUNNER_INITIALIZED = "org.eclipse.swt.browser.XULRunnerInitialized"; //$NON-NLS-1$ + static final String XULRUNNER_PATH = "org.eclipse.swt.browser.XULRunnerPath"; //$NON-NLS-1$ + static { MozillaClearSessions = new Runnable () { public void run () { @@ -141,29 +145,41 @@ public void create (Composite parent, int style) { int /*long*/[] result = new int /*long*/[1]; if (!initialized) { boolean initLoaded = false; - try { - Library.loadLibrary ("swt-xpcominit"); //$NON-NLS-1$ - initLoaded = true; - } catch (UnsatisfiedLinkError e) { + String mozillaPath = System.getProperty (XULRUNNER_PATH); + boolean isXULRunner = false; + if (mozillaPath == null) { try { - /* - * The initial loadLibrary attempt may have failed as a result of the user's - * system not having libstdc++.so.6 installed, so try to load the alternate - * swt xpcominit library that depends on libswtc++.so.5 instead. - */ - Library.loadLibrary ("swt-xpcominit-gcc3"); //$NON-NLS-1$ + Library.loadLibrary ("swt-xpcominit"); //$NON-NLS-1$ initLoaded = true; - } catch (UnsatisfiedLinkError ex) { - /* - * If this library still failed to load then do not attempt to detect a - * xulrunner to use. The Browser may still be usable if MOZILLA_FIVE_HOME - * points at a GRE. + } catch (UnsatisfiedLinkError e) { + try { + /* + * The initial loadLibrary attempt may have failed as a result of the user's + * system not having libstdc++.so.6 installed, so try to load the alternate + * swt xpcominit library that depends on libswtc++.so.5 instead. + */ + Library.loadLibrary ("swt-xpcominit-gcc3"); //$NON-NLS-1$ + initLoaded = true; + } catch (UnsatisfiedLinkError ex) { + /* + * If this library still failed to load then do not attempt to detect a + * xulrunner to use. The Browser may still be usable if MOZILLA_FIVE_HOME + * points at a GRE. + */ + } + } + } else { + mozillaPath += SEPARATOR_OS + delegate.getLibraryName (); + if (System.getProperty (XULRUNNER_INITIALIZED) != null) { + /* + * Another browser has already initialized xulrunner in this process, + * so just bind to it instead of trying to initialize a new one. */ + initialized = true; + isXULRunner = true; } } - - boolean isXULRunner = false; - String mozillaPath = null; + if (initLoaded) { /* attempt to discover a XULRunner to use as the GRE */ GREVersionRange range = new GREVersionRange (); @@ -280,25 +296,29 @@ public void create (Composite parent, int style) { } } - int /*long*/[] retVal = new int /*long*/[1]; - nsEmbedString pathString = new nsEmbedString (mozillaPath); - int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), true, retVal); - pathString.dispose (); - if (rc != XPCOM.NS_OK) { - browser.dispose (); - error (rc); - } - if (retVal[0] == 0) { - browser.dispose (); - error (XPCOM.NS_ERROR_NULL_POINTER); - } + if (!initialized) { + int /*long*/[] retVal = new int /*long*/[1]; + nsEmbedString pathString = new nsEmbedString (mozillaPath); + int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), true, retVal); + pathString.dispose (); + if (rc != XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (retVal[0] == 0) { + browser.dispose (); + error (XPCOM.NS_ERROR_NULL_POINTER); + } - nsIFile localFile = new nsILocalFile (retVal[0]); - rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), 0); - localFile.Release (); - if (rc != XPCOM.NS_OK) { - browser.dispose (); - SWT.error (SWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + nsIFile localFile = new nsILocalFile (retVal[0]); + rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), 0); + localFile.Release (); + if (rc != XPCOM.NS_OK) { + browser.dispose (); + SWT.error (SWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + System.setProperty (XULRUNNER_PATH, mozillaPath); //$NON-NLS-1$ + System.setProperty (XULRUNNER_INITIALIZED, "true"); //$NON-NLS-1$ } /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */ @@ -325,7 +345,7 @@ public void create (Composite parent, int style) { } } - rc = XPCOM.NS_GetComponentManager (result); + int rc = XPCOM.NS_GetComponentManager (result); if (rc != XPCOM.NS_OK) { browser.dispose (); error (rc); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java index e1ffc6fd36..a321e085e1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java @@ -121,6 +121,10 @@ int /*long*/ getHandle () { return embedHandle; } +String getLibraryName () { + return "libxpcom.so"; +} + int /*long*/ gtk_event (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) { /* * Stop the propagation of events that are not consumed by Mozilla, before diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java index e1e884a6a1..db6de00c50 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java @@ -103,6 +103,10 @@ int getHandle() { return result; } +String getLibraryName () { + return "libxpcom.so"; +} + void onDispose (int embedHandle) { GTK.gtk_widget_destroy (embedHandle); while (GTK.gtk_events_pending () != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java index 408351876d..5e274da71f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java @@ -48,6 +48,10 @@ int /*long*/ getHandle () { return browser.handle; } +String getLibraryName () { + return "xpcom.dll"; +} + void onDispose (int /*long*/ embedHandle) { } |