示例#1
0
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            long     identifier;
            CefFrame frame;

            switch (message.Name)
            {
            case "dom-response":
                identifier = message.GetFrameIdentifier();
                frame      = browser.GetFrame(identifier);
                if (frame != null)
                {
                    var arguments = message.Arguments;
                    var success   = arguments.GetBool(2);
                    var s         = arguments.GetString(3);
                    if (success)
                    {
                        var dom = XDocument.Parse(s);
                        FRenderer.OnUpdateDom(dom);
                    }
                    else
                    {
                        FRenderer.OnUpdateDom(s);
                    }
                }
                return(true);

            case "document-size-response":
                identifier = message.GetFrameIdentifier();
                frame      = browser.GetFrame(identifier);
                if (frame != null)
                {
                    var arguments = message.Arguments;
                    var width     = arguments.GetInt(2);
                    var height    = arguments.GetInt(3);
                    FRenderer.OnDocumentSize(frame, width, height);
                }
                return(true);

            default:
                break;
            }
            return(base.OnProcessMessageReceived(browser, sourceProcess, message));
        }
示例#2
0
            protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
            {
                long identifier;

                switch (message.Name)
                {
                case "dom-request":
                    identifier = message.GetFrameIdentifier();
                    HandleDomRequest(browser, sourceProcess, identifier);
                    return(true);

                case "document-size-request":
                    identifier = message.GetFrameIdentifier();
                    HandleDocumentSizeRequest(browser, sourceProcess, identifier);
                    return(true);

                default:
                    return(base.OnProcessMessageReceived(browser, sourceProcess, message));
                }
            }