private void BtnDevTools_Click(object sender, EventArgs e) { var host = browser.Browser.GetHost(); var wi = CefWindowInfo.Create(); wi.SetAsPopup(IntPtr.Zero, "DevTools"); host.ShowDevTools(wi, new DevToolsWebClient(), new CefBrowserSettings(), new CefPoint(0, 0)); }
/// <summary> /// The on realized. /// </summary> /// <param name="hwnd"> /// The hwnd. /// </param> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> /// <exception cref="NotSupportedException"> /// Exception returned for MacOS not supported. /// </exception> protected override void OnCreate(IntPtr hwnd, int width, int height) { var windowInfo = CefWindowInfo.Create(); var placement = _hostConfig.HostPlacement; windowInfo.SetAsChild(hwnd, new CefRectangle(0, 0, placement.Width, placement.Height)); Browser.Create(windowInfo); }
public virtual void ShowDevTools(CefPoint inspectElementAt) { var windowInfo = new CefWindowInfo(); windowInfo.SetAsPopup(IntPtr.Zero, "DevTools"); AliveBrowserHost.ShowDevTools(windowInfo, null, BrowserSettings, inspectElementAt); windowInfo.Dispose(); }
private void OpenDeveloperToolsCommand(object sender, EventArgs e) { var host = MainView.CurrentBrowser.GetHost(); var wi = CefWindowInfo.Create(); wi.SetAsPopup(IntPtr.Zero, "DevTools"); host.ShowDevTools(wi, new DevToolsWebClient(), new CefBrowserSettings(), new CefPoint(0, 0)); }
public CefBeforePopupEventArgs(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings) { this.parentBrowser = parentBrowser; this.popupFeatures = popupFeatures; this.windowInfo = windowInfo; this.url = url; this.client = client; this.settings = settings; }
public void Create(CefWindowInfo windowInfo) { if (this.client == null) { this.client = CefWebClientFactory.Default.Create(this); } CefBrowser.Create(windowInfo, this.client, this.StartUrl, this.settings); }
public void Create(CefWindowInfo windowInfo) { if (_client == null) { _client = new WebClient(this); } CefBrowserHost.CreateBrowser(windowInfo, _client, _settings, StartUrl); }
public async Task Create(CefWindowInfo windowInfo) { var settings = new CefBrowserSettings { WindowlessFrameRate = 5 }; CefBrowserHost.CreateBrowser(windowInfo, this.client, settings, string.Empty); await this.initializedCompletionSource.Task.ConfigureAwait(false); }
public void Create(CefWindowInfo windowInfo) { if (Client == null) { Client = new WebClient(this); } CefBrowserHost.CreateBrowser(windowInfo, Client, Host.Config.CefBrowserSettings, StartUrl); }
public void CreateBrowser(CefWindowInfo windowInfo) { if (BrowserClient == null) { BrowserClient = new BrowserClient(Owner); } CefBrowserHost.CreateBrowser(windowInfo, BrowserClient, _settings, _startUrl); }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { var e = new CancelEventArgs(); _core.NewWindow(targetUrl, e); return(e.Cancel); }
/// <summary> /// The on realized. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> /// <exception cref="NotSupportedException"> /// Exception returned for MacOS not supported. /// </exception> protected override void OnCreated(object sender, CreatedEventArgs createdEventArgs) { var windowInfo = CefWindowInfo.Create(); var placement = _hostConfig.HostPlacement; windowInfo.SetAsChild(createdEventArgs.WinXID, new CefRectangle(0, 0, placement.Width, placement.Height)); Browser.Create(windowInfo); }
/// <summary> /// ShowDevTools. /// </summary> public void ShowDevTools() { var host = this.WebBrowser.CefBrowser.GetHost(); var wi = CefWindowInfo.Create(); wi.SetAsPopup(IntPtr.Zero, "DevTools"); var client = new CefGlue.Lib.Browser.WebClient(this.WebBrowser); host.ShowDevTools(wi, client, this.BrowserSettings, new CefPoint(0, 0)); }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { // Block a new popup window. // Instead just redirect the popup target to the current browser. browser.GetMainFrame().LoadUrl(targetUrl); return(true); }
/// <summary> /// 创建浏览器 /// </summary> private void CreateBrowser() { var windowInfo = CefWindowInfo.Create(); windowInfo.SetAsChild(Handle, new CefRectangle(0, 0, Width, Height)); var client = new WebClient(this); var settings = new CefBrowserSettings(); CefBrowserHost.CreateBrowser(windowInfo, client, settings, Url ?? "about:blank"); }
public void showDevTools(bool firstWindow = true) { if (this.Browser != null) { CefBrowser b = firstWindow ? this.Browser : this.LastBrowser; CefWindowInfo wi = CefWindowInfo.Create(); wi.SetAsPopup(b.GetHost().GetWindowHandle(), "DevTools"); b.GetHost().ShowDevTools(wi, this.Client, new CefBrowserSettings(), new CefPoint()); } }
protected override void OnAfterCreated(CefBrowser browser) { base.OnAfterCreated(browser); var wi = CefWindowInfo.Create(); var host = browser.GetHost(); wi.SetAsPopup(IntPtr.Zero, "DevTools"); host.ShowDevTools(wi, new DevToolsWebClient(), new CefBrowserSettings(), new CefPoint(0, 0)); }
/// <summary> /// The create. /// </summary> /// <param name="windowInfo"> /// The window info. /// </param> public void Create(CefWindowInfo windowInfo) { if (this.mClient == null) { IoC.RegisterInstance(typeof(CefGlueBrowser), typeof(CefGlueBrowser).FullName, this); this.mClient = new CefGlueClient(CefGlueClientParams.Create(this)); } CefBrowserHost.CreateBrowser(windowInfo, this.mClient, this.mSettings, this.StartUrl); }
private LVCefClient _lvCefClient; //keeping references to anything CEF makes it crashy, release reference after browser made public void openDevTools() { if (_browser != null) { var host = _browser.GetHost(); var wi = CefWindowInfo.Create(); wi.SetAsPopup(IntPtr.Zero, "DevTools"); host.ShowDevTools(wi, new DevToolsWebClient(), new CefBrowserSettings(), new CefPoint(0, 0)); } }
private void StartCef() { #if UNITY_EDITOR CefRuntime.Load(Path.Combine(Application.dataPath, "Plugins", "Cef", "Windows")); #else CefRuntime.Load(); #endif var cefMainArgs = new CefMainArgs(new string[] { }); var cefApp = new OffscreenCEFClient.OffscreenCEFApp(); // This is where the code path diverges for child processes. if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Debug.LogError("Could not start the secondary process."); } var cefSettings = new CefSettings { //ExternalMessagePump = true, MultiThreadedMessageLoop = false, SingleProcess = true, LogSeverity = CefLogSeverity.Verbose, LogFile = "cef.log", WindowlessRenderingEnabled = true, NoSandbox = true }; // Start the browser process (a child process). CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); // Instruct CEF to not render to a window. CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsWindowless(IntPtr.Zero, true); // Settings for the browser window itself (e.g. enable JavaScript?). CefBrowserSettings cefBrowserSettings = new CefBrowserSettings() { }; Debug.Log("Start with window: " + this.windowWidth + ", " + this.windowHeight); // Initialize some of the custom interactions with the browser process. this.cefClient = new OffscreenCEFClient( this.windowWidth, this.windowHeight, this.hideScrollbars, this.BrowserTexture, this ); // Start up the browser instance. CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.overlayUrl) ? "http://www.google.com" : this.overlayUrl); }
public Menu( CefApp menuCeffApp, CefMainArgs mainArgs, InputProcessor inputProcessor, MenuBrowserClient browserClient, StateManager stateManager, EventBus eventBus ) { // State Initialization _buttons = (GameControllerButton[])Enum.GetValues(typeof(GameControllerButton)); _analogs = (GameControllerAnalog[])Enum.GetValues(typeof(GameControllerAnalog)); _eventTokenList = new List <SubscriptionToken>(); _eventBus = eventBus; #if (DEBUG) var logSeverity = CefLogSeverity.Error; #else var logSeverity = CefLogSeverity.Error; #endif var settings = new CefSettings { WindowlessRenderingEnabled = true, LogSeverity = logSeverity, NoSandbox = true }; CefRuntime.Initialize(mainArgs, settings, menuCeffApp, IntPtr.Zero); // Instruct CEF to not render to a window at all. var cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsWindowless(IntPtr.Zero, false); var browserSettings = new CefBrowserSettings() { WindowlessFrameRate = 60, }; _inputProcessor = inputProcessor; _browserClient = browserClient; _browser = CefBrowserHost.CreateBrowserSync( cefWindowInfo, _browserClient, browserSettings, "http://localhost:4200" ); _eventTokenList.Add(_eventBus.Subscribe <OpenMenuEvent>(OnOpenMenuEvent)); _eventTokenList.Add(_eventBus.Subscribe <CloseMenuEvent>(OnCloseMenuEvent)); var game = stateManager.GetGameById("Super Mario World (USA)"); eventBus.Publish(new LoadGameEvent(game)); }
private void CreateBrowser() { var windowInfo = CefWindowInfo.Create(); var windowHandle = InteropLinux.gtk_widget_get_window(_container.Handle); var xid = InteropLinux.gdk_x11_window_get_xid(windowHandle); windowInfo.SetAsChild(xid, new CefRectangle(0, 0, AllocatedWidth, AllocatedHeight)); Browser.Create(windowInfo, _startUrl); _initialized = true; _startUrl = null; }
/// <summary> /// Opens the developer tools. /// </summary> private void OpenDeveloperTools() { Application.Current.InvokeOnMain(() => { var windowInfo = CefWindowInfo.Create(); windowInfo.SetAsPopup(IntPtr.Zero, "Developer tools"); windowInfo.Width = 1200; windowInfo.Height = 500; CefBrowser.GetHost().ShowDevTools(windowInfo, new DeveloperToolsClient(), new CefBrowserSettings(), new CefPoint(0, 0)); }); }
private void StartCef() { #if UNITY_EDITOR CefRuntime.Load("./Assets/Plugins/x86_64"); #else CefRuntime.Load(); #endif var cefMainArgs = new CefMainArgs(new string[] { }); var cefApp = new OffscreenCEFClient.OffscreenCEFApp(); // This is where the code path diverges for child processes. if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Debug.LogError("Could not start the secondary process."); } var cefSettings = new CefSettings { //ExternalMessagePump = true, MultiThreadedMessageLoop = false, SingleProcess = true, LogSeverity = CefLogSeverity.Verbose, LogFile = "cef.log", WindowlessRenderingEnabled = true, NoSandbox = true, }; // Start the browser process (a child process). CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); // Instruct CEF to not render to a window. CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsWindowless(IntPtr.Zero, false); // Settings for the browser window itself (e.g. enable JavaScript?). CefBrowserSettings cefBrowserSettings = new CefBrowserSettings() { BackgroundColor = new CefColor(255, 60, 85, 115), JavaScript = CefState.Enabled, JavaScriptAccessClipboard = CefState.Disabled, JavaScriptCloseWindows = CefState.Disabled, JavaScriptDomPaste = CefState.Disabled, JavaScriptOpenWindows = CefState.Disabled, LocalStorage = CefState.Disabled }; // Initialize some of the custom interactions with the browser process. this.cefClient = new OffscreenCEFClient(this.windowSize, this.hideScrollbars); // Start up the browser instance. CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.url) ? "http://www.google.com" : this.url); }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings, noJavascriptAccess); _core.InvokeIfRequired(() => _core.OnBeforePopup(e)); client = e.Client; noJavascriptAccess = e.NoJavascriptAccess; return e.Handled; }
public void ShowDevTools(bool firstwindow = true) { this.allBrowsersSemaphore.Wait(); if (this.allBrowsers.Count > 0) { var b = firstwindow ? this.allBrowsers.First() : this.allBrowsers.Last(); var wi = CefWindowInfo.Create(); wi.SetAsPopup(b.GetHost().GetWindowHandle(), "DevTools"); b.GetHost().ShowDevTools(wi, this.Client, new CefBrowserSettings(), new CefPoint()); } this.allBrowsersSemaphore.Release(); }
protected override void OnCreated(object sender, CreatedEventArgs createdEventArgs) { Handle = createdEventArgs.Window; WinXID = createdEventArgs.WinXID; Browser.HostHandle = createdEventArgs.Window; var windowInfo = CefWindowInfo.Create(); windowInfo.SetAsChild(createdEventArgs.WinXID, new CefRectangle(0, 0, _config.WindowOptions.Size.Width, _config.WindowOptions.Size.Height)); Browser.Create(windowInfo); }
void CreateBrowser() { if (!isCefRuntimeInitialized) { InitializeCefRuntime(); } if (isCefRuntimeInitialized) { viewSize = GetNeededSize(); var windowInfo = CefWindowInfo.Create(); windowInfo.SetAsWindowless(IntPtr.Zero, false); var client = new WebClient(this); var settings = new CefBrowserSettings { // AuthorAndUserStylesDisabled = false, }; //string r = GetURLFromVirtualFileName( "Maps\\Engine Features Demo\\Resources\\GUI\\FileTest.html" ); //r = PathUtils.GetRealPathByVirtual( "Maps\\Engine Features Demo\\Resources\\GUI\\FileTest.html" ); //CefBrowserHost.CreateBrowser( windowInfo, client, settings, r );//"about:blank" ); //if( !string.IsNullOrEmpty( startUrl ) ) // LoadURL( startUrl ); //LoadFileByVirtualFileName( "Maps\\Engine Features Demo\\Resources\\GUI\\FileTest.html" ); string url = "about:blank"; if (!string.IsNullOrEmpty(StartURL)) { url = StartURL; } else if (!string.IsNullOrEmpty(StartFile)) { url = GetURLByFileName(StartFile); } CefBrowserHost.CreateBrowser(windowInfo, client, settings, url); //CefBrowserHost.CreateBrowser( windowInfo, client, settings, "about:blank" ); //if( !string.IsNullOrEmpty( startFile ) ) // LoadFileByVirtualFileName( startFile ); //else if( !string.IsNullOrEmpty( startUrl ) ) // LoadURL( startUrl ); //CefBrowserHost.CreateBrowser( windowInfo, client, settings, !string.IsNullOrEmpty( StartURL ) ? StartURL : "about:blank" ); //if( !string.IsNullOrEmpty( startUrl ) ) // LoadURL( startUrl ); } }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (!DesignMode) { var windowInfo = CefWindowInfo.Create(); windowInfo.SetAsChild(Handle, new CefRectangle { X = 0, Y = 0, Width = Width, Height = Height }); _core.Create(windowInfo); } }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { //settings.WebSecurity = CefState.Disabled; windowInfo.SetAsWindowless(IntPtr.Zero, false); var newBrowser = new Browser(false); client = newBrowser.CefClient; WaitForBrowser(newBrowser); return(false); }
private static void Main(string[] args) { // Load CEF. This checks for the correct CEF version. CefRuntime.Load(); // Start the secondary CEF process. var cefMainArgs = new CefMainArgs(new string[0]); var cefApp = new DemoCefApp(); // This is where the code path divereges for child processes. if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp) != -1) { Console.Error.WriteLine("CefRuntime could not the secondary process."); } // Settings for all of CEF (e.g. process management and control). var cefSettings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true }; // Start the browser process (a child process). CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp); // Instruct CEF to not render to a window at all. CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsOffScreen(IntPtr.Zero); // Settings for the browser window itself (e.g. should JavaScript be enabled?). var cefBrowserSettings = new CefBrowserSettings(); // Initialize some the cust interactions with the browser process. // The browser window will be 1280 x 720 (pixels). var cefClient = new DemoCefClient(1280, 720); // Start up the browser instance. string url = "http://www.reddit.com/"; CefBrowserHost.CreateBrowser(cefWindowInfo, cefClient, cefBrowserSettings, url); // Hang, to let the browser to do its work. Console.WriteLine("Press a key at any time to end the program."); Console.ReadKey(); // Clean up CEF. CefRuntime.Shutdown(); }
public BeforePopupEventArgs( CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, bool noJavascriptAccess) { Frame = frame; TargetUrl = targetUrl; TargetFrameName = targetFrameName; PopupFeatures = popupFeatures; WindowInfo = windowInfo; Client = client; Settings = settings; NoJavascriptAccess = noJavascriptAccess; }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (this.DesignMode) { if (!this.handleCreatedHandled) { this.Paint += new PaintEventHandler(this.DesignModePaint); } } else { if (this.handleCreatedHandled) { throw new InvalidOperationException("Handle already created."); } // TODO: fix when browser still creating, but control already disposed // it can be done via setting client to detached state, and onaftercreated // force browser to be closed. var windowInfo = new CefWindowInfo(); #if WINDOWS windowInfo.SetAsChild(this.Handle, 0, 0, this.Width, this.Height); #else #error Only windows supported. #endif this.core.Create(windowInfo); windowInfo.Dispose(); } this.handleCreatedHandled = true; }
protected override bool OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings) { #if DIAGNOSTICS Cef.Logger.Trace(LogTarget.CefLifeSpanHandler, "OnBeforePopup"); #endif /* #if DEBUG string message = string.Format( "LifeSpanHandler:OnBeforePopup\n" + " URL: {0}\n" + " X: {1}\n" + " Y: {2}\n" + " Width: {3}\n" + " Height: {4}\n" + " MenuBarVisible: {5}\n" + " StatusBarVisible: {6}\n" + " ToolBarVisible: {7}\n" + "LocationBarVisible: {8}\n" + " ScrollbarsVisible: {9}\n" + " Resizable: {10}\n" + " Fullscreen: {11}\n" + " Dialog: {12}\n", url, popupFeatures.X.HasValue ? popupFeatures.X.ToString() : "not set", popupFeatures.Y.HasValue ? popupFeatures.Y.ToString() : "not set", popupFeatures.Width.HasValue ? popupFeatures.Width.ToString() : "not set", popupFeatures.Height.HasValue ? popupFeatures.Height.ToString() : "not set", popupFeatures.MenuBarVisible, popupFeatures.StatusBarVisible, popupFeatures.ToolBarVisible, popupFeatures.LocationBarVisible, popupFeatures.ScrollbarsVisible, popupFeatures.Resizable, popupFeatures.Fullscreen, popupFeatures.Dialog ); #endif */ this.context.OnBeforePopup(parentBrowser, popupFeatures, windowInfo, url, ref client, settings); // TODO: create webview here // TODO: do not inherit browser settings for devtools client = CefWebClientFactory.Default.Create(new CefWebBrowserCore(null, this.context.Settings, url)); // TODO: create new browsercontext for popup windows return false; }
public void OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings) { var handler = this.BeforePopup; if (handler != null) { handler(this.owner, new CefBeforePopupEventArgs(parentBrowser, popupFeatures, windowInfo, url, ref client, settings)); } }