|
|
*******************************************************************************/ | *******************************************************************************/ |
package org.eclipse.swt.browser; | package org.eclipse.swt.browser; |
| |
import java.io.*; |
import java.io.File; |
import java.util.*; |
import java.io.UnsupportedEncodingException; |
import org.eclipse.swt.*; |
import java.util.Locale; |
import org.eclipse.swt.widgets.*; |
import java.util.StringTokenizer; |
import org.eclipse.swt.graphics.*; |
|
import org.eclipse.swt.internal.*; |
import org.eclipse.swt.SWT; |
import org.eclipse.swt.internal.gtk.*; |
import org.eclipse.swt.SWTError; |
import org.eclipse.swt.internal.mozilla.*; |
import org.eclipse.swt.SWTException; |
import org.eclipse.swt.layout.*; |
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 | * Instances of this class implement the browser user interface |
|
Lines 175-214
public Browser(Composite parent, int style) {
|
Link Here
|
|---|
|
* - mozilla17profile/mozilla17profile-gcc should succeed for mozilla 1.7.x and firefox | * - mozilla17profile/mozilla17profile-gcc should succeed for mozilla 1.7.x and firefox |
* - mozilla18profile/mozilla18profile-gcc should succeed for mozilla 1.8.x (seamonkey) | * - mozilla18profile/mozilla18profile-gcc should succeed for mozilla 1.8.x (seamonkey) |
*/ | */ |
try { |
// Library.loadLibrary("swt-mozilla17-profile"); |
Library.loadLibrary ("swt-mozilla14-profile"); //$NON-NLS-1$ |
// We build the profile stuff without the need for a separate DSO |
usingProfile = true; |
usingProfile = true; |
} catch (UnsatisfiedLinkError e1) { |
// try { |
try { |
// Library.loadLibrary ("swt-mozilla14-profile"); //$NON-NLS-1$ |
Library.loadLibrary ("swt-mozilla17-profile"); //$NON-NLS-1$ |
// usingProfile = true; |
usingProfile = true; |
// } catch (UnsatisfiedLinkError e1) { |
} catch (UnsatisfiedLinkError e2) { |
// try { |
try { |
// Library.loadLibrary ("swt-mozilla17-profile"); //$NON-NLS-1$ |
Library.loadLibrary ("swt-mozilla14-profile-gcc3"); //$NON-NLS-1$ |
// usingProfile = true; |
usingProfile = true; |
// } catch (UnsatisfiedLinkError e2) { |
} catch (UnsatisfiedLinkError e3) { |
// try { |
try { |
// Library.loadLibrary ("swt-mozilla14-profile-gcc3"); //$NON-NLS-1$ |
Library.loadLibrary ("swt-mozilla17-profile-gcc3"); //$NON-NLS-1$ |
// usingProfile = true; |
usingProfile = true; |
// } catch (UnsatisfiedLinkError e3) { |
} catch (UnsatisfiedLinkError e4) { |
// try { |
try { |
// Library.loadLibrary ("swt-mozilla17-profile-gcc3"); //$NON-NLS-1$ |
Library.loadLibrary ("swt-mozilla18-profile"); //$NON-NLS-1$ |
// usingProfile = true; |
usingProfile = true; |
// } catch (UnsatisfiedLinkError e4) { |
} catch (UnsatisfiedLinkError e5) { |
// try { |
try { |
// Library.loadLibrary ("swt-mozilla18-profile"); //$NON-NLS-1$ |
Library.loadLibrary ("swt-mozilla18-profile-gcc3"); //$NON-NLS-1$ |
// usingProfile = true; |
usingProfile = true; |
// } catch (UnsatisfiedLinkError e5) { |
} catch (UnsatisfiedLinkError e6) { |
// try { |
/* |
// Library.loadLibrary ("swt-mozilla18-profile-gcc3"); //$NON-NLS-1$ |
* fail silently, the Browser will still work without profile support |
// usingProfile = true; |
* but will abort any attempts to navigate to HTTPS pages |
// } 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]; | long /*int*/[] retVal = new long /*int*/[1]; |
nsEmbedString pathString = new nsEmbedString(mozillaPath); | nsEmbedString pathString = new nsEmbedString(mozillaPath); |
|
Lines 218-228
public Browser(Composite parent, int style) {
|
Link Here
|
|---|
|
if (retVal[0] == 0) error(XPCOM.NS_ERROR_NULL_POINTER); | if (retVal[0] == 0) error(XPCOM.NS_ERROR_NULL_POINTER); |
| |
nsILocalFile localFile = new nsILocalFile(retVal[0]); | 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(); | localFile.Release(); |
if (rc != XPCOM.NS_OK) { | if (rc != XPCOM.NS_OK) { |
dispose(); | 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); | rc = XPCOM.NS_GetComponentManager(result); |
|
Lines 283-289
public Browser(Composite parent, int style) {
|
Link Here
|
|---|
|
rc = properties.Get(buffer, nsIFile.NS_IFILE_IID, result); | rc = properties.Get(buffer, nsIFile.NS_IFILE_IID, result); |
if (rc != XPCOM.NS_OK) error(rc); | if (rc != XPCOM.NS_OK) error(rc); |
if (result[0] == 0) error(XPCOM.NS_NOINTERFACE); | if (result[0] == 0) error(XPCOM.NS_NOINTERFACE); |
properties.Release(); |
// properties.Release() is now after the Set below |
| |
nsIFile profileDir = new nsIFile(result[0]); | nsIFile profileDir = new nsIFile(result[0]); |
result[0] = 0; | result[0] = 0; |
|
Lines 305-328
public Browser(Composite parent, int style) {
|
Link Here
|
|---|
|
pathString.dispose(); // | pathString.dispose(); // |
| |
profileDir = new nsIFile(result[0]); | 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 (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; | 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); |
|
} |
|
}); |
|
} | } |
| |
/* | /* |
|
Lines 1354-1380
void onDispose(Display display) {
|
Link Here
|
|---|
|
tip = null; | tip = null; |
| |
BrowserCount--; | 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() { | void Activate() { |