MCPcopy Create free account
hub / github.com/cztomczak/cefpython / BindedFunctionExists

Method BindedFunctionExists

src/subprocess/cefpython_app.cpp:427–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427bool CefPythonApp::BindedFunctionExists(CefRefPtr<CefBrowser> browser,
428 const CefString& functionName) {
429 CefRefPtr<CefDictionaryValue> jsBindings = GetJavascriptBindings(browser);
430 if (!jsBindings.get()) {
431 return false;
432 }
433 std::string strFunctionName = functionName.ToString();
434 size_t dotPosition = strFunctionName.find(".");
435 if (std::string::npos != dotPosition) {
436 // This is a method call, functionName == "object.method".
437 CefString objectName(strFunctionName.substr(0, dotPosition));
438 CefString methodName(strFunctionName.substr(dotPosition + 1,
439 std::string::npos));
440 if (!(jsBindings->HasKey("objects")
441 && jsBindings->GetType("objects") == VTYPE_DICTIONARY)) {
442 LOG(ERROR) << "[Renderer process] BindedFunctionExists():"
443 " objects dictionary not found";
444 return false;
445 }
446 CefRefPtr<CefDictionaryValue> objects = \
447 jsBindings->GetDictionary("objects");
448 if (objects->HasKey(objectName)) {
449 if (!(objects->GetType(objectName) == VTYPE_DICTIONARY)) {
450 LOG(ERROR) << "[Renderer process] BindedFunctionExists():"
451 " objects dictionary has invalid type";
452 return false;
453 }
454 CefRefPtr<CefDictionaryValue> methods = \
455 objects->GetDictionary(objectName);
456 return methods->HasKey(methodName);
457 } else {
458 return false;
459 }
460 } else {
461 // This is a function call.
462 if (!(jsBindings->HasKey("functions")
463 && jsBindings->GetType("functions") == VTYPE_DICTIONARY)) {
464 LOG(ERROR) << "[Renderer process] BindedFunctionExists():"
465 " functions dictionary not found";
466 return false;
467 }
468 CefRefPtr<CefDictionaryValue> functions = \
469 jsBindings->GetDictionary("functions");
470 return functions->HasKey(functionName);
471 }
472}
473
474void CefPythonApp::DoJavascriptBindingsForBrowser(
475 CefRefPtr<CefBrowser> browser) {

Callers 1

ExecuteMethod · 0.80

Calls 3

ToStringMethod · 0.80
findMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected