Esempio n. 1
0
void GetJNIStringVector(JNIEnv* env, jobject jvector,
                        std::vector<CefString>& vals) {
  if (!jvector)
    return;

  jint jsize=0;
  JNI_CALL_METHOD(env, jvector, "size", "()I", Int, jsize);

  for (jint index=0; index< jsize; index++) {
    jobject str=NULL;
    JNI_CALL_METHOD(env, jvector, "get", "(I)Ljava/lang/Object;", Object, str, index);
    vals.push_back(GetJNIString(env, (jstring)str));
  }
}
JNIEXPORT void JNICALL Java_org_cef_network_CefResponse_1N_N_1SetHeaderMap
  (JNIEnv *env, jobject obj, jobject jheaderMap) {
  CefRefPtr<CefResponse> response = GetCefFromJNIObject<CefResponse>(env, obj, "CefResponse");
  if (!response)
    return;

  // public abstract java.util.Set<java.util.Map$Entry<K, V>> entrySet();
  jobject entrySet = NULL;
  JNI_CALL_METHOD(env, jheaderMap,
                  "entrySet",
                  "()Ljava/util/Set;",
                  Object,
                  entrySet);
  if (!entrySet)
    return;

  // public abstract java.lang.Object[] toArray();
  jobject entrySetValues = NULL;
  JNI_CALL_METHOD(env, entrySet,
                  "toArray",
                  "()[Ljava/lang/Object;",
                  Object,
                  entrySetValues);
  if (!entrySetValues)
    return;

  CefResponse::HeaderMap headerMap;
  jint length = env->GetArrayLength((jobjectArray)entrySetValues);
  for (jint i=0; i < length; i++) {
    jobject mapEntry = env->GetObjectArrayElement((jobjectArray)entrySetValues, i);
    if (!mapEntry)
      return;
    jobject key = NULL;
    jobject value = NULL;
    JNI_CALL_METHOD(env, mapEntry,
                    "getKey",
                    "()Ljava/lang/Object;",
                    Object,
                    key);
    JNI_CALL_METHOD(env, mapEntry,
                    "getValue",
                    "()Ljava/lang/Object;",
                    Object,
                    value);
    headerMap.insert(std::make_pair(GetJNIString(env, (jstring)key), GetJNIString(env, (jstring)value)));
  }
  response->SetHeaderMap(headerMap);
}
bool KeyboardHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
                           const CefKeyEvent& event,
                           CefEventHandle os_event,
                           bool* is_keyboard_shortcut) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;

  jobject jevent = getjEvent(env, event);
  if (!jevent)
    return false;

  jobject jboolRef = NewJNIBoolRef(env, *is_keyboard_shortcut);
  if (!jboolRef)
    return false;

  jboolean jresult = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onPreKeyEvent",
                  "(Lorg/cef/browser/CefBrowser;Lorg/cef/handler/CefKeyboardHandler$CefKeyEvent;Lorg/cef/misc/BoolRef;)Z",
                  Boolean,
                  jresult,
                  GetJNIBrowser(browser),
                  jevent,
                  jboolRef);

  *is_keyboard_shortcut = GetJNIBoolRef(env, jboolRef);
  return (jresult != JNI_FALSE);
}
CefRefPtr<CefResourceHandler> SchemeHandlerFactory::Create(
    CefRefPtr<CefBrowser> browser,
    CefRefPtr<CefFrame> frame,
    const CefString& scheme_name,
    CefRefPtr<CefRequest> request) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return NULL;

  jobject jRequest = NewJNIObject(env, "org/cef/network/CefRequest_N");
  if (jRequest != NULL)
    SetCefForJNIObject(env, jRequest, request.get(), "CefRequest");

  jobject jResourceHandler = NULL;
  JNI_CALL_METHOD(env, jfactory_, "create",
                  "(Lorg/cef/browser/CefBrowser;Lorg/cef/browser/"
                  "CefFrame;Ljava/lang/String;Lorg/cef/"
                  "network/CefRequest;)Lorg/cef/handler/CefResourceHandler;",
                  Object, jResourceHandler, GetJNIBrowser(browser),
                  GetJNIFrame(env, frame), NewJNIString(env, scheme_name),
                  jRequest);

  if (jRequest != NULL)
    SetCefForJNIObject<CefRequest>(env, jRequest, NULL, "CefRequest");

  if (!jResourceHandler)
    return NULL;
  CefRefPtr<CefResourceHandler> result =
      new ResourceHandler(env, jResourceHandler);
  return result;
}
bool RenderHandler::GetScreenPoint(jobject browser,
                                   int viewX,
                                   int viewY,
                                   int& screenX,
                                   int& screenY) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
  	return false;

  jobject jreturn = NULL;
  jobject point_obj = NewJNIPoint(env, viewX, viewY);
  if (!point_obj)
    return false;

  JNI_CALL_METHOD(env, jhandler_, 
                  "getScreenPoint", 
                  "(Lorg/cef/browser/CefBrowser;Ljava/awt/Point;)Ljava/awt/Point;",
                  Object,
                  jreturn, 
                  browser,
                  point_obj);
  if (jreturn) {
    GetJNIPoint(env, jreturn, &screenX, &screenY);
    env->DeleteLocalRef(jreturn);
    return true;
  }
  return false;
}
bool ContextMenuHandler::OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
                                              CefRefPtr<CefFrame> frame,
                                              CefRefPtr<CefContextMenuParams> params,
                                              int command_id,
                                              EventFlags event_flags) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;

  jobject jparams = NewJNIObject(env, "org/cef/callback/CefContextMenuParams_N");
  if (!jparams)
    return false;
  SetCefForJNIObject(env, jparams, params.get(), "CefContextMenuParams");

  jboolean result = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onContextMenuCommand",
                  "(Lorg/cef/browser/CefBrowser;Lorg/cef/callback/CefContextMenuParams;II)Z",
                  Boolean,
                  result,
                  GetJNIBrowser(browser),
                  jparams,
                  (jint)command_id,
                  (jint)event_flags);

  // Do not keep references to |params| or |model| outside of this callback.
  SetCefForJNIObject<CefContextMenuParams>(env, jparams, NULL, "CefContextMenuParams");
  return (result != JNI_FALSE);
}
bool DragHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
                             CefRefPtr<CefDragData> dragData,
                             CefDragHandler::DragOperationsMask mask) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;

  jobject jdragdata = NewJNIObject(env, "org/cef/callback/CefDragData_N");
  if (!jdragdata)
    return false;
  SetCefForJNIObject(env, jdragdata, dragData.get(), "CefDragData");

  jboolean result = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onDragEnter",
                  "(Lorg/cef/browser/CefBrowser;Lorg/cef/callback/CefDragData;I)Z",
                  Boolean,
                  result,
                  GetJNIBrowser(browser),
                  jdragdata,
                  (jint)mask);

  //Remove native reference from java class
  SetCefForJNIObject<CefDragData>(env, jdragdata, NULL, "CefDragData");
  return (result != JNI_FALSE);
}
Esempio n. 8
0
bool JSDialogHandler::OnBeforeUnloadDialog(
    CefRefPtr<CefBrowser> browser,
    const CefString& message_text,
    bool is_reload,
    CefRefPtr<CefJSDialogCallback> callback) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    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_, "onBeforeUnloadDialog",
                  "(Lorg/cef/browser/CefBrowser;Ljava/lang/String;ZLorg/cef/"
                  "callback/CefJSDialogCallback;)Z",
                  Boolean, jresult, GetJNIBrowser(browser),
                  NewJNIString(env, message_text),
                  (is_reload ? JNI_TRUE : JNI_FALSE), jcallback);

  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);
}
bool LifeSpanHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
                                    CefRefPtr<CefFrame> frame,
                                    const CefString& target_url,
                                    const CefString& target_frame_name,
                                    const CefPopupFeatures& popupFeatures,
                                    CefWindowInfo& windowInfo,
                                    CefRefPtr<CefClient>& client,
                                    CefBrowserSettings& settings,
                                    bool* no_javascript_access) {
  if (browser->GetHost()->IsWindowRenderingDisabled()) {
    // Cancel popups in off-screen rendering mode.
    return true;
  }
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;
  jboolean jreturn = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onBeforePopup",
                  "(Lorg/cef/browser/CefBrowser;Ljava/lang/String;Ljava/lang/String;)Z",
                  Boolean,
                  jreturn,
                  GetJNIBrowser(browser),
                  NewJNIString(env, target_url),
                  NewJNIString(env, target_frame_name));
  return (jreturn != JNI_FALSE);
}
Esempio n. 10
0
bool GetJNIBoolRef(JNIEnv* env, jobject jboolRef) {
  jboolean boolRefRes = JNI_FALSE;
  JNI_CALL_METHOD(env, jboolRef, 
                  "get",
                   "()Z",
                   Boolean,
                   boolRefRes);
  return (boolRefRes != JNI_FALSE);
}
Esempio n. 11
0
int GetJNIIntRef(JNIEnv* env, jobject jintRef) {
  jint intRefRes = -1;
  JNI_CALL_METHOD(env, jintRef, 
                  "get",
                  "()I",
                  Int,
                  intRefRes);
  return intRefRes;
}
Esempio n. 12
0
CefString GetJNIStringRef(JNIEnv* env, jobject jstringRef) {
  jobject jstr = NULL;
  JNI_CALL_METHOD(env, jstringRef, 
                  "get",
                  "()Ljava/lang/String;",
                  Object,
                  jstr);
  return GetJNIString(env, (jstring)jstr);
}
Esempio n. 13
0
CefMessageRouterConfig GetJNIMessageRouterConfigFromRouter(JNIEnv* env, jobject jRouter) {
  jobject jrouterConfig = NULL;
  JNI_CALL_METHOD(env,
                  jRouter,
                  "getMessageRouterConfig",
                  "()Lorg/cef/browser/CefMessageRouter$CefMessageRouterConfig;",
                  Object,
                  jrouterConfig);
  return GetJNIMessageRouterConfig(env, jrouterConfig);
}
JNIEXPORT void JNICALL Java_org_cef_misc_CefPrintSettings_1N_N_1SetPageRanges
  (JNIEnv *env, jobject obj, jobject jrangeVector) {
  CefRefPtr<CefPrintSettings> settings =
      GetCefFromJNIObject<CefPrintSettings>(env, obj, "CefPrintSettings");
  if (!settings || !jrangeVector)
    return;

  CefPrintSettings::PageRangeList rangeList;
  jint jsize=0;
  JNI_CALL_METHOD(env, jrangeVector, "size", "()I", Int, jsize);
  for (jint index=0; index< jsize; index++) {
    jobject range = NULL;
    JNI_CALL_METHOD(env, jrangeVector, "get", "(I)Ljava/lang/Object;", Object,
        range, index);
    if (!range)
      continue;
    rangeList.push_back(GetJNIPageRange(env, range));
  }
  settings->SetPageRanges(rangeList);
}
Esempio n. 15
0
jobjectArray GetAllJNIBrowser(JNIEnv* env, jobject jclientHandler) {
    jobject jbrowsers = NULL;
  JNI_CALL_METHOD(env, jclientHandler,
                  "getAllBrowser",
                  "()[Ljava/lang/Object;",
                  Object,
                  jbrowsers);
  if(!jbrowsers)
    return NULL;
  return (jobjectArray)jbrowsers;
}
Esempio n. 16
0
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);
}
bool LifeSpanHandler::DoClose(CefRefPtr<CefBrowser> browser) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;
  jboolean jreturn = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "doClose",
                  "(Lorg/cef/browser/CefBrowser;)Z",
                  Boolean,
                  jreturn,
                  GetJNIBrowser(browser));
  return (jreturn != JNI_FALSE);
}
Esempio n. 18
0
jobject ClientHandler::getBrowser(CefRefPtr<CefBrowser> browser) {
  jobject jbrowser = NULL;
  BEGIN_ENV(env)
  JNI_CALL_METHOD(env, 
                  jhandler_, 
                  "getBrowser", 
                  "(I)Lorg/cef/browser/CefBrowser;", 
                  Object, 
                  jbrowser, 
                  browser->GetIdentifier());
  END_ENV(env)
  return jbrowser;
}
Esempio n. 19
0
bool GetJNIFieldDate(JNIEnv* env, jclass cls, jobject obj,
                     const char* field_name, CefTime* value) {
  jfieldID field = env->GetFieldID(cls, field_name, "Ljava/util/Date;");
  if (field) {
    jobject jdate = env->GetObjectField(obj, field);
    long timestamp = 0;
    JNI_CALL_METHOD(env, jdate, "getTime", "()J", Long, timestamp);
    value->SetDoubleT((double)(timestamp/1000));
    return true;
  }
  env->ExceptionClear();
  return false;
}
Esempio n. 20
0
CefRefPtr<CefDownloadHandler> ClientHandler::GetDownloadHandler() {
  CefRefPtr<CefDownloadHandler> result = NULL;
  BEGIN_ENV(env)
  jobject handler = NULL;
  JNI_CALL_METHOD(env, jhandler_, "getDownloadHandler", "()Lorg/cef/handler/CefDownloadHandler;", Object, handler);
  if (handler) {
    result = GetCefFromJNIObject<CefDownloadHandler>(env, handler, "CefDownloadHandler");
    if (!result.get()) {
      result = new DownloadHandler(env, handler);
      SetCefForJNIObject(env, handler, result.get(), "CefDownloadHandler");
    }
  }
  END_ENV(env)
  return result;
}
bool DisplayHandler::OnTooltip(CefRefPtr<CefBrowser> browser,
                       CefString& text) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;
  jboolean jreturn = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onTooltip",
                  "(Lorg/cef/browser/CefBrowser;Ljava/lang/String;)Z",
                  Boolean,
                  jreturn,
                  GetJNIBrowser(browser),
                  NewJNIString(env, text));
  return (jreturn != JNI_FALSE);
}
Esempio n. 22
0
bool IsJNIEnumValue(JNIEnv* env, jobject jenum, const char* class_name, const char* enum_valname) {
  if(!jenum)
    return false;

  jobject compareTo = GetJNIEnumValue(env, class_name, enum_valname);
  if (compareTo) {
    jboolean isEqual = JNI_FALSE;
    JNI_CALL_METHOD(env, jenum,
                    "equals",
                    "(Ljava/lang/Object;)Z",
                    Boolean,
                    isEqual,
                    compareTo);
    return (isEqual != JNI_FALSE);
  }
  return false;
}
bool WindowHandler::GetRect(jobject browser, CefRect& rect) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;
  jobject jreturn = NULL;
  JNI_CALL_METHOD(env, jhandler_, 
                  "getRect", 
                  "(Lorg/cef/browser/CefBrowser;)Ljava/awt/Rectangle;",
                  Object,
                  jreturn, 
                  browser);
  if (jreturn) {
    rect = GetJNIRect(env, jreturn);
    env->DeleteLocalRef(jreturn);
    return true;
  }
  return false;
}
bool DisplayHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
                              const CefString& message,
                              const CefString& source,
                              int line) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;
  jboolean jreturn = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onConsoleMessage",
                  "(Lorg/cef/browser/CefBrowser;Ljava/lang/String;Ljava/lang/String;I)Z",
                  Boolean,
                  jreturn,
                  GetJNIBrowser(browser),
                  NewJNIString(env, message),
                  NewJNIString(env, source),
                  line );
  return (jreturn != JNI_FALSE);
}
bool KeyboardHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser,
                        const CefKeyEvent& event,
                        CefEventHandle os_event) {
  JNIEnv* env = GetJNIEnv();
  if (!env)
    return false;

  jobject jevent = getjEvent(env, event);
  if (!jevent)
    return false;

  jboolean jresult = JNI_FALSE;
  JNI_CALL_METHOD(env, jhandler_,
                  "onKeyEvent",
                  "(Lorg/cef/browser/CefBrowser;Lorg/cef/handler/CefKeyboardHandler$CefKeyEvent;)Z",
                  Boolean,
                  jresult,
                  GetJNIBrowser(browser),
                  jevent);

  return (jresult != JNI_FALSE);
}
JNIEXPORT void JNICALL Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap
  (JNIEnv *env, jobject obj, jobject jheaderMap) {
  CefRefPtr<CefResponse> response = GetCefFromJNIObject<CefResponse>(env, obj, "CefResponse");
  if (!response)
    return;  
  CefResponse::HeaderMap headerMap;
  response->GetHeaderMap(headerMap);

  for (CefResponse::HeaderMap::iterator iter = headerMap.begin(); iter != headerMap.end(); ++iter) {
    jstring jkey = NewJNIString(env, iter->first);
    jstring jvalue = NewJNIString(env, iter->second);
    jobject returnIgn = NULL;
    JNI_CALL_METHOD(env,
                    jheaderMap,
                    "put",
                    "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                    Object,
                    returnIgn,
                    jkey,
                    jvalue);
    UNUSED(returnIgn);
  }
}
Esempio n. 27
0
CefSettings GetJNISettings(JNIEnv* env, jobject obj) {
  CefString tmp;
  CefSettings settings;
  if (!obj)
    return settings;

  jclass cls = env->FindClass("org/cef/CefSettings");
  if (!cls)
    return settings;

  if (GetJNIFieldString(env, cls, obj, "browser_subprocess_path", &tmp) &&
      !tmp.empty()) {
    CefString(&settings.browser_subprocess_path) = tmp;
    tmp.clear();
  }
  GetJNIFieldBoolean(env, cls, obj, "windowless_rendering_enabled",
      &settings.windowless_rendering_enabled);
  GetJNIFieldBoolean(env, cls, obj, "command_line_args_disabled",
      &settings.command_line_args_disabled);
  if (GetJNIFieldString(env, cls, obj, "cache_path", &tmp) && !tmp.empty()) {
    CefString(&settings.cache_path) = tmp;
    tmp.clear();
  }
  GetJNIFieldBoolean(env, cls, obj, "persist_session_cookies",
      &settings.persist_session_cookies);
  if (GetJNIFieldString(env, cls, obj, "user_agent", &tmp) && !tmp.empty()) {
    CefString(&settings.user_agent) = tmp;
    tmp.clear();
  }
  if (GetJNIFieldString(env, cls, obj, "product_version", &tmp) &&
      !tmp.empty()) {
    CefString(&settings.product_version) = tmp;
    tmp.clear();
  }
  if (GetJNIFieldString(env, cls, obj, "locale", &tmp) && !tmp.empty()) {
    CefString(&settings.locale) = tmp;
    tmp.clear();
  }
  if (GetJNIFieldString(env, cls, obj, "log_file", &tmp) && !tmp.empty()) {
    CefString(&settings.log_file) = tmp;
    tmp.clear();
  }
  jobject obj_sev = NULL;
  if (GetJNIFieldObject(env, cls, obj, "log_severity", &obj_sev,
          "Lorg/cef/CefSettings$LogSeverity;")) {
    if (obj_sev != NULL) {
      if (IsJNIEnumValue(env, obj_sev, "org/cef/CefSettings$LogSeverity",
                     "LOGSEVERITY_VERBOSE"))
        settings.log_severity = LOGSEVERITY_VERBOSE;
      else if (IsJNIEnumValue(env, obj_sev, "org/cef/CefSettings$LogSeverity",
                     "LOGSEVERITY_INFO"))
        settings.log_severity = LOGSEVERITY_INFO;
      else if (IsJNIEnumValue(env, obj_sev, "org/cef/CefSettings$LogSeverity",
                     "LOGSEVERITY_WARNING"))
        settings.log_severity = LOGSEVERITY_WARNING;
      else if (IsJNIEnumValue(env, obj_sev, "org/cef/CefSettings$LogSeverity",
                     "LOGSEVERITY_ERROR"))
        settings.log_severity = LOGSEVERITY_ERROR;
      else if (IsJNIEnumValue(env, obj_sev, "org/cef/CefSettings$LogSeverity",
                     "LOGSEVERITY_DISABLE"))
        settings.log_severity = LOGSEVERITY_DISABLE;
      else
        settings.log_severity = LOGSEVERITY_DEFAULT;
    }
  }
  if (GetJNIFieldString(env, cls, obj, "javascript_flags", &tmp) &&
      !tmp.empty()) {
    CefString(&settings.javascript_flags) = tmp;
    tmp.clear();
  }
  if (GetJNIFieldString(env, cls, obj, "resources_dir_path", &tmp) &&
      !tmp.empty()) {
    CefString(&settings.resources_dir_path) = tmp;
    tmp.clear();
  }
  if (GetJNIFieldString(env, cls, obj, "locales_dir_path", &tmp) &&
      !tmp.empty()) {
    CefString(&settings.locales_dir_path) = tmp;
    tmp.clear();
  }
  GetJNIFieldBoolean(env, cls, obj, "pack_loading_disabled",
      &settings.pack_loading_disabled);
  GetJNIFieldInt(env, cls, obj, "remote_debugging_port",
      &settings.remote_debugging_port);
  GetJNIFieldInt(env, cls, obj, "uncaught_exception_stack_size",
      &settings.uncaught_exception_stack_size);
  GetJNIFieldInt(env, cls, obj, "context_safety_implementation",
      &settings.context_safety_implementation);
  GetJNIFieldBoolean(env, cls, obj, "ignore_certificate_errors",
      &settings.ignore_certificate_errors);
  jobject obj_col = NULL;
  if (GetJNIFieldObject(env, cls, obj, "background_color", &obj_col,
          "Lorg/cef/CefSettings$ColorType;")) {
    if (obj_col != NULL) {
      jlong jcolor = 0;
      JNI_CALL_METHOD(env, obj_col, "getColor", "()J", Long, jcolor);
      settings.background_color = (cef_color_t)jcolor;
    }
  }
  return settings;
}