public ChromiumControl(string address, params IBindableToJs[] objectsToBind) { address = AddInternalDomain(address); m_Log = ObjectFactory.Get <ILog>(); CEF.Initialize(new Settings()); CEF.SetCookiePath(TheProduct.ProductApplicationData); m_WebView = new WebView(address, new BrowserSettings { WebSecurityDisabled = true }) { Dock = DockStyle.Fill, RequestHandler = new InterceptingRequestHandler(c_InternalDomain, new OwinBasedFileServer(new EmbeddedResourceFileSystemWithDirectorySupport(AssetsAssembly.Get())).Request) }; foreach (var toBind in objectsToBind) { m_WebView.RegisterJsObject(toBind.Name, toBind); } m_WebView.PropertyChanged += (sender, args) => { m_WebView.Address = address; if (args.PropertyName == "IsBrowserInitialized" && Keyboard.IsKeyDown(Key.LeftShift)) { m_WebView.ShowDevTools(); } }; m_WebView.ConsoleMessage += LogConsoleMessage; m_WebView.LifeSpanHandler = new PopupHandler(); // Without this: // The webview isn't initialized for a while after the tab is shown, so we have to wait, polling it. // About 1/3 times when the tab gets created the webview only fills the top left hand corner of it. SizeChanged += ReinitializeAndResize; Controls.Add(m_WebView); m_WebView.MenuHandler = this; }