Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessHandler"/> class.
        /// </summary>
        public ProcessHandler()
        {
            MessageRouter   = new CefMessageRouterRendererSide(new CefMessageRouterConfig());
            V8NativeHandler = new V8NativeHandler();

            LoadHandler = new LoadHandler();
            LoadHandler.OnLoadStartEvent += OnLoadStart;
        }
Esempio n. 2
0
        /// <summary>
        /// Called when process message received.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="sourceProcess">The source process.</param>
        /// <param name="message">The process message.</param>
        /// <returns></returns>
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            return(V8NativeHandler.ProcessMessage(browser, sourceProcess, message) ||
                   MessageRouter.OnProcessMessageReceived(browser, sourceProcess, message));
        }
Esempio n. 3
0
        /// <summary>
        /// Called when load start.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="OnLoadStartEventArgs"/> instance containing the event data.</param>
        protected void OnLoadStart(object sender, OnLoadStartEventArgs e)
        {
            var frame   = e.Frame;
            var context = e.Frame.V8Context;

            if (frame.IsMain && IsLocalUrl(frame.Url))
            {
                if (V8NativeHandler != null)
                {
                    V8NativeHandler.Reset();
                }

                RegisterHtmlUiAsScriptIfNeeded(context);
            }
        }