예제 #1
0
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            Console.WriteLine("Render::OnProcessMessageReceived: SourceProcess={0}", sourceProcess);
            Console.WriteLine("Message Name={0} IsValid={1} IsReadOnly={2}", message.Name, message.IsValid, message.IsReadOnly);
            var arguments = message.Arguments;
            for (var i = 0; i < arguments.Count; i++)
            {
                var type = arguments.GetValueType(i);
                object value;
                switch (type)
                {
                    case CefValueType.Null: value = null; break;
                    case CefValueType.String: value = arguments.GetString(i); break;
                    case CefValueType.Int: value = arguments.GetInt(i); break;
                    case CefValueType.Double: value = arguments.GetDouble(i); break;
                    case CefValueType.Bool: value = arguments.GetBool(i); break;
                    default: value = null; break;
                }

                Console.WriteLine("  [{0}] ({1}) = {2}", i, type, value);
            }

            if (message.Name == "myMessage2") return true;

            var message2 = CefProcessMessage.Create("myMessage2");
            var success = browser.SendProcessMessage(CefProcessId.Renderer, message2);
            Console.WriteLine("Sending myMessage2 to renderer process = {0}", success);

            var message3 = CefProcessMessage.Create("myMessage3");
            var success2 = browser.SendProcessMessage(CefProcessId.Browser, message3);
            Console.WriteLine("Sending myMessage3 to browser process = {0}", success);

            return false;
        }
예제 #2
0
파일: WebClient.cs 프로젝트: rajsite/lvcef
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (DumpProcessMessages)
            {
                Console.WriteLine("Client::OnProcessMessageReceived: SourceProcess={0}", sourceProcess);
                Console.WriteLine("Message Name={0} IsValid={1} IsReadOnly={2}", message.Name, message.IsValid, message.IsReadOnly);
                var arguments = message.Arguments;
                for (var i = 0; i < arguments.Count; i++)
                {
                    var type = arguments.GetValueType(i);
                    object value;
                    switch (type)
                    {
                        case CefValueType.Null: value = null; break;
                        case CefValueType.String: value = arguments.GetString(i); break;
                        case CefValueType.Int: value = arguments.GetInt(i); break;
                        case CefValueType.Double: value = arguments.GetDouble(i); break;
                        case CefValueType.Bool: value = arguments.GetBool(i); break;
                        default: value = null; break;
                    }

                    Console.WriteLine("  [{0}] ({1}) = {2}", i, type, value);
                }
            }

            var handled = DemoApp.BrowserMessageRouter.OnProcessMessageReceived(browser, sourceProcess, message);
            if (handled) return true;

            if (message.Name == "myMessage2" || message.Name == "myMessage3") return true;

            return false;
        }
예제 #3
0
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (!this.loggingService.IsDebugEnabled)
            {
                return false;
            }

            this.loggingService.Debug("Client::OnProcessMessageReceived: SourceProcess={0}", sourceProcess);
            this.loggingService.Debug("Message Name={0} IsValid={1} IsReadOnly={2}", message.Name, message.IsValid, message.IsReadOnly);
            var arguments = message.Arguments;
            for (var i = 0; i < arguments.Count; i++)
            {
                var type = arguments.GetValueType(i);
                object value;
                switch (type)
                {
                    case CefValueType.Null: value = null; break;
                    case CefValueType.String: value = arguments.GetString(i); break;
                    case CefValueType.Int: value = arguments.GetInt(i); break;
                    case CefValueType.Double: value = arguments.GetDouble(i); break;
                    case CefValueType.Bool: value = arguments.GetBool(i); break;
                    default: value = null; break;
                }

                this.loggingService.Debug("  [{0}] ({1}) = {2}", i, type, value);
            }

            return false;
        }
예제 #4
0
            protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
            {
                if (message.Name == "renderProcessIdRequest")
                {
                    CefProcessMessage response = CefProcessMessage.Create("renderProcessIdResponse");
                    response.Arguments.SetInt(0, Process.GetCurrentProcess().Id);
                    browser.SendProcessMessage(CefProcessId.Browser, response);
                }

                return false;
            }
예제 #5
0
        private int on_process_message_received(cef_client_t *self, cef_browser_t *browser, CefProcessId source_process, cef_process_message_t *message)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_message = CefProcessMessage.FromNative(message);

            var result = OnProcessMessageReceived(m_browser, source_process, m_message);

            // m_browser.Dispose();
            m_message.Dispose();

            return(result ? 1 : 0);
        }
        private int on_process_message_received(cef_render_process_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, CefProcessId source_process, cef_process_message_t *message)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_frame   = CefFrame.FromNative(frame);
            var m_message = CefProcessMessage.FromNative(message);

            var result = OnProcessMessageReceived(m_browser, m_frame, source_process, m_message);

            m_message.Dispose();

            return(result ? 1 : 0);
        }
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (message.Name == "renderProcessIdResponse")
            {
                int renderProcessId = message.Arguments.GetInt(0);
                BrowserWrapper browserWrapper;
                if (BrowserManager.Instance.TryGetBrowser(
                    browser.Identifier, out browserWrapper))
                {
                    browserWrapper.UpdateRenderProcessId(renderProcessId);
                }
            }

            return false;
        }
예제 #8
0
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            Debug.WriteLine(DBGPREFIX + "OnProcessMessageReceived: " + message.ToString());
            var isHandled = _messageRouter.OnProcessMessageReceived(browser, sourceProcess, message);
            if (isHandled)
                return true;

	        var handler = OnProcessMessageReceivedEvent;
            if (handler != null)
            {
                Debug.WriteLine(DBGPREFIX + "OnProcessMessageReceived Delegate");
                var e = new OnProcessMessageReceivedEventArgs(browser, sourceProcess, message);
                handler(this, e);
                return e.Handled;
            }
            return false;
        }
예제 #9
0
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (message.Name == "SetOverlayAPI")
            {
                // 対象のフレームを取得
                var frameName = message.Arguments.GetString(0);
                var frame = GetFrameByName(browser, frameName);

                // API を設定
                if (frame != null && frame.V8Context.Enter())
                {
                    var apiObject = CefV8Value.CreateObject(null);

                    var broadcastMessageFunction = CefV8Value.CreateFunction(
                        BuiltinFunctionHandler.BroadcastMessageFunctionName,
                        builtinFunctionHandler);
                    var sendMessageFunction = CefV8Value.CreateFunction(
                         BuiltinFunctionHandler.SendMessageFunctionName,
                         builtinFunctionHandler);

                    apiObject.SetValue(
                        BuiltinFunctionHandler.BroadcastMessageFunctionName,
                        broadcastMessageFunction,
                        CefV8PropertyAttribute.None);
                    apiObject.SetValue(
                        BuiltinFunctionHandler.SendMessageFunctionName,
                        sendMessageFunction,
                        CefV8PropertyAttribute.None);

                    frame.V8Context.GetGlobal().SetValue("OverlayPluginApi", apiObject, CefV8PropertyAttribute.None);

                    frame.V8Context.Exit();
                }
                return true;
            }

            return base.OnProcessMessageReceived(browser, sourceProcess, message);
        }
예제 #10
0
파일: CefBrowser.cs 프로젝트: whztt07/SDK
        /// <summary>
        /// Send a message to the specified |target_process|. Returns true if the
        /// message was sent successfully.
        /// </summary>
        public bool SendProcessMessage(CefProcessId target, CefProcessMessage message)
        {
            if (message == null) throw new ArgumentNullException("message");

            return cef_browser_t.send_process_message(_self, target, message.ToNative()) != 0;
        }
예제 #11
0
 /// <summary>
 /// Called when a new message is received from a different process. Return true
 /// if the message was handled or false otherwise. Do not keep a reference to
 /// or attempt to access the message outside of this callback.
 /// </summary>
 protected virtual bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
 {
     return false;
 }
예제 #12
0
 /// <summary>
 /// Called when a new message is received from a different process. Return true
 /// if the message was handled or false otherwise. Do not keep a reference to
 /// or attempt to access the message outside of this callback.
 /// </summary>
 protected virtual bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
 {
     return(false);
 }
예제 #13
0
 protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
 {
     Debug.WriteLine(DBGPREFIX + "OnProcessMessageReceived called");
     return _messageRouter.OnProcessMessageReceived(browser, sourceProcess, message);
 }
예제 #14
0
파일: Form1.cs 프로젝트: qipa/ILBC
 private void Browser_ProcessMessageReceived(Xilium.CefGlue.CefBrowser browser, Xilium.CefGlue.CefProcessId sourceProcess, Xilium.CefGlue.CefProcessMessage message)
 {
     if (message.Name == "OpenSaveFileDialog")
     {
         BeginInvoke(new Action(() => { saveFileDialog1.ShowDialog(); }));
     }
     else
     {
         this.BeginInvoke(new Action(() =>
                                     { MessageBox.Show("未知的消息 from Render Process ,消息名字“" + message.Name + "”。"); }));
     }
 }
예제 #15
0
 /// <summary>
 /// Returns a writable copy of this object.
 /// </summary>
 public CefProcessMessage Copy()
 {
     return(CefProcessMessage.FromNative(
                cef_process_message_t.copy(_self)
                ));
 }
예제 #16
0
            internal OnProcessMessageReceivedEventArgs(CefBrowser _browser, CefProcessId _sourceProcess, CefProcessMessage _message)
	        {
                browser = _browser;
                sourceProcess = _sourceProcess;
                message = _message;
                Handled = false; //default return value
	        }