Beispiel #1
0
        private bool OnQuery(int browserId, int frameId, long queryId, string request,
                             JavaScriptRequestSuccessCallback successCallback, JavaScriptRequestFailureCallback failureCallback)
        {
            Console.WriteLine($"OnQuery {queryId} - {request}");

            if (_browserWindows.TryGetValue(browserId, out var browserWindow))
            {
                return(browserWindow.ProcessJavaScriptRequest(frameId, queryId, request, successCallback, failureCallback));
            }

            return(false);
        }
Beispiel #2
0
        internal bool ProcessJavaScriptRequest(int frameId, long queryId, string request,
                                               JavaScriptRequestSuccessCallback successCallback, JavaScriptRequestFailureCallback failureCallback)
        {
            var jsRequest = JsonConvert.DeserializeObject <JavaScriptRequest>(request);

            if (!_javaScriptQueryHandlers.TryGetValue(jsRequest.Channel, out var handler))
            {
                return(false);
            }

            jsRequest.FrameId         = frameId;
            jsRequest.QueryId         = queryId;
            jsRequest.SuccessCallback = successCallback;
            jsRequest.FailureCallback = failureCallback;
            jsRequest.BrowserWindow   = this;

            handler(jsRequest);

            return(true);
            // if (jsRequest.Channel == "openDevTools")
            // {
            //     if (_nativeInterface.ShowDeveloperTools(browserId))
            //     {
            //         successCallback(queryId, "Opened developer tools");
            //     }
            //     else
            //     {
            //          failureCallback(queryId, 1, "Failed to open developer tools");
            //     }

            //     return true;
            // }
        }