Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationEvent.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java22
8 files changed, 99 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationEvent.java
index 0fed868b06..c500ee31b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationEvent.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.swt.browser;
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
/**
* A <code>LocationEvent</code> is sent by a {@link Browser} to
@@ -26,7 +26,10 @@ import org.eclipse.swt.events.*;
* @since 3.0
*/
public class LocationEvent extends TypedEvent {
- /** current location */
+ /**
+ * The URL of this event, escaped and encoded for consumption by
+ * {@link java.net.URI#URI(String)}.
+ */
public String location;
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index 2a932269df..13cc2ae0de 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -472,12 +472,19 @@ public void create(Composite parent, int style) {
/*
* Feature in IE. For navigations on the local machine, BeforeNavigate2's url
- * field contains a string representing the file path in a non-URL format.
+ * field contains a string representation of the file path in a non-URL format.
* In order to be consistent with the other Browser implementations, this
* case is detected and the string is changed to be a proper url string.
*/
if (url.indexOf(":/") == -1 && url.indexOf(":\\") != -1) { //$NON-NLS-1$ //$NON-NLS-2$
- url = PROTOCOL_FILE + url.replace('\\', '/');
+ TCHAR filePath = new TCHAR(0, url, true);
+ TCHAR urlResult = new TCHAR(0, OS.INTERNET_MAX_URL_LENGTH);
+ int[] size = new int[] {urlResult.length()};
+ if (!OS.IsWinCE && OS.UrlCreateFromPath(filePath, urlResult, size, 0) == COM.S_OK) {
+ url = urlResult.toString(0, size[0]);
+ } else {
+ url = PROTOCOL_FILE + url.replace('\\', '/');
+ }
}
/* Disallow local file system accesses if the browser content is untrusted */
@@ -542,13 +549,20 @@ public void create(Composite parent, int style) {
varResult = event.arguments[1];
String url = varResult.getString();
/*
- * Bug in IE. For navigations on the local machine, DocumentComplete's URL
- * field contains a string representing the file path in a non-URL format.
+ * Feature in IE. For navigations on the local machine, DocumentComplete's url
+ * field contains a string representation of the file path in a non-URL format.
* In order to be consistent with the other Browser implementations, this
* case is detected and the string is changed to be a proper url string.
*/
if (url.indexOf(":/") == -1 && url.indexOf(":\\") != -1) { //$NON-NLS-1$ //$NON-NLS-2$
- url = PROTOCOL_FILE + url.replace('\\', '/');
+ TCHAR filePath = new TCHAR(0, url, true);
+ TCHAR urlResult = new TCHAR(0, OS.INTERNET_MAX_URL_LENGTH);
+ int[] size = new int[] {urlResult.length()};
+ if (!OS.IsWinCE && OS.UrlCreateFromPath(filePath, urlResult, size, 0) == COM.S_OK) {
+ url = urlResult.toString(0, size[0]);
+ } else {
+ url = PROTOCOL_FILE + url.replace('\\', '/');
+ }
}
if (html != null && url.equals(ABOUT_BLANK)) {
if (delaySetText) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
index 43c88c8b45..58d70261a5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
@@ -22,7 +22,7 @@ SWT_PREFIX = swt
WS_PREFIX = win32
SWT_VERSION = $(maj_ver)$(min_ver)
SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
-SWT_LIBS = comctl32.lib shell32.lib imm32.lib oleacc.lib usp10.lib wininet.lib Crypt32.lib
+SWT_LIBS = comctl32.lib shell32.lib imm32.lib oleacc.lib usp10.lib wininet.lib Crypt32.lib Shlwapi.lib
SWT_OBJS = swt.obj callback.obj c.obj c_stats.obj \
os.obj os_structs.obj os_custom.obj os_stats.obj \
com_structs.obj com.obj com_stats.obj com_custom.obj
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index b514f5898d..39272ca3a4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -18099,6 +18099,50 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(UpdateWindow)
}
#endif
+#ifndef NO_UrlCreateFromPathA
+JNIEXPORT jint JNICALL OS_NATIVE(UrlCreateFromPathA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jintArray arg2, jint arg3)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint *lparg2=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, UrlCreateFromPathA_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ rc = (jint)UrlCreateFromPathA((LPCTSTR)lparg0, (LPCTSTR)lparg1, lparg2, arg3);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ OS_NATIVE_EXIT(env, that, UrlCreateFromPathA_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_UrlCreateFromPathW
+JNIEXPORT jint JNICALL OS_NATIVE(UrlCreateFromPathW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jintArray arg2, jint arg3)
+{
+ jchar *lparg0=NULL;
+ jchar *lparg1=NULL;
+ jint *lparg2=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, UrlCreateFromPathW_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ rc = (jint)UrlCreateFromPathW((LPCWSTR)lparg0, (LPCWSTR)lparg1, lparg2, arg3);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ OS_NATIVE_EXIT(env, that, UrlCreateFromPathW_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_ValidateRect
JNIEXPORT jboolean JNICALL OS_NATIVE(ValidateRect)
(JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
index abaa3bdb61..ebb5a9a404 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
@@ -618,6 +618,8 @@
#define NO_UnregisterClassA
#define NO_UnregisterTouchWindow
#define NO_UpdateLayeredWindow
+#define NO_UrlCreateFromPathA
+#define NO_UrlCreateFromPathW
#define NO_VkKeyScanA
#define NO_VkKeyScanW
#define NO_VtblCall__IILorg_eclipse_swt_internal_win32_TF_1DISPLAYATTRIBUTE_2
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index c947f89492..879d0d5ab2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1069;
-int OS_nativeFunctionCallCount[1069];
+int OS_nativeFunctionCount = 1071;
+int OS_nativeFunctionCallCount[1071];
char * OS_nativeFunctionNames[] = {
"ACCEL_1sizeof",
"ACTCTX_1sizeof",
@@ -1837,6 +1837,8 @@ char * OS_nativeFunctionNames[] = {
"UnregisterTouchWindow",
"UpdateLayeredWindow",
"UpdateWindow",
+ "UrlCreateFromPathA",
+ "UrlCreateFromPathW",
"ValidateRect",
"VkKeyScanA",
"VkKeyScanW",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
index 3d606b8309..47434909fb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
@@ -1845,6 +1845,8 @@ typedef enum {
UnregisterTouchWindow_FUNC,
UpdateLayeredWindow_FUNC,
UpdateWindow_FUNC,
+ UrlCreateFromPathA_FUNC,
+ UrlCreateFromPathW_FUNC,
ValidateRect_FUNC,
VkKeyScanA_FUNC,
VkKeyScanW_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index c06b800392..d045269733 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -907,6 +907,7 @@ public class OS extends C {
public static final int INFINITE = 0xffffffff;
public static final int INPUT_KEYBOARD = 1;
public static final int INPUT_MOUSE = 0;
+ public static final int INTERNET_MAX_URL_LENGTH = 2084;
public static final int INTERNET_OPTION_END_BROWSER_SESSION = 42;
public static final int KEY_ENUMERATE_SUB_KEYS = 0x8;
public static final int KEY_NOTIFY = 0x10;
@@ -3544,6 +3545,17 @@ public static final boolean UnregisterClass (TCHAR lpClassName, int /*long*/ hIn
return UnregisterClassA (lpClassName1, hInstance);
}
+public static final int UrlCreateFromPath (TCHAR pszPath, TCHAR pszURL, int[] pcchUrl, int flags) {
+ if (IsUnicode) {
+ char [] path = pszPath == null ? null : pszPath.chars;
+ char [] url = pszURL == null ? null : pszURL.chars;
+ return UrlCreateFromPathW (path, url, pcchUrl, flags);
+ }
+ byte [] path = pszPath == null ? null : pszPath.bytes;
+ byte [] url = pszURL == null ? null : pszURL.bytes;
+ return UrlCreateFromPathA (path, url, pcchUrl, flags);
+}
+
public static final short VkKeyScan (short ch) {
if (IsUnicode) return VkKeyScanW (ch);
return VkKeyScanA (ch);
@@ -6928,6 +6940,16 @@ public static final native boolean UpdateLayeredWindow (int /*long*/ hwnd, int /
public static final native boolean UnregisterTouchWindow (int /*long*/ hwnd);
/** @param hWnd cast=(HWND) */
public static final native boolean UpdateWindow (int /*long*/ hWnd);
+/**
+ * @param pszPath cast=(LPCTSTR)
+ * @param pszURL cast=(LPCTSTR)
+ */
+public static final native int UrlCreateFromPathA (byte[] pszPath, byte[] pszURL, int[] pcchUrl, int flags);
+/**
+ * @param pszPath cast=(LPCWSTR)
+ * @param pszURL cast=(LPCWSTR)
+ */
+public static final native int UrlCreateFromPathW (char[] pszPath, char[] pszURL, int[] pcchUrl, int flags);
/** @param hWnd cast=(HWND) */
public static final native boolean ValidateRect (int /*long*/ hWnd, RECT lpRect);
/** @param ch cast=(WCHAR) */

Back to the top