private void Initialize() { InitializeCef(); chromium = new ChromiumBrowser(); chromium.BrowserInitialized += OnWebViewBrowserInitialized; chromium.LoadEnd += OnWebViewLoadEnd; chromium.LoadError += OnWebViewLoadError; chromium.TitleChanged += OnWebViewTitleChanged; chromium.JavascriptContextCreated += OnJavascriptContextCreated; chromium.JavascriptContextReleased += OnJavascriptContextReleased; chromium.JavascriptUncaughException += OnJavascriptUncaughException; chromium.UnhandledException += OnUnhandledException; chromium.RequestHandler = new InternalRequestHandler(this); chromium.LifeSpanHandler = new InternalLifeSpanHandler(this); chromium.ContextMenuHandler = new InternalContextMenuHandler(this); chromium.DialogHandler = new InternalDialogHandler(this); chromium.DownloadHandler = new InternalDownloadHandler(this); chromium.JSDialogHandler = new InternalJsDialogHandler(this); chromium.DragHandler = new InternalDragHandler(this); chromium.KeyboardHandler = new InternalKeyboardHandler(this); disposables = new IDisposable[] { chromium, AsyncCancellationTokenSource }; RegisterJavascriptObject(Listener.EventListenerObjName, EventsListener); ExtraInitialize(); GlobalWebViewInitialized?.Invoke(this); }
private void Initialize(string initialAddress) { InitializeCef(); if (!subscribedApplicationExit) { // subscribe exit again, first time might have failed if Application.Current was null Application.Current.Exit += OnApplicationExit; subscribedApplicationExit = true; } lifeSpanHandler = new CefLifeSpanHandler(this); chromium = new InternalChromiumBrowser(initialAddress); chromium.IsBrowserInitializedChanged += OnWebViewIsBrowserInitializedChanged; chromium.FrameLoadEnd += OnWebViewFrameLoadEnd; chromium.LoadError += OnWebViewLoadError; chromium.TitleChanged += OnWebViewTitleChanged; chromium.PreviewKeyDown += OnPreviewKeyDown; chromium.RequestHandler = new CefRequestHandler(this); chromium.LifeSpanHandler = lifeSpanHandler; chromium.RenderProcessMessageHandler = new CefRenderProcessMessageHandler(this); chromium.MenuHandler = new CefMenuHandler(this); chromium.DialogHandler = new CefDialogHandler(this); chromium.DownloadHandler = new CefDownloadHandler(this); chromium.CleanupElement = new FrameworkElement(); // prevent chromium to listen to default cleanup element unload events, this will be controlled manually chromium.DragHandler = new CefDragHandler(this); disposables = new[] { (IDisposable)AsyncCancellationTokenSource, chromium }; RegisterJavascriptObject(Listener.EventListenerObjName, EventsListener); Content = chromium; GlobalWebViewInitialized?.Invoke(this); JavascriptContextCreated += OnJavascriptContextCreated; JavascriptContextReleased += OnJavascriptContextReleased; RenderProcessCrashed += OnRenderProcessCrashed; FocusManager.SetIsFocusScope(this, true); FocusManager.SetFocusedElement(this, FocusableElement); }
private void Initialize() { InitializeCef(); if (!subscribedApplicationExit) { // subscribe exit again, first time might have failed if Application.Current was null Application.Current.Exit += OnApplicationExit; subscribedApplicationExit = true; } settings = new BrowserSettings(); lifeSpanHandler = new CefLifeSpanHandler(this); chromium = new InternalChromiumBrowser(); chromium.BrowserSettings = settings; chromium.IsBrowserInitializedChanged += OnWebViewIsBrowserInitializedChanged; chromium.FrameLoadEnd += OnWebViewFrameLoadEnd; chromium.LoadError += OnWebViewLoadError; chromium.TitleChanged += OnWebViewTitleChanged; chromium.PreviewKeyDown += OnPreviewKeyDown; chromium.RequestHandler = new CefRequestHandler(this); chromium.ResourceHandlerFactory = new CefResourceHandlerFactory(this); chromium.LifeSpanHandler = lifeSpanHandler; chromium.RenderProcessMessageHandler = new CefRenderProcessMessageHandler(this); chromium.MenuHandler = new CefMenuHandler(this); chromium.DialogHandler = new CefDialogHandler(this); chromium.DownloadHandler = new CefDownloadHandler(this); chromium.CleanupElement = new FrameworkElement(); // prevent chromium to listen to default cleanup element unload events, this will be controlled manually jsExecutor = new JavascriptExecutor(this); RegisterJavascriptObject(Listener.EventListenerObjName, eventsListener); Content = chromium; GlobalWebViewInitialized?.Invoke(this); DisposableWebViews.Add(this); FocusManager.SetIsFocusScope(this, true); FocusManager.SetFocusedElement(this, FocusableElement); }
private void Initialize() { WebViewLoader.Initialize(Settings); chromium = new ChromiumBrowser(); chromium.BrowserInitialized += OnWebViewBrowserInitialized; chromium.LoadEnd += OnWebViewLoadEnd; chromium.LoadError += OnWebViewLoadError; chromium.TitleChanged += delegate { TitleChanged?.Invoke(); }; chromium.JavascriptContextCreated += OnJavascriptContextCreated; chromium.JavascriptContextReleased += OnJavascriptContextReleased; chromium.JavascriptUncaughException += OnJavascriptUncaughException; chromium.UnhandledException += (o, e) => ForwardUnhandledAsyncException(e.Exception); chromium.RequestHandler = new InternalRequestHandler(this); chromium.LifeSpanHandler = new InternalLifeSpanHandler(this); chromium.ContextMenuHandler = new InternalContextMenuHandler(this); chromium.DialogHandler = new InternalDialogHandler(this); chromium.DownloadHandler = new InternalDownloadHandler(this); chromium.JSDialogHandler = new InternalJsDialogHandler(this); chromium.DragHandler = new InternalDragHandler(this); chromium.KeyboardHandler = new InternalKeyboardHandler(this); if (!Settings.OsrEnabled) { // having the handler (by default) seems to cause some focus troubles, enable only osr disabled chromium.FocusHandler = new InternalFocusHandler(this); } EditCommands = new EditCommands(chromium); disposables = new IDisposable[] { AsyncCancellationTokenSource, chromium // browser should be the last }; ExtraInitialize(); GlobalWebViewInitialized?.Invoke(this); }