public override void OnBrowserCreated(CefBrowserWrapper browser) { browsers.Add(browser); if (parentBrowserId == null) { parentBrowserId = browser.BrowserId; } if (ParentProcessId == null || parentBrowserId == null) { return; } var browserId = browser.IsPopup ? parentBrowserId.Value : browser.BrowserId; var serviceName = RenderprocessClientFactory.GetServiceName(ParentProcessId.Value, browserId); var binding = BrowserProcessServiceHost.CreateBinding(); var channelFactory = new DuplexChannelFactory <IBrowserProcess>( this, binding, new EndpointAddress(serviceName) ); channelFactory.Open(); var browserProcess = channelFactory.CreateChannel(); var clientChannel = ((IClientChannel)browserProcess); try { clientChannel.Open(); if (!browser.IsPopup) { browserProcess.Connect(); } var javascriptObject = browserProcess.GetRegisteredJavascriptObjects(); if (javascriptObject.MemberObjects.Count > 0) { browser.JavascriptRootObject = javascriptObject; } browser.ChannelFactory = channelFactory; browser.BrowserProcess = browserProcess; } catch (Exception) { } }
public override void OnBrowserCreated(CefBrowserWrapper browser) { browsers.Add(browser); if (parentBrowserId == null) { parentBrowserId = browser.BrowserId; } if (ParentProcessId == null || parentBrowserId == null) { return; } var browserId = browser.IsPopup ? parentBrowserId.Value : browser.BrowserId; var serviceName = RenderprocessClientFactory.GetServiceName(ParentProcessId.Value, browserId); var binding = BrowserProcessServiceHost.CreateBinding(); var channelFactory = new ChannelFactory <IBrowserProcess>( binding, new EndpointAddress(serviceName) ); channelFactory.Open(); var browserProcess = channelFactory.CreateChannel(); var clientChannel = ((IClientChannel)browserProcess); try { clientChannel.Open(); browser.ChannelFactory = channelFactory; browser.BrowserProcess = browserProcess; } catch (Exception) { } }