Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2013-03-13 21:16:26 +0000
committerGrant Gayed2013-03-13 21:16:26 +0000
commit20f05d860fe44a4a043edce0681ee4d54086278c (patch)
treed6b016f4de3bbea8a69f67510ab05e8c827ce09a
parent93cc605fb5cb2db4e08b3cdd70304cfc693beb6d (diff)
downloadeclipse.platform.swt-20f05d860fe44a4a043edce0681ee4d54086278c.tar.gz
eclipse.platform.swt-20f05d860fe44a4a043edce0681ee4d54086278c.tar.xz
eclipse.platform.swt-20f05d860fe44a4a043edce0681ee4d54086278c.zip
implement execute() and ensure that alloc'd strings are being freed
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java47
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java4
6 files changed, 65 insertions, 19 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 28b44b9f24..39620a959f 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
@@ -83,6 +83,27 @@ JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__JJJ)(JNIEnv *env, jclass that,
}
#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)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__JJJJI)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3, jint arg4)
+#endif
+{
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__IIIII_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__JJJJI_FUNC);
+#endif
+ ((void (CEF_CALLBACK*)())arg0)(arg1, arg2, arg3, arg4);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__IIIII_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__JJJJI_FUNC);
+#endif
+}
+#endif
+
#ifndef NO_cef_1base_1t_1sizeof
JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1base_1t_1sizeof)
(JNIEnv *env, jclass that)
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 3036f4c9a0..b3874f1993 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
@@ -27,6 +27,11 @@ char * CEF3_nativeFunctionNames[] = {
#else
"callFuncVoid__JJJ",
#endif
+#ifndef JNI64
+ "callFuncVoid__IIIII",
+#else
+ "callFuncVoid__JJJJI",
+#endif
"cef_1base_1t_1sizeof",
"cef_1browser_1host_1create_1browser",
"cef_1browser_1host_1t_1sizeof",
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 ab650f8c96..e90443c9cc 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
@@ -37,6 +37,11 @@ typedef enum {
#else
callFuncVoid__JJJ_FUNC,
#endif
+#ifndef JNI64
+ callFuncVoid__IIIII_FUNC,
+#else
+ callFuncVoid__JJJJI_FUNC,
+#endif
cef_1base_1t_1sizeof_FUNC,
cef_1browser_1host_1create_1browser_FUNC,
cef_1browser_1host_1t_1sizeof_FUNC,
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 edb5d701b6..44116a3b3e 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
@@ -60,9 +60,9 @@ public class CEF extends WebBrowser {
Library.loadLibrary("swt-cef3"); // $NON-NLS-1$
/* initialize STRING_EMPTY */
- long /*int*/ string = CreateCEFString("");
+ long /*int*/ pString = CreateCEFString(""); /* leaked */
STRING_EMPTY = new cef_string_t();
- CEF3.memmove(STRING_EMPTY, string, cef_string_t.sizeof);
+ CEF3.memmove(STRING_EMPTY, pString, cef_string_t.sizeof);
/* initialize CEF3 */
cef_main_args_t args = new cef_main_args_t();
@@ -108,6 +108,7 @@ public class CEF extends WebBrowser {
CEF3.memmove(settings.browser_subprocess_path, subprocessPath, cef_string_t.sizeof);
App.add_ref();
int rc = CEF3.cef_initialize(args, settings, App.getAddress());
+ CEF3.cef_string_userfree_free(subprocessPath);
if (rc != 0) {
LibraryLoaded = true;
} else {
@@ -172,13 +173,13 @@ static long /*int*/ CreateCEFString(String string) {
return result;
}
-static String ExtractCEFString(long /*int*/ stringPointer) {
- if (stringPointer == 0) {
+static String ExtractCEFString(long /*int*/ pString) {
+ if (pString == 0) {
return "";
}
cef_string_t cefStringUrl = new cef_string_t();
- CEF3.memmove(cefStringUrl, stringPointer, CEF3.cef_string_t_sizeof());
+ CEF3.memmove(cefStringUrl, pString, CEF3.cef_string_t_sizeof());
int length = (int)/*64*/cefStringUrl.length;
char[] chars = new char[length];
@@ -207,10 +208,11 @@ public void create(Composite parent, int style) {
cef_browser_settings_t browserSettings = new cef_browser_settings_t();
browserSettings.size = cef_browser_settings_t.sizeof;
- long /*int*/ url = CreateCEFString("about:blank");
+ long /*int*/ pUrl = CreateCEFString("about:blank");
client = new CEFClient(this);
client.add_ref();
- int rc = CEF3.cef_browser_host_create_browser(windowInfo, client.getAddress(), url, browserSettings);
+ int rc = CEF3.cef_browser_host_create_browser(windowInfo, client.getAddress(), pUrl, browserSettings);
+ CEF3.cef_string_userfree_free(pUrl);
if (rc == 0) {
return;
}
@@ -276,8 +278,14 @@ void browserCreated(long /*int*/ handle) {
public boolean execute(String script) {
if (cefBrowser == null) return false;
- // TODO
- return false;
+ long /*int*/ pFrame = cefBrowser.get_main_frame();
+ CEFFrame mainFrame = new CEFFrame(pFrame);
+ long /*int*/ pScript = CreateCEFString(script);
+ long /*int*/ pUrl = CreateCEFString(getUrl());
+ mainFrame.execute_java_script(pScript, pUrl, 0);
+ CEF3.cef_string_userfree_free(pUrl);
+ CEF3.cef_string_userfree_free(pScript);
+ return true;
}
public boolean forward() {
@@ -309,13 +317,13 @@ public String getUrl() {
return ABOUT_BLANK;
}
- long /*int*/ result = cefBrowser.get_main_frame();
- if (result == 0) {
+ long /*int*/ pFrame = cefBrowser.get_main_frame();
+ if (pFrame == 0) {
return null;
}
- CEFFrame frame = new CEFFrame(result);
- long /*int*/ url = frame.get_url();
- String javaStringUrl = ExtractCEFString(url);
+ CEFFrame frame = new CEFFrame(pFrame);
+ long /*int*/ pUrl = frame.get_url();
+ String javaStringUrl = ExtractCEFString(pUrl);
/*
* If the URI indicates that the page is being rendered from memory
@@ -447,14 +455,15 @@ public boolean setUrl(String url, String postData, String[] headers) {
}
// TODO postData, headers...
- long /*int*/ result = cefBrowser.get_main_frame();
- if (result == 0) {
+ long /*int*/ pFrame = cefBrowser.get_main_frame();
+ if (pFrame == 0) {
return false;
}
- CEFFrame frame = new CEFFrame(result);
- long /*int*/ urlPtr = CreateCEFString(url);
- frame.load_url(urlPtr);
+ CEFFrame frame = new CEFFrame(pFrame);
+ long /*int*/ pUrl = CreateCEFString(url);
+ frame.load_url(pUrl);
+ CEF3.cef_string_userfree_free(pUrl);
return true;
}
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 c074a863bc..79d162f835 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
@@ -87,6 +87,8 @@ public static final native void callFuncVoid(long /*int*/ address, long /*int*/
public static final native long /*int*/ callFuncPtr(long /*int*/ address, long /*int*/ arg0);
/** @method convention=CEF_CALLBACK */
public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, long /*int*/ arg1);
+/** @method convention=CEF_CALLBACK */
+public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, int arg3);
/* 64 bit */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
index 9f18511a3d..7ccca6c179 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
@@ -32,4 +32,8 @@ public boolean is_main() {
return CEF3.callFuncInt(struct.is_main, address) != 0;
}
+public void execute_java_script(long /*int*/ code, long /*int*/ script_url, int start_line) {
+ CEF3.callFuncVoid(struct.execute_java_script, address, code, script_url, start_line);
+}
+
}

Back to the top