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

Function PutJavascriptCallback

src/subprocess/javascript_callback.cpp:27–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25int g_jsCallbackMaxId = 0;
26
27CefString PutJavascriptCallback(
28 CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Value> jsCallback) {
29 // Returns a "####cefpython####" string followed by json encoded data.
30 // {"what":"javascript-callback","callbackId":123,
31 // "frameId":123,"functionName":"xx"}
32 int callbackId = ++g_jsCallbackMaxId;
33 int64 frameId = frame->GetIdentifier();
34 CefString functionName = jsCallback->GetFunctionName();
35 std::string strCallbackId = "####cefpython####";
36 strCallbackId.append("{");
37 // JSON format allows only for double quotes.
38 strCallbackId.append("\"what\":\"javascript-callback\"");
39 strCallbackId.append(",\"callbackId\":").append(AnyToString(callbackId));
40 strCallbackId.append(",\"frameId\":").append(AnyToString(frameId));
41 strCallbackId.append(",\"functionName\":\"").append(functionName) \
42 .append("\"");
43 strCallbackId.append("}");
44 g_jsCallbackMap.insert(std::make_pair(
45 callbackId,
46 std::make_pair(frame, jsCallback)));
47 return strCallbackId;
48}
49
50bool ExecuteJavascriptCallback(int callbackId, CefRefPtr<CefListValue> args) {
51 if (g_jsCallbackMap.empty()) {

Callers 2

Calls 1

AnyToStringFunction · 0.70

Tested by

no test coverage detected