diff options
author | Benoit Hiller | 2013-03-18 16:39:45 -0400 |
---|---|---|
committer | Grant Gayed | 2013-03-21 10:39:14 -0400 |
commit | 5ae1a74671f9ebd34f8f905ba3b492c54859381b (patch) | |
tree | cb4c490e17c924bf3df48f74ae5a9724d866d8a5 | |
parent | 20f05d860fe44a4a043edce0681ee4d54086278c (diff) | |
download | eclipse.platform.swt-5ae1a74671f9ebd34f8f905ba3b492c54859381b.zip eclipse.platform.swt-5ae1a74671f9ebd34f8f905ba3b492c54859381b.tar.gz eclipse.platform.swt-5ae1a74671f9ebd34f8f905ba3b492c54859381b.tar.xz |
untrusted setText and version checking
setText is for the most part more straightforward in CEF than in the other
browsers. Title events are fired correctly even in the absence of titles
and it appears to fire loading events correctly. However trusted
navigation is not currently working. The load_string method provided by
frame appears to refuse to run with the url set to a native url. If you
navigate manually to a native url first then attempt to set the text with
the url specified as the root it will not run. The code returns the error
-310, too many redirects.
As for the isInstalled, cef3 gives us the revision number. I just check if
it is leq the current one.
7 files changed, 70 insertions, 4 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 39620a9..c524aa2 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__IIII) && !defined(JNI64)) || (!defined(NO_callFuncVoid__JJJJ) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__IIII)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(callFuncVoid__JJJJ)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3)
+#endif
+{
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__IIII_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, callFuncVoid__JJJJ_FUNC);
+#endif
+ ((void (CEF_CALLBACK*)())arg0)(arg1, arg2, arg3);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__IIII_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, callFuncVoid__JJJJ_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)
@@ -171,6 +192,18 @@ JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1browser_1t_1sizeof) }
#endif
+#ifndef NO_cef_1build_1revision
+JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1build_1revision)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ CEF3_NATIVE_ENTER(env, that, cef_1build_1revision_FUNC);
+ rc = (jint)cef_build_revision();
+ CEF3_NATIVE_EXIT(env, that, cef_1build_1revision_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)
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 b3874f1..8bda387 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 @@ -28,6 +28,11 @@ char * CEF3_nativeFunctionNames[] = { "callFuncVoid__JJJ",
#endif
#ifndef JNI64
+ "callFuncVoid__IIII",
+#else
+ "callFuncVoid__JJJJ",
+#endif
+#ifndef JNI64
"callFuncVoid__IIIII",
#else
"callFuncVoid__JJJJI",
@@ -37,6 +42,7 @@ char * CEF3_nativeFunctionNames[] = { "cef_1browser_1host_1t_1sizeof",
"cef_1browser_1settings_1t_1sizeof",
"cef_1browser_1t_1sizeof",
+ "cef_1build_1revision",
"cef_1execute_1process",
"cef_1frame_1t_1sizeof",
"cef_1initialize",
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 e90443c..44f5aa3 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 @@ -38,6 +38,11 @@ typedef enum { callFuncVoid__JJJ_FUNC,
#endif
#ifndef JNI64
+ callFuncVoid__IIII_FUNC,
+#else
+ callFuncVoid__JJJJ_FUNC,
+#endif
+#ifndef JNI64
callFuncVoid__IIIII_FUNC,
#else
callFuncVoid__JJJJI_FUNC,
@@ -47,6 +52,7 @@ typedef enum { cef_1browser_1host_1t_1sizeof_FUNC,
cef_1browser_1settings_1t_1sizeof_FUNC,
cef_1browser_1t_1sizeof_FUNC,
+ cef_1build_1revision_FUNC,
cef_1execute_1process_FUNC,
cef_1frame_1t_1sizeof_FUNC,
cef_1initialize_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 44116a3..12ec02d 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 @@ -21,9 +21,10 @@ import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*;
public class CEF extends WebBrowser {
- boolean ignoreDispose, creatingBrowser;
+ boolean creatingBrowser, ignoreDispose;
CEFClient client;
CEFBrowser cefBrowser;
+ String htmlText;
Object[] pendingText, pendingUrl;
long /*int*/ windowHandle;
@@ -37,6 +38,7 @@ public class CEF extends WebBrowser { static final String CEF3_PATH = "org.eclipse.swt.browser.CEF3Path"; //$NON-NLS-1$
static final String URI_FILEROOT = "file:///"; //$NON-NLS-1$
static final int MAX_PROGRESS = 100;
+ static final int CEF3_SUPPORTED_REVISON = 1094;
static {
/*
@@ -189,7 +191,7 @@ static String ExtractCEFString(long /*int*/ pString) { static boolean IsInstalled() {
if (!LibraryLoaded) return false;
- // TODO if CEF3 has API to get its version then verify that it is supported, for now assume that it is
+ if (CEF3.cef_build_revision() < CEF3_SUPPORTED_REVISON) return false;
return true;
}
@@ -442,7 +444,18 @@ public boolean setText(String html, boolean trusted) { return true;
}
- // TODO
+ long /*int*/ pFrame = cefBrowser.get_main_frame();
+ if (pFrame == 0) {
+ return false;
+ }
+ CEFFrame frame = new CEFFrame(pFrame);
+
+ long /*int*/ pHtml = CreateCEFString(html);
+ long /*int*/ pUrl = CreateCEFString(ABOUT_BLANK);
+ frame.load_string(pHtml, pUrl);
+ CEF3.cef_string_userfree_free(pHtml);
+ CEF3.cef_string_userfree_free(pUrl);
+
return false;
}
@@ -472,6 +485,7 @@ public void stop() { pendingText = pendingUrl = null;
return;
}
+
cefBrowser.stop_load();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java index 25ccc10..2150e7c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java +++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java @@ -82,7 +82,7 @@ long /*int*/ on_load_end(long /*int*/ browser, long /*int*/ frame, int httpStatu long /*int*/ on_load_error(long /*int*/ browser, long /*int*/ frame, int errorCode, long /*int*/ errorText, long /*int*/ failedUrl) {
/* possibly useful if on_load_end() not received for load errors */
- if (Device.DEBUG) System.out.println("on_load_error");
+ if (Device.DEBUG) System.out.println("on_load_error code:" + errorCode + " text: " + CEF.ExtractCEFString(errorText) );
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 79d162f..f996158 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 @@ -88,6 +88,8 @@ public static final native long /*int*/ callFuncPtr(long /*int*/ address, long / /** @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);
+/** @method convention=CEF_CALLBACK */
public static final native void callFuncVoid(long /*int*/ address, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, int arg3);
@@ -100,5 +102,6 @@ public static final native int cef_browser_settings_t_sizeof(); public static final native int cef_frame_t_sizeof();
public static final native int cef_settings_t_sizeof();
public static final native int cef_string_t_sizeof();
+public static final native int cef_build_revision();
}
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 7ccca6c..93a4a31 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 @@ -24,6 +24,10 @@ public void load_url(long /*int*/ url) { CEF3.callFuncVoid(struct.load_url, address, url);
}
+public void load_string(long /*int*/ string, long /*int*/ url) {
+ CEF3.callFuncVoid(struct.load_string, address, string, url);
+}
+
public long /*int*/ get_url() {
return CEF3.callFuncPtr(struct.get_url, address);
}
|