bool JSDialogHandler::OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin_url, CefJSDialogHandler::JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr<CefJSDialogCallback> callback, bool& suppress_message) { JNIEnv* env = GetJNIEnv(); if (!env) return false; jobject jdialogType = NULL; switch (dialog_type) { default: JNI_CASE(env, "org/cef/handler/CefJSDialogHandler$JSDialogType", JSDIALOGTYPE_ALERT, jdialogType); JNI_CASE(env, "org/cef/handler/CefJSDialogHandler$JSDialogType", JSDIALOGTYPE_CONFIRM, jdialogType); JNI_CASE(env, "org/cef/handler/CefJSDialogHandler$JSDialogType", JSDIALOGTYPE_PROMPT, jdialogType); } jobject jboolRef = NewJNIBoolRef(env, suppress_message); if (!jboolRef) return false; jobject jcallback = NewJNIObject(env, "org/cef/callback/CefJSDialogCallback_N"); if (!jcallback) return false; SetCefForJNIObject(env, jcallback, callback.get(), "CefJSDialogCallback"); jboolean jresult = JNI_FALSE; JNI_CALL_METHOD( env, jhandler_, "onJSDialog", "(Lorg/cef/browser/CefBrowser;Ljava/lang/String;" "Lorg/cef/handler/CefJSDialogHandler$JSDialogType;Ljava/lang/String;" "Ljava/lang/String;Lorg/cef/callback/CefJSDialogCallback;Lorg/cef/misc/" "BoolRef;)Z", Boolean, jresult, GetJNIBrowser(browser), NewJNIString(env, origin_url), jdialogType, NewJNIString(env, message_text), NewJNIString(env, default_prompt_text), jcallback, jboolRef); suppress_message = GetJNIBoolRef(env, jboolRef); if (jresult == JNI_FALSE) { // If the java method returns "false", the callback won't be used and // therefore the reference can be removed. SetCefForJNIObject<CefJSDialogCallback>(env, jcallback, NULL, "CefJSDialogCallback"); } return (jresult != JNI_FALSE); }
JNIEXPORT jobject JNICALL Java_org_cef_misc_CefPrintSettings_1N_N_1GetDuplexMode (JNIEnv *env, jobject obj) { jobject result = GetJNIEnumValue(env, "org/cef/misc/CefPrintSettings$DuplexMode", "DUPLEX_MODE_UNKNOWN"); CefRefPtr<CefPrintSettings> settings = GetCefFromJNIObject<CefPrintSettings>(env, obj, "CefPrintSettings"); if (!settings) return result; switch (settings->GetDuplexMode()) { JNI_CASE(env, "org/cef/misc/CefPrintSettings$DuplexMode", DUPLEX_MODE_SIMPLEX, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$DuplexMode", DUPLEX_MODE_LONG_EDGE, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$DuplexMode", DUPLEX_MODE_SHORT_EDGE, result); default: JNI_CASE(env, "org/cef/misc/CefPrintSettings$DuplexMode", DUPLEX_MODE_UNKNOWN, result); } return result; }
jobject getjEvent(JNIEnv* env, const CefKeyEvent& event) { jobject jkeyEventType = NULL; switch (event.type) { default: JNI_CASE(env, "org/cef/handler/CefKeyboardHandler$CefKeyEvent$EventType", KEYEVENT_RAWKEYDOWN, jkeyEventType); JNI_CASE(env, "org/cef/handler/CefKeyboardHandler$CefKeyEvent$EventType", KEYEVENT_KEYDOWN, jkeyEventType); JNI_CASE(env, "org/cef/handler/CefKeyboardHandler$CefKeyEvent$EventType", KEYEVENT_KEYUP, jkeyEventType); JNI_CASE(env, "org/cef/handler/CefKeyboardHandler$CefKeyEvent$EventType", KEYEVENT_CHAR, jkeyEventType); } jobject jevent = NewJNIObject(env, "org/cef/handler/CefKeyboardHandler$CefKeyEvent", "(Lorg/cef/handler/CefKeyboardHandler$CefKeyEvent$EventType;IIIZCCZ)V", jkeyEventType, event.modifiers, event.windows_key_code, event.native_key_code, (event.is_system_key != 0 ? JNI_TRUE : JNI_FALSE), event.character, event.unmodified_character, (event.focus_on_editable_field != 0 ? JNI_TRUE : JNI_FALSE)); return jevent; }
JNIEXPORT jobject JNICALL Java_org_cef_callback_CefContextMenuParams_1N_N_1GetMediaType (JNIEnv *env, jobject obj) { CefRefPtr<CefContextMenuParams> menuParams = GetCefFromJNIObject<CefContextMenuParams>(env, obj, "CefContextMenuParams"); jobject result = GetJNIEnumValue(env, "org/cef/callback/CefContextMenuParams$MediaType", "CM_MEDIATYPE_NONE"); if (!menuParams.get()) return result; switch (menuParams->GetMediaType()) { JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_IMAGE, result); JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_VIDEO, result); JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_AUDIO, result); JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_FILE, result); JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_PLUGIN, result); default: JNI_CASE(env, "org/cef/callback/CefContextMenuParams$MediaType", CM_MEDIATYPE_NONE, result); } return result; }
jobject NewJNIErrorCode(JNIEnv* env, cef_errorcode_t errorCode) { jobject jerrorCode = NULL; switch (errorCode) { default: JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_NONE, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_FAILED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_ABORTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INVALID_ARGUMENT, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INVALID_HANDLE, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_FILE_NOT_FOUND, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_TIMED_OUT, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_FILE_TOO_BIG, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_UNEXPECTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_ACCESS_DENIED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_NOT_IMPLEMENTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CONNECTION_CLOSED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CONNECTION_RESET, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CONNECTION_REFUSED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CONNECTION_ABORTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CONNECTION_FAILED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_NAME_NOT_RESOLVED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INTERNET_DISCONNECTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_SSL_PROTOCOL_ERROR, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_ADDRESS_INVALID, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_ADDRESS_UNREACHABLE, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_SSL_CLIENT_AUTH_CERT_NEEDED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_TUNNEL_CONNECTION_FAILED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_NO_SSL_VERSIONS_ENABLED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_SSL_VERSION_OR_CIPHER_MISMATCH, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_SSL_RENEGOTIATION_REQUESTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_COMMON_NAME_INVALID, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_DATE_INVALID, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_AUTHORITY_INVALID, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_CONTAINS_ERRORS, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_NO_REVOCATION_MECHANISM, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_UNABLE_TO_CHECK_REVOCATION, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_REVOKED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_INVALID, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CERT_END, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INVALID_URL, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_DISALLOWED_URL_SCHEME, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_UNKNOWN_URL_SCHEME, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_TOO_MANY_REDIRECTS, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_UNSAFE_REDIRECT, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_UNSAFE_PORT, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INVALID_RESPONSE, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INVALID_CHUNKED_ENCODING, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_METHOD_NOT_SUPPORTED, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_UNEXPECTED_PROXY_AUTH, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_EMPTY_RESPONSE, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_RESPONSE_HEADERS_TOO_BIG, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_CACHE_MISS, jerrorCode); JNI_CASE(env, "org/cef/handler/CefLoadHandler$ErrorCode", ERR_INSECURE_RESPONSE, jerrorCode); } return jerrorCode; }
JNIEXPORT jobject JNICALL Java_org_cef_misc_CefPrintSettings_1N_N_1GetColorModel (JNIEnv *env, jobject obj) { jobject result = GetJNIEnumValue(env, "org/cef/misc/CefPrintSettings$ColorModel", "COLOR_MODEL_UNKNOWN"); CefRefPtr<CefPrintSettings> settings = GetCefFromJNIObject<CefPrintSettings>(env, obj, "CefPrintSettings"); if (!settings) return result; switch (settings->GetColorModel()) { JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_GRAY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMYK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_KCMY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMY_K, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_BLACK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_GRAYSCALE, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGB, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGB16, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGBA, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLORMODE_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLORMODE_MONOCHROME, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_HP_COLOR_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_HP_COLOR_BLACK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PRINTOUTMODE_NORMAL, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_CMYK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_RGB, result); default: JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_UNKNOWN, result); } return result; }