aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Hiller2013-04-07 13:40:44 (EDT)
committerGrant Gayed2013-04-08 10:47:17 (EDT)
commitc198ee8e71f6343717ca89d24990bcf6153706c7 (patch)
tree841f81a69ebad47b706db7e1fc93ee5ad70095b9
parent53a00ebb783f6585a573649678906ae161a323d0 (diff)
downloadeclipse.platform.swt-c198ee8e71f6343717ca89d24990bcf6153706c7.zip
eclipse.platform.swt-c198ee8e71f6343717ca89d24990bcf6153706c7.tar.gz
eclipse.platform.swt-c198ee8e71f6343717ca89d24990bcf6153706c7.tar.bz2
Adding support for downloads
The included CEF download handler gets us everything up to when the download starts. CEF does not provide any way for the user to cancel the dialogs so I have created a CEFDownload object that maintains the state of the download. The CEFDownload objects are stored in a hash table in CEF so that the download progress notifications can be directed to the correct dialog. Each download within chrome is identified by a unique 32bit identifier and this is the only way of keeping track of them. The download progress events are completely asynchronous and they begin firing before the download has actually started(I am not sure why they do this as they do not appear to be doing something like starting the download in advance of the user naming it to save time. Unless this is what is going on and the received bytes is just not updated accordingly). NOTE: the documentation on the download handler is wrong. The download events begin firing even if you do not fire the before download callback. Caveats: * Currently when you navigate directly to a file that chrome downloads, it does not update the frame or the address bar. However if you navigate in the frame the download stops. The correct behaviour would be to somehow catch this, navigate to about:blank, and start the download as though a link was clicked. As of yet I do not know how to do the first or last steps. * The download window I create could be a good deal nicer (CEF provides things like the ETA and download speed). * Not sure where I should put the object CEFDownload, if it should be called something else, if it should be a widget that contains state as opposed to a state object that contains a widget, etc... I am not sure of the best practices here. * I may have missed some of the race conditions that can occur due to the assynchronous nature of the download events. My synchronization and some of my checks may also be unnecessary.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c169
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.c147
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.h36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFDownloadHandler.java105
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFBeforeDownloadCallback.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownload.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItem.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItemCallback.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_before_download_callback_t.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_callback_t.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_t.java54
17 files changed, 807 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
index e3752b2..1b30819 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
@@ -90,6 +90,18 @@ fail:
}
#endif
+#ifndef NO_callFuncLong
+JNIEXPORT jlong JNICALL CEF3_NATIVE(callFuncLong)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+{
+ jlong rc = 0;
+ CEF3_NATIVE_ENTER(env, that, callFuncLong_FUNC);
+ rc = (jlong)((jlong (CEF_CALLBACK*)())arg0)(arg1);
+ CEF3_NATIVE_EXIT(env, that, callFuncLong_FUNC);
+ return rc;
+}
+#endif
+
#if (!defined(NO_callFuncPtr__II) && !defined(JNI64)) || (!defined(NO_callFuncPtr__JJ) && defined(JNI64))
#ifndef JNI64
JNIEXPORT jintLong JNICALL CEF3_NATIVE(callFuncPtr__II)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
@@ -136,6 +148,27 @@ JNIEXPORT jintLong JNICALL CEF3_NATIVE(callFuncPtr__JJI)(JNIEnv *env, jclass tha
}
#endif
+#if (!defined(NO_callFuncVoid__II) && !defined(JNI64)) || (!defined(NO_callFuncVoid__JJ) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__II)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__JJ)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+#endif
+{
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__II_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__JJ_FUNC);
+#endif
+ ((void (CEF_CALLBACK*)())arg0)(arg1);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__II_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__JJ_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_callFuncVoid__IIIII) && !defined(JNI64)) || (!defined(NO_callFuncVoid__JJJJI) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__IIIII)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3, jint arg4)
@@ -182,6 +215,31 @@ fail:
}
#endif
+#if (!defined(NO_callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I) && !defined(JNI64)) || (!defined(NO_callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jint arg3)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jint arg3)
+#endif
+{
+ cef_string_t _arg2, *lparg2=NULL;
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC);
+#endif
+ if (arg2) if ((lparg2 = getcef_string_tFields(env, arg2, &_arg2)) == NULL) goto fail;
+ ((void (CEF_CALLBACK*)())arg0)(arg1, lparg2, arg3);
+fail:
+ if (arg2 && lparg2) setcef_string_tFields(env, arg2, lparg2);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2) && !defined(JNI64)) || (!defined(NO_callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jobject arg3)
@@ -250,6 +308,18 @@ JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1base_1t_1sizeof)
}
#endif
+#ifndef NO_cef_1before_1download_1callback_1t_1sizeof
+JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1before_1download_1callback_1t_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ CEF3_NATIVE_ENTER(env, that, cef_1before_1download_1callback_1t_1sizeof_FUNC);
+ rc = (jint)cef_before_download_callback_t_sizeof();
+ CEF3_NATIVE_EXIT(env, that, cef_1before_1download_1callback_1t_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_cef_1browser_1host_1create_1browser
JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1browser_1host_1create_1browser)
(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jobject arg2, jobject arg3)
@@ -320,6 +390,30 @@ JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1build_1revision)
}
#endif
+#ifndef NO_cef_1download_1item_1callback_1t_1sizeof
+JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1download_1item_1callback_1t_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ CEF3_NATIVE_ENTER(env, that, cef_1download_1item_1callback_1t_1sizeof_FUNC);
+ rc = (jint)cef_download_item_callback_t_sizeof();
+ CEF3_NATIVE_EXIT(env, that, cef_1download_1item_1callback_1t_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_cef_1download_1item_1t_1sizeof
+JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1download_1item_1t_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ CEF3_NATIVE_ENTER(env, that, cef_1download_1item_1t_1sizeof_FUNC);
+ rc = (jint)cef_download_item_t_sizeof();
+ CEF3_NATIVE_EXIT(env, that, cef_1download_1item_1t_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_cef_1execute_1process
JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1execute_1process)
(JNIEnv *env, jclass that, jobject arg0, jintLong arg1)
@@ -485,6 +579,31 @@ fail:
}
#endif
+#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#endif
+{
+ cef_before_download_callback_t _arg0, *lparg0=NULL;
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ_FUNC);
+#endif
+ if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+ memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+ if (arg0 && lparg0) setcef_before_download_callback_tFields(env, arg0, lparg0);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2JJ) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
@@ -535,6 +654,56 @@ fail:
}
#endif
+#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#endif
+{
+ cef_download_item_callback_t _arg0, *lparg0=NULL;
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ_FUNC);
+#endif
+ if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+ memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+ if (arg0 && lparg0) setcef_download_item_callback_tFields(env, arg0, lparg0);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ_FUNC);
+#endif
+}
+#endif
+
+#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
+#endif
+{
+ cef_download_item_t _arg0, *lparg0=NULL;
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ_FUNC);
+#endif
+ if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+ memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+ if (arg0 && lparg0) setcef_download_item_tFields(env, arg0, lparg0);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2JJ) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.h b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.h
index 1b513fc..a5477c0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.h
@@ -20,6 +20,8 @@ typedef enum cef_state_t cef_state_t;
#include <cef_app_capi.h>
#include <cef_browser_capi.h>
+#include <cef_download_handler_capi.h>
+#include <cef_download_item_capi.h>
#include <cef_frame_capi.h>
#include <cef_version.h>
#include <cef_process_message_capi.h>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
index 260f24e..42bf01f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
@@ -30,6 +30,7 @@ char * CEF3_nativeFunctionNames[] = {
#else
"callFuncInt__JJILorg_eclipse_swt_internal_cef3_cef_1string_1t_2",
#endif
+ "callFuncLong",
#ifndef JNI64
"callFuncPtr__II",
#else
@@ -41,6 +42,11 @@ char * CEF3_nativeFunctionNames[] = {
"callFuncPtr__JJI",
#endif
#ifndef JNI64
+ "callFuncVoid__II",
+#else
+ "callFuncVoid__JJ",
+#endif
+#ifndef JNI64
"callFuncVoid__IIIII",
#else
"callFuncVoid__JJJJI",
@@ -51,6 +57,11 @@ char * CEF3_nativeFunctionNames[] = {
"callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2",
#endif
#ifndef JNI64
+ "callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I",
+#else
+ "callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I",
+#endif
+#ifndef JNI64
"callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2",
#else
"callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2",
@@ -61,11 +72,14 @@ char * CEF3_nativeFunctionNames[] = {
"callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2I",
#endif
"cef_1base_1t_1sizeof",
+ "cef_1before_1download_1callback_1t_1sizeof",
"cef_1browser_1host_1create_1browser",
"cef_1browser_1host_1t_1sizeof",
"cef_1browser_1settings_1t_1sizeof",
"cef_1browser_1t_1sizeof",
"cef_1build_1revision",
+ "cef_1download_1item_1callback_1t_1sizeof",
+ "cef_1download_1item_1t_1sizeof",
"cef_1execute_1process",
"cef_1frame_1t_1sizeof",
"cef_1initialize",
@@ -82,6 +96,11 @@ char * CEF3_nativeFunctionNames[] = {
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2JJ",
#endif
#ifndef JNI64
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II",
+#else
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ",
+#endif
+#ifndef JNI64
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2II",
#else
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2JJ",
@@ -92,6 +111,16 @@ char * CEF3_nativeFunctionNames[] = {
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1t_2JJ",
#endif
#ifndef JNI64
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II",
+#else
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ",
+#endif
+#ifndef JNI64
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II",
+#else
+ "memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ",
+#endif
+#ifndef JNI64
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2II",
#else
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2JJ",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
index cf54b09..09d6338 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
@@ -40,6 +40,7 @@ typedef enum {
#else
callFuncInt__JJILorg_eclipse_swt_internal_cef3_cef_1string_1t_2_FUNC,
#endif
+ callFuncLong_FUNC,
#ifndef JNI64
callFuncPtr__II_FUNC,
#else
@@ -51,6 +52,11 @@ typedef enum {
callFuncPtr__JJI_FUNC,
#endif
#ifndef JNI64
+ callFuncVoid__II_FUNC,
+#else
+ callFuncVoid__JJ_FUNC,
+#endif
+#ifndef JNI64
callFuncVoid__IIIII_FUNC,
#else
callFuncVoid__JJJJI_FUNC,
@@ -61,6 +67,11 @@ typedef enum {
callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2_FUNC,
#endif
#ifndef JNI64
+ callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC,
+#else
+ callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC,
+#endif
+#ifndef JNI64
callFuncVoid__IILorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2_FUNC,
#else
callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2_FUNC,
@@ -71,11 +82,14 @@ typedef enum {
callFuncVoid__JJLorg_eclipse_swt_internal_cef3_cef_1string_1t_2Lorg_eclipse_swt_internal_cef3_cef_1string_1t_2I_FUNC,
#endif
cef_1base_1t_1sizeof_FUNC,
+ cef_1before_1download_1callback_1t_1sizeof_FUNC,
cef_1browser_1host_1create_1browser_FUNC,
cef_1browser_1host_1t_1sizeof_FUNC,
cef_1browser_1settings_1t_1sizeof_FUNC,
cef_1browser_1t_1sizeof_FUNC,
cef_1build_1revision_FUNC,
+ cef_1download_1item_1callback_1t_1sizeof_FUNC,
+ cef_1download_1item_1t_1sizeof_FUNC,
cef_1execute_1process_FUNC,
cef_1frame_1t_1sizeof_FUNC,
cef_1initialize_FUNC,
@@ -92,6 +106,11 @@ typedef enum {
memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2JJ_FUNC,
#endif
#ifndef JNI64
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2II_FUNC,
+#else
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1before_1download_1callback_1t_2JJ_FUNC,
+#endif
+#ifndef JNI64
memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2II_FUNC,
#else
memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1host_1t_2JJ_FUNC,
@@ -102,6 +121,16 @@ typedef enum {
memmove__Lorg_eclipse_swt_internal_cef3_cef_1browser_1t_2JJ_FUNC,
#endif
#ifndef JNI64
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2II_FUNC,
+#else
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1callback_1t_2JJ_FUNC,
+#endif
+#ifndef JNI64
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2II_FUNC,
+#else
+ memmove__Lorg_eclipse_swt_internal_cef3_cef_1download_1item_1t_2JJ_FUNC,
+#endif
+#ifndef JNI64
memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2II_FUNC,
#else
memmove__Lorg_eclipse_swt_internal_cef3_cef_1frame_1t_2JJ_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.c b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.c
index 9c366e2..6503c1b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.c
@@ -52,6 +52,40 @@ void setcef_base_tFields(JNIEnv *env, jobject lpObject, cef_base_t *lpStruct)
}
#endif
+#ifndef NO_cef_before_download_callback_t
+typedef struct cef_before_download_callback_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cont;
+} cef_before_download_callback_t_FID_CACHE;
+
+cef_before_download_callback_t_FID_CACHE cef_before_download_callback_tFc;
+
+void cachecef_before_download_callback_tFields(JNIEnv *env, jobject lpObject)
+{
+ if (cef_before_download_callback_tFc.cached) return;
+ cachecef_base_tFields(env, lpObject);
+ cef_before_download_callback_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ cef_before_download_callback_tFc.cont = (*env)->GetFieldID(env, cef_before_download_callback_tFc.clazz, "cont", I_J);
+ cef_before_download_callback_tFc.cached = 1;
+}
+
+cef_before_download_callback_t *getcef_before_download_callback_tFields(JNIEnv *env, jobject lpObject, cef_before_download_callback_t *lpStruct)
+{
+ if (!cef_before_download_callback_tFc.cached) cachecef_before_download_callback_tFields(env, lpObject);
+ getcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ lpStruct->cont = (void (CEF_CALLBACK *)(struct _cef_before_download_callback_t* self, const cef_string_t* download_path, int show_dialog))(*env)->GetIntLongField(env, lpObject, cef_before_download_callback_tFc.cont);
+ return lpStruct;
+}
+
+void setcef_before_download_callback_tFields(JNIEnv *env, jobject lpObject, cef_before_download_callback_t *lpStruct)
+{
+ if (!cef_before_download_callback_tFc.cached) cachecef_before_download_callback_tFields(env, lpObject);
+ setcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ (*env)->SetIntLongField(env, lpObject, cef_before_download_callback_tFc.cont, (jintLong)lpStruct->cont);
+}
+#endif
+
#ifndef NO_cef_browser_host_t
typedef struct cef_browser_host_t_FID_CACHE {
int cached;
@@ -397,6 +431,119 @@ void setcef_browser_tFields(JNIEnv *env, jobject lpObject, cef_browser_t *lpStru
}
#endif
+#ifndef NO_cef_download_item_callback_t
+typedef struct cef_download_item_callback_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cancel;
+} cef_download_item_callback_t_FID_CACHE;
+
+cef_download_item_callback_t_FID_CACHE cef_download_item_callback_tFc;
+
+void cachecef_download_item_callback_tFields(JNIEnv *env, jobject lpObject)
+{
+ if (cef_download_item_callback_tFc.cached) return;
+ cachecef_base_tFields(env, lpObject);
+ cef_download_item_callback_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ cef_download_item_callback_tFc.cancel = (*env)->GetFieldID(env, cef_download_item_callback_tFc.clazz, "cancel", I_J);
+ cef_download_item_callback_tFc.cached = 1;
+}
+
+cef_download_item_callback_t *getcef_download_item_callback_tFields(JNIEnv *env, jobject lpObject, cef_download_item_callback_t *lpStruct)
+{
+ if (!cef_download_item_callback_tFc.cached) cachecef_download_item_callback_tFields(env, lpObject);
+ getcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ lpStruct->cancel = (void (CEF_CALLBACK *)(struct _cef_before_download_callback_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_callback_tFc.cancel);
+ return lpStruct;
+}
+
+void setcef_download_item_callback_tFields(JNIEnv *env, jobject lpObject, cef_download_item_callback_t *lpStruct)
+{
+ if (!cef_download_item_callback_tFc.cached) cachecef_download_item_callback_tFields(env, lpObject);
+ setcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_callback_tFc.cancel, (jintLong)lpStruct->cancel);
+}
+#endif
+
+#ifndef NO_cef_download_item_t
+typedef struct cef_download_item_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID is_valid, is_in_progress, is_complete, is_canceled, get_current_speed, get_percent_complete, get_total_bytes, get_received_bytes, get_start_time, get_end_time, get_full_path, get_id, get_url, get_suggested_file_name, get_content_disposition, get_mime_type;
+} cef_download_item_t_FID_CACHE;
+
+cef_download_item_t_FID_CACHE cef_download_item_tFc;
+
+void cachecef_download_item_tFields(JNIEnv *env, jobject lpObject)
+{
+ if (cef_download_item_tFc.cached) return;
+ cachecef_base_tFields(env, lpObject);
+ cef_download_item_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ cef_download_item_tFc.is_valid = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "is_valid", I_J);
+ cef_download_item_tFc.is_in_progress = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "is_in_progress", I_J);
+ cef_download_item_tFc.is_complete = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "is_complete", I_J);
+ cef_download_item_tFc.is_canceled = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "is_canceled", I_J);
+ cef_download_item_tFc.get_current_speed = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_current_speed", I_J);
+ cef_download_item_tFc.get_percent_complete = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_percent_complete", I_J);
+ cef_download_item_tFc.get_total_bytes = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_total_bytes", I_J);
+ cef_download_item_tFc.get_received_bytes = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_received_bytes", I_J);
+ cef_download_item_tFc.get_start_time = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_start_time", I_J);
+ cef_download_item_tFc.get_end_time = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_end_time", I_J);
+ cef_download_item_tFc.get_full_path = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_full_path", I_J);
+ cef_download_item_tFc.get_id = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_id", I_J);
+ cef_download_item_tFc.get_url = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_url", I_J);
+ cef_download_item_tFc.get_suggested_file_name = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_suggested_file_name", I_J);
+ cef_download_item_tFc.get_content_disposition = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_content_disposition", I_J);
+ cef_download_item_tFc.get_mime_type = (*env)->GetFieldID(env, cef_download_item_tFc.clazz, "get_mime_type", I_J);
+ cef_download_item_tFc.cached = 1;
+}
+
+cef_download_item_t *getcef_download_item_tFields(JNIEnv *env, jobject lpObject, cef_download_item_t *lpStruct)
+{
+ if (!cef_download_item_tFc.cached) cachecef_download_item_tFields(env, lpObject);
+ getcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ lpStruct->is_valid = (int (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.is_valid);
+ lpStruct->is_in_progress = (int (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.is_in_progress);
+ lpStruct->is_complete = (int (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.is_complete);
+ lpStruct->is_canceled = (int (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.is_canceled);
+ lpStruct->get_current_speed = (int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_current_speed);
+ lpStruct->get_percent_complete = (int (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_percent_complete);
+ lpStruct->get_total_bytes = (int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_total_bytes);
+ lpStruct->get_received_bytes = (int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_received_bytes);
+ lpStruct->get_start_time = (cef_time_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_start_time);
+ lpStruct->get_end_time = (cef_time_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_end_time);
+ lpStruct->get_full_path = (cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_full_path);
+ lpStruct->get_id = (int32 (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_id);
+ lpStruct->get_url = (cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_url);
+ lpStruct->get_suggested_file_name = (cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_suggested_file_name);
+ lpStruct->get_content_disposition = (cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_content_disposition);
+ lpStruct->get_mime_type = (cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))(*env)->GetIntLongField(env, lpObject, cef_download_item_tFc.get_mime_type);
+ return lpStruct;
+}
+
+void setcef_download_item_tFields(JNIEnv *env, jobject lpObject, cef_download_item_t *lpStruct)
+{
+ if (!cef_download_item_tFc.cached) cachecef_download_item_tFields(env, lpObject);
+ setcef_base_tFields(env, lpObject, (cef_base_t *)lpStruct);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.is_valid, (jintLong)lpStruct->is_valid);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.is_in_progress, (jintLong)lpStruct->is_in_progress);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.is_complete, (jintLong)lpStruct->is_complete);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.is_canceled, (jintLong)lpStruct->is_canceled);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_current_speed, (jintLong)lpStruct->get_current_speed);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_percent_complete, (jintLong)lpStruct->get_percent_complete);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_total_bytes, (jintLong)lpStruct->get_total_bytes);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_received_bytes, (jintLong)lpStruct->get_received_bytes);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_start_time, (jintLong)lpStruct->get_start_time);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_end_time, (jintLong)lpStruct->get_end_time);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_full_path, (jintLong)lpStruct->get_full_path);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_id, (jintLong)lpStruct->get_id);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_url, (jintLong)lpStruct->get_url);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_suggested_file_name, (jintLong)lpStruct->get_suggested_file_name);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_content_disposition, (jintLong)lpStruct->get_content_disposition);
+ (*env)->SetIntLongField(env, lpObject, cef_download_item_tFc.get_mime_type, (jintLong)lpStruct->get_mime_type);
+}
+#endif
+
#ifndef NO_cef_frame_t
typedef struct cef_frame_t_FID_CACHE {
int cached;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.h b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.h
index cee33c4..2110923 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_structs.h
@@ -23,6 +23,18 @@ void setcef_base_tFields(JNIEnv *env, jobject lpObject, cef_base_t *lpStruct);
#define cef_base_t_sizeof() 0
#endif
+#ifndef NO_cef_before_download_callback_t
+void cachecef_before_download_callback_tFields(JNIEnv *env, jobject lpObject);
+cef_before_download_callback_t *getcef_before_download_callback_tFields(JNIEnv *env, jobject lpObject, cef_before_download_callback_t *lpStruct);
+void setcef_before_download_callback_tFields(JNIEnv *env, jobject lpObject, cef_before_download_callback_t *lpStruct);
+#define cef_before_download_callback_t_sizeof() sizeof(cef_before_download_callback_t)
+#else
+#define cachecef_before_download_callback_tFields(a,b)
+#define getcef_before_download_callback_tFields(a,b,c) NULL
+#define setcef_before_download_callback_tFields(a,b,c)
+#define cef_before_download_callback_t_sizeof() 0
+#endif
+
#ifndef NO_cef_browser_host_t
void cachecef_browser_host_tFields(JNIEnv *env, jobject lpObject);
cef_browser_host_t *getcef_browser_host_tFields(JNIEnv *env, jobject lpObject, cef_browser_host_t *lpStruct);
@@ -59,6 +71,30 @@ void setcef_browser_tFields(JNIEnv *env, jobject lpObject, cef_browser_t *lpStru
#define cef_browser_t_sizeof() 0
#endif
+#ifndef NO_cef_download_item_callback_t
+void cachecef_download_item_callback_tFields(JNIEnv *env, jobject lpObject);
+cef_download_item_callback_t *getcef_download_item_callback_tFields(JNIEnv *env, jobject lpObject, cef_download_item_callback_t *lpStruct);
+void setcef_download_item_callback_tFields(JNIEnv *env, jobject lpObject, cef_download_item_callback_t *lpStruct);
+#define cef_download_item_callback_t_sizeof() sizeof(cef_download_item_callback_t)
+#else
+#define cachecef_download_item_callback_tFields(a,b)
+#define getcef_download_item_callback_tFields(a,b,c) NULL
+#define setcef_download_item_callback_tFields(a,b,c)
+#define cef_download_item_callback_t_sizeof() 0
+#endif
+
+#ifndef NO_cef_download_item_t
+void cachecef_download_item_tFields(JNIEnv *env, jobject lpObject);
+cef_download_item_t *getcef_download_item_tFields(JNIEnv *env, jobject lpObject, cef_download_item_t *lpStruct);
+void setcef_download_item_tFields(JNIEnv *env, jobject lpObject, cef_download_item_t *lpStruct);
+#define cef_download_item_t_sizeof() sizeof(cef_download_item_t)
+#else
+#define cachecef_download_item_tFields(a,b)
+#define getcef_download_item_tFields(a,b,c) NULL
+#define setcef_download_item_tFields(a,b,c)
+#define cef_download_item_t_sizeof() 0
+#endif
+
#ifndef NO_cef_frame_t
void cachecef_frame_tFields(JNIEnv *env, jobject lpObject);
cef_frame_t *getcef_frame_tFields(JNIEnv *env, jobject lpObject, cef_frame_t *lpStruct);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
index d5080cc..610120b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
@@ -28,6 +28,7 @@ public class CEF extends WebBrowser {
Object[] pendingText, pendingUrl;
long /*int*/ windowHandle;
Hashtable ipcAdapters = new Hashtable(9);
+ Hashtable downloads = new Hashtable();
static boolean LibraryLoaded;
static CEFApp App;
@@ -251,6 +252,11 @@ public void create(Composite parent, int style) {
browser.addListener(SWT.KeyDown, listener); /* needed for tabbing into the Browser */
}
+public void createDownloadWindow(String filename, String url, int id) {
+ CEFDownload download = new CEFDownload(filename, url, browser);
+ downloads.put(new Integer(id), download);
+}
+
public boolean back() {
if (cefBrowser == null || cefBrowser.can_go_back() == 0) return false;
cefBrowser.go_back();
@@ -400,6 +406,13 @@ void onDispose(Event e) {
}
}
+void onDownloadProgress(long receivedBytes, long totalBytes, int completed, int inProgress, int cancelled, long /*int*/ pCallback,int id) {
+ boolean done = ((CEFDownload)downloads.get(new Integer(id))).updateStatus(receivedBytes, totalBytes, completed, inProgress, cancelled, pCallback);
+ if (done) {
+ downloads.remove(new Integer(id));
+ }
+}
+
void onIPCDispose(String id) {
CEFIPCSharedFile adapter = (CEFIPCSharedFile)ipcAdapters.get(id);
if (adapter != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
index 7f9250d..57bbd2f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
@@ -18,6 +18,7 @@ public class CEFClient {
CEF3Object object;
CEFContextMenuHandler contextMenuHandler;
CEFDisplayHandler displayHandler;
+ CEFDownloadHandler downloadHandler;
CEFFocusHandler focusHandler;
CEFLifeSpanHandler lifeSpanHandler;
CEFLoadHandler loadHandler;
@@ -73,6 +74,10 @@ synchronized int release() {
displayHandler.release();
displayHandler = null;
}
+ if (downloadHandler != null) {
+ downloadHandler.release();
+ downloadHandler = null;
+ }
if (focusHandler != null) {
focusHandler.release();
focusHandler = null;
@@ -123,8 +128,12 @@ long /*int*/ get_display_handler() {
}
long /*int*/ get_download_handler() {
- if (Device.DEBUG) System.out.println("get_download_handler (TODO)");
- return 0;
+ if (Device.DEBUG) System.out.println("get_download_handler (impl)");
+ if (downloadHandler == null) {
+ downloadHandler = new CEFDownloadHandler(host);
+ }
+ downloadHandler.add_ref();
+ return downloadHandler.getAddress();
}
long /*int*/ get_focus_handler() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFDownloadHandler.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFDownloadHandler.java
new file mode 100644
index 0000000..9ff5182
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFDownloadHandler.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.internal.cef3.*;
+
+public class CEFDownloadHandler {
+ CEF3Object object;
+ int refCount = 1;
+ CEF host;
+
+public CEFDownloadHandler(CEF host) {
+ super();
+ this.host = host;
+ object = new CEF3Object (new int[] {0, 0, 0, 4, 3}) {
+ public long /*int*/ method0(long /*int*/[] args) {return add_ref();}
+ public long /*int*/ method1(long /*int*/[] args) {return CEFDownloadHandler.this.release();}
+ public long /*int*/ method2(long /*int*/[] args) {return get_refct();}
+ public long /*int*/ method3(long /*int*/[] args) {return on_before_download(args[0], args[1], args[2], args[3]);}
+ public long /*int*/ method4(long /*int*/[] args) {return on_download_updated(args[0], args[1], args[2]);}
+ };
+}
+
+long /*int*/ getAddress () {
+ return object.getAddress ();
+}
+
+/* cef_base_t */
+
+synchronized int add_ref() {
+ refCount++;
+ return refCount;
+}
+
+synchronized int get_refct() {
+ return refCount;
+}
+
+synchronized int release() {
+ if (--refCount == 0) {
+ if (Device.DEBUG) System.out.println("release: CEFDownloadHandler");
+ if (object != null) {
+ object.dispose ();
+ }
+ object = null;
+ }
+ return refCount;
+}
+
+/* cef_download_handler_t */
+
+
+long /*int*/ on_before_download(long /*int*/ pBrowser, long /*int*/ pDownloadItem, long /*int*/ strSuggestedName, long /*int*/ pCallback) {
+ if (Device.DEBUG) System.out.println("on_before_download (impl)");
+ final CEFBeforeDownloadCallback callback = new CEFBeforeDownloadCallback(pCallback);
+ CEFDownloadItem downloadItem = new CEFDownloadItem(pDownloadItem);
+ final String suggestedName = CEF.ExtractCEFString(strSuggestedName);
+ long /*int*/ pUrl = downloadItem.getUrl();
+ final String url = CEF.ExtractCEFString(pUrl);
+ final int id = downloadItem.getId();
+ CEF3.cef_string_userfree_free(pUrl);
+ host.browser.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (host.browser.isDisposed()) return;
+ host.createDownloadWindow(suggestedName, url, id);
+ callback.cont();
+ callback.release();
+ }
+ });
+ new CEFBase(pBrowser).release();
+ downloadItem.release();
+ return 0;
+}
+
+long /*int*/ on_download_updated(long /*int*/ pBrowser, long /*int*/ pDownloadItem, final long /*int*/ pCallback) {
+ if (Device.DEBUG) System.out.println("on_download_updated (impl)");
+ CEFDownloadItem downloadItem = new CEFDownloadItem(pDownloadItem);
+ final long totalBytes = downloadItem.getTotalBytes();
+ final long receivedBytes = downloadItem.getReceivedBytes();
+ final int completed = downloadItem.isComplete();
+ final int inProgress = downloadItem.isInProgress();
+ final int cancelled = downloadItem.isCancelled();
+ final int id = downloadItem.getId();
+ host.browser.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (host.browser.isDisposed()) return;
+ host.onDownloadProgress(receivedBytes, totalBytes, completed, inProgress, cancelled, pCallback, id);
+ }
+ });
+ downloadItem.release();
+ new CEFBase(pBrowser).release();
+ return 0;
+}
+
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
index 654e902..81dad70 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
@@ -69,6 +69,26 @@ public static final native void memmove(cef_browser_host_t dest, long /*int*/ sr
* @param src cast=(const void *)
* @param size cast=(size_t)
*/
+public static final native void memmove(cef_before_download_callback_t dest, long /*int*/ src, long /*int*/ size);
+
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
+public static final native void memmove(cef_download_item_t dest, long /*int*/ src, long /*int*/ size);
+
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
+public static final native void memmove(cef_download_item_callback_t dest, long /*int*/ src, long /*int*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove(cef_frame_t dest, long /*int*/ src, long /*int*/ size);
/**
@@ -102,12 +122,18 @@ public static final native int callFuncInt(long /*int*/ address, long /*int*/ ar
/** @method convention=CEF_CALLBACK */
public static final native int callFuncInt(long /*int*/ address, long /*int*/ arg0, int arg1, cef_string_t arg2);
/** @method convention=CEF_CALLBACK */
+public static final native long callFuncLong(long /*int*/ address, long /*int*/ arg0);
+/** @method convention=CEF_CALLBACK */
public static final native long /*int*/ callFuncPtr(long /*int*/ address, long /*int*/ arg0);
/** @method convention=CEF_CALLBACK */
public static final native long /*int*/ callFuncPtr(long /*int*/ address, long /*int*/ arg0, int arg1);
/** @method convention=CEF_CALLBACK */
+public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0);
+/** @method convention=CEF_CALLBACK */
public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, cef_string_t arg1);
/** @method convention=CEF_CALLBACK */
+public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, cef_string_t arg1, int arg2);
+/** @method convention=CEF_CALLBACK */
public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, cef_string_t arg1, cef_string_t arg2);
/** @method convention=CEF_CALLBACK */
public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, int arg3);
@@ -121,6 +147,9 @@ public static final native int cef_base_t_sizeof();
public static final native int cef_browser_t_sizeof();
public static final native int cef_browser_host_t_sizeof();
public static final native int cef_browser_settings_t_sizeof();
+public static final native int cef_before_download_callback_t_sizeof();
+public static final native int cef_download_item_t_sizeof();
+public static final native int cef_download_item_callback_t_sizeof();
public static final native int cef_frame_t_sizeof();
public static final native int cef_list_value_t_sizeof();
public static final native int cef_process_message_t_sizeof();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFBeforeDownloadCallback.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFBeforeDownloadCallback.java
new file mode 100644
index 0000000..7d596ae
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFBeforeDownloadCallback.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.cef3;
+
+import org.eclipse.swt.browser.CEF;
+
+public class CEFBeforeDownloadCallback extends CEFBase {
+ cef_before_download_callback_t struct;
+
+ public CEFBeforeDownloadCallback(long /*int*/ address) {
+ super(address);
+ struct = new cef_before_download_callback_t();
+ CEF3.memmove(struct, address, cef_before_download_callback_t.sizeof);
+ }
+
+ public void cont() {
+ CEF3.callFuncVoid(struct.cont, address,CEF.CEFSTRING_EMPTY,1);
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownload.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownload.java
new file mode 100644
index 0000000..a00479a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownload.java
@@ -0,0 +1,92 @@
+package org.eclipse.swt.internal.cef3;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+public class CEFDownload {
+ Label statusLabel;
+ Button cancel;
+ Shell shell;
+ boolean cancelled = false;
+ long receivedBytes = 0;
+
+ public CEFDownload(String filename, String url, Browser browser) {
+ shell = new Shell();
+ String msg = Compatibility.getMessage("SWT_FileDownload"); //$NON-NLS-1$
+ shell.setText (msg);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.marginHeight = 15;
+ gridLayout.marginWidth = 15;
+ gridLayout.verticalSpacing = 20;
+ shell.setLayout(gridLayout);
+
+ msg = Compatibility.getMessage("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+ Label nameLabel = new Label(shell, SWT.WRAP);
+ nameLabel.setText (msg);
+ GridData data = new GridData();
+ Monitor monitor = browser.getMonitor();
+ int maxWidth = monitor.getBounds().width / 2;
+ int width = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ data.widthHint = Math.min(width, maxWidth);
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ nameLabel.setLayoutData(data);
+
+ statusLabel = new Label(shell, SWT.NONE);
+ statusLabel.setText(Compatibility.getMessage("SWT_Download_Started")); //$NON-NLS-1$
+ data = new GridData(GridData.FILL_BOTH);
+ statusLabel.setLayoutData (data);
+
+ cancel = new Button(shell, SWT.PUSH);
+ cancel.setText(Compatibility.getMessage("SWT_Cancel")); //$NON-NLS-1$
+ data = new GridData();
+ data.horizontalAlignment = GridData.CENTER;
+ cancel.setLayoutData(data);
+ final Listener cancelListener = new Listener () {
+ public void handleEvent(Event event) {
+ cancelled = true;
+ }
+ };
+ cancel.addListener(SWT.Selection, cancelListener);
+
+ shell.pack();
+ shell.open();
+ }
+
+ private void close() {
+ cancel = null;
+ statusLabel = null;
+ shell.dispose();
+ shell = null;
+ }
+
+ public synchronized boolean updateStatus(long receivedBytes, long totalbytes, int completed, int inProgress, int cancelled, long /*int*/ pCallback){
+ if (receivedBytes >= this.receivedBytes) {
+ this.receivedBytes = receivedBytes;
+ if (this.cancelled || cancelled == 1) {
+ this.cancelled = true;
+ CEFDownloadItemCallback callback = new CEFDownloadItemCallback(pCallback);
+ close();
+ callback.cancel();
+ callback.release();
+ return true;
+ }
+ // If I understand correctly it is possible for a download to complete before you cancel it.
+ // Thus we should only consider the download complete if it is in progress.
+ if (inProgress == 1 && completed == 1) {
+ close();
+ new CEFBase(pCallback).release();
+ return true;
+ }
+
+ String message = Compatibility.getMessage ("SWT_Download_Status", new Object[] {new Long(receivedBytes / 1024L), new Long(totalbytes / 1024L)}); //$NON-NLS-1$
+ statusLabel.setText (message);
+ new CEFBase(pCallback).release();
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItem.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItem.java
new file mode 100644
index 0000000..7565cf3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItem.java
@@ -0,0 +1,40 @@
+package org.eclipse.swt.internal.cef3;
+
+public class CEFDownloadItem extends CEFBase {
+ cef_download_item_t struct;
+
+ public CEFDownloadItem(long /*int*/ address) {
+ super(address);
+ struct = new cef_download_item_t();
+ CEF3.memmove(struct, address, cef_download_item_t.sizeof);
+ }
+
+ public long /*int*/ getUrl() {
+ return CEF3.callFuncPtr(struct.get_url, address);
+ }
+
+ public int getId() {
+ return CEF3.callFuncInt(struct.get_id, address);
+ }
+
+ public long getTotalBytes() {
+ return CEF3.callFuncLong(struct.get_total_bytes,address);
+ }
+
+ public long getReceivedBytes() {
+ return CEF3.callFuncLong(struct.get_received_bytes,address);
+ }
+
+ public int isComplete() {
+ return CEF3.callFuncInt(struct.is_complete, address);
+ }
+
+ public int isInProgress() {
+ return CEF3.callFuncInt(struct.is_in_progress, address);
+ }
+
+ public int isCancelled() {
+ return CEF3.callFuncInt(struct.is_canceled, address);
+ }
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItemCallback.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItemCallback.java
new file mode 100644
index 0000000..640dbc7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFDownloadItemCallback.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.cef3;
+
+public class CEFDownloadItemCallback extends CEFBase {
+ cef_download_item_callback_t struct;
+
+ public CEFDownloadItemCallback(long /*int*/ address) {
+ super(address);
+ struct = new cef_download_item_callback_t();
+ CEF3.memmove(struct, address, cef_download_item_callback_t.sizeof);
+ }
+
+ public void cancel() {
+ CEF3.callFuncVoid(struct.cancel, address);
+ }
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_before_download_callback_t.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_before_download_callback_t.java
new file mode 100644
index 0000000..489f9c3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_before_download_callback_t.java
@@ -0,0 +1,9 @@
+package org.eclipse.swt.internal.cef3;
+
+public class cef_before_download_callback_t extends cef_base_t {
+
+ /** @field cast="(void (CEF_CALLBACK *)(struct _cef_before_download_callback_t* self, const cef_string_t* download_path, int show_dialog))" */
+ public long /*int*/ cont;
+
+ public static final int sizeof = CEF3.cef_before_download_callback_t_sizeof ();
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_callback_t.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_callback_t.java
new file mode 100644
index 0000000..8118dd5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_callback_t.java
@@ -0,0 +1,9 @@
+package org.eclipse.swt.internal.cef3;
+
+public class cef_download_item_callback_t extends cef_base_t {
+
+ /** @field cast="(void (CEF_CALLBACK *)(struct _cef_before_download_callback_t* self))" */
+ public long /*int*/ cancel;
+
+ public static final int sizeof = CEF3.cef_download_item_callback_t_sizeof ();
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_t.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_t.java
new file mode 100644
index 0000000..14eac46
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_download_item_t.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.internal.cef3;
+
+public class cef_download_item_t extends cef_base_t {
+
+ /** @field cast="(int (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ is_valid;
+
+ /** @field cast="(int (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ is_in_progress;
+
+ /** @field cast="(int (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ is_complete;
+
+ /** @field cast="(int (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ is_canceled;
+
+ /** @field cast="(int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_current_speed;
+
+ /** @field cast="(int (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_percent_complete;
+
+ /** @field cast="(int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_total_bytes;
+
+ /** @field cast="(int64 (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_received_bytes;
+
+ /** @field cast="(cef_time_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_start_time;
+
+ /** @field cast="(cef_time_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_end_time;
+
+ /** @field cast="(cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_full_path;
+
+ /** @field cast="(int32 (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_id;
+
+ /** @field cast="(cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_url;
+
+ /** @field cast="(cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_suggested_file_name;
+
+ /** @field cast="(cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_content_disposition;
+
+ /** @field cast="(cef_string_userfree_t (CEF_CALLBACK *)(struct _cef_download_item_t* self))" */
+ public long /*int*/ get_mime_type;
+
+ public static final int sizeof = CEF3.cef_download_item_t_sizeof();
+}