Пример #1
0
            private void HandleDomRequest(CefBrowser browser, CefProcessId sourceProcess, long frameIdentifier)
            {
                var scheduler = GetTaskScheduler(CefThreadId.Renderer);

                Task.Factory.StartNew(
                    () =>
                {
                    var frame = browser.GetFrame(frameIdentifier);
                    if (frame != null)
                    {
                        var visitor = new DomVisitor();
                        frame.VisitDom(visitor);
                        var response = CefProcessMessage.Create("dom-response");
                        response.SetFrameIdentifier(frame.Identifier);
                        if (visitor.Result != null)
                        {
                            response.Arguments.SetBool(2, true);
                            response.Arguments.SetString(3, visitor.Result.ToString());
                        }
                        else
                        {
                            response.Arguments.SetBool(2, false);
                            response.Arguments.SetString(3, visitor.Exception.ToString());
                        }
                        browser.SendProcessMessage(sourceProcess, response);
                    }
                },
                    CancellationToken.None,
                    TaskCreationOptions.None,
                    scheduler);
            }
Пример #2
0
        private void UpdateDom(CefFrame frame)
        {
            var visitor = new DomVisitor(this);

            // Note: Call is async. Will at some point lead to OnVisitDom a few lines down.
            frame.VisitDom(visitor);
        }