Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Unsolved QWebChannel.js does not work with Chromium's existing functionality

$
0
0

How to achieve before the page is loaded on the registration of objects or methods, similar to Chromium registered in the method OnContextCreated.

virtual void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
                            CefRefPtr<CefBrowser> browser,
                            CefRefPtr<CefFrame> frame,
                            CefRefPtr<CefV8Context> context) OVERRIDE {
 CefRefPtr<CefV8Value> object = context->GetGlobal();
 CefRefPtr<CefV8Handler> handler = new V8Handler();
// Bind test functions.
object->SetValue(kGetPerfTests,
                 CefV8Value::CreateFunction(kGetPerfTests, handler),
                 V8_PROPERTY_ATTRIBUTE_READONLY);
object->SetValue(kRunPerfTest,
                 CefV8Value::CreateFunction(kRunPerfTest, handler),
                 V8_PROPERTY_ATTRIBUTE_READONLY);
object->SetValue(kPerfTestReturnValue,
                 CefV8Value::CreateFunction(kPerfTestReturnValue, handler),
                 V8_PROPERTY_ATTRIBUTE_READONLY);
 }

The current method of using QWebChannel.js no way to ensure that the first injection, if the page load on the need to communicate with C + + can not be achieved, you must wait for QWebChannel.js loaded and new QWebChannel object after the implementation. Like the following page content can not be achieved

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
   <script type="text/javascript">
	window.invoke("testCallbackFunc", "test");
   </script>
</body>
</html>~~~~

Viewing all articles
Browse latest Browse all 13965

Trending Articles