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

Function ExecuteJavascriptCallback

src/subprocess/javascript_callback.cpp:50–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50bool ExecuteJavascriptCallback(int callbackId, CefRefPtr<CefListValue> args) {
51 if (g_jsCallbackMap.empty()) {
52 LOG(ERROR) << "[Renderer process] ExecuteJavascriptCallback():"
53 " callback map is empty";
54 return false;
55 }
56 JavascriptCallbackMap::const_iterator it = g_jsCallbackMap.find(
57 callbackId);
58 if (it == g_jsCallbackMap.end()) {
59 std::string logMessage = "[Renderer process]"
60 " ExecuteJavascriptCallback():"
61 " callback not found, id=";
62 logMessage.append(AnyToString(callbackId));
63 LOG(ERROR) << logMessage.c_str();
64 return false;
65 }
66 CefRefPtr<CefFrame> frame = it->second.first;
67 CefRefPtr<CefV8Value> callback = it->second.second;
68 CefRefPtr<CefV8Context> context = frame->GetV8Context();
69 context->Enter();
70 CefV8ValueList v8Arguments = CefListValueToCefV8ValueList(args);
71 CefRefPtr<CefV8Value> v8ReturnValue = callback->ExecuteFunction(
72 NULL, v8Arguments);
73 if (v8ReturnValue.get()) {
74 context->Exit();
75 return true;
76 } else {
77 context->Exit();
78 LOG(ERROR) << "[Renderer process] ExecuteJavascriptCallback():"
79 " callback->ExecuteFunction() failed";
80 return false;
81 }
82}
83
84void RemoveJavascriptCallbacksForFrame(CefRefPtr<CefFrame> frame) {
85 if (g_jsCallbackMap.empty()) {

Callers 1

Calls 6

findMethod · 0.80
c_strMethod · 0.80
AnyToStringFunction · 0.70
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected