コード例 #1
0
ファイル: ChromiumBrowser.cs プロジェクト: wingwu123/Chromely
        internal void CreateBrowser(IntPtr hostHandle, IntPtr winXID)
        {
            if (_client == null)
            {
                _client = CreateClient();
            }
            if (_settings == null)
            {
                _settings = new CefBrowserSettings();
            }

            _settings.DefaultEncoding             = "UTF-8";
            _settings.FileAccessFromFileUrls      = CefState.Enabled;
            _settings.UniversalAccessFromFileUrls = CefState.Enabled;
            _settings.WebSecurity = CefState.Disabled;

            HostHandle = hostHandle;
            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsChild(winXID, new CefRectangle(0, 0, _config.WindowOptions.Size.Width, _config.WindowOptions.Size.Height));

            Address  = _config.StartUrl;
            StartUrl = _config.StartUrl;
            CefBrowserHost.CreateBrowser(windowInfo, _client, _settings, StartUrl);
        }
コード例 #2
0
    public BaseCEFClient CreateBrowser(BaseCEFClient client = null, string url = null)
    {
        if (!initialized)
        {
            return(null);
        }

        if (client == null)
        {
            client = new BaseCEFClient(BrowserPageWidth, BrowserPageHeight);
        }

        var browserSettings = new CefBrowserSettings()
        {
            JavaScript          = JSRunnable? CefState.Enabled : CefState.Disabled,
            WindowlessFrameRate = frameRate
        };

        var windowSettings = CefWindowInfo.Create();

        windowSettings.SetAsWindowless(IntPtr.Zero, false);

        if (url != null)
        {
            CefBrowserHost.CreateBrowser(windowSettings, client, browserSettings, url);
        }
        else
        {
            CefBrowserHost.CreateBrowser(windowSettings, client, browserSettings);
        }

        registeredClients.Add(client);
        return(client);
    }
コード例 #3
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="width">Browser rect width</param>
        /// <param name="height">Browser rect height</param>
        /// <param name="starturl"></param>
        public void Init(int width, int height, string starturl)
        {
            RegisterMessageRouter();

            CefWindowInfo cefWindowInfo = CefWindowInfo.Create();

            cefWindowInfo.SetAsWindowless(IntPtr.Zero, false);
            var cefBrowserSettings = new CefBrowserSettings {
                JavaScript          = CefState.Enabled,
                TabToLinks          = CefState.Enabled,
                WebSecurity         = CefState.Disabled,
                WebGL               = CefState.Enabled,
                WindowlessFrameRate = 30
            };



            _client = new WorkerCefClient(width, height, this);

            string url = "http://www.yandex.ru/";

            if (starturl != "")
            {
                url = starturl;
            }
            CefBrowserHost.CreateBrowser(cefWindowInfo, _client, cefBrowserSettings, url);



            _initialized = true;
        }
コード例 #4
0
        /// <summary>
        /// 加载Cef相关的资源
        /// </summary>
        public MainUIRender(GraphicsDevice gd, IntPtr handle, uint windwosWidth, uint windowsHeight)
        {
            _gd            = gd;
            _windowsHeight = windowsHeight;
            _windowsWidth  = windwosWidth;
            CefWindowInfo cefWindowInfo = CefWindowInfo.Create();

            cefWindowInfo.SetAsWindowless(handle, true);

            CefBrowserSettings cefBrowserSettings = new CefBrowserSettings()
            {
                BackgroundColor           = new CefColor(0, 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 CefOSRClient(this);

            // Start up the browser instance.
            CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.url) ? "http://www.google.com" : this.url);
        }
コード例 #5
0
ファイル: Window.cs プロジェクト: ulkyome/HtmlUi
        /// <summary>
        /// Creates the browser.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="position">The position.</param>
        protected void CreateBrowser(IntPtr handle, CefRectangle position)
        {
            Application.Current.EnsureCefThread();

            if (IsBrowserCreated)
            {
                throw new InvalidOperationException("Browser already created.");
            }

            Logger.Info("Creating browser.");

            var cefWindowInfo = CefWindowInfo.Create();

            cefWindowInfo.SetAsChild(handle, position);

            var cefClient = new Client();

            cefClient.BrowserCreated += (sender, e) =>
            {
                CefBrowser = e.CefBrowser;

                if (BrowserCreated != null)
                {
                    BrowserCreated(this, e);
                }
            };

            var cefSettings = new CefBrowserSettings();

            CefBrowserHost.CreateBrowser(cefWindowInfo, cefClient, cefSettings, Application.Current.GetContentUrl(View));

            IsBrowserCreated = true;

            Logger.Info("Browser created.");
        }
コード例 #6
0
        /// <summary>
        /// 创建一个web browser 对象,并打开一个新的空白页
        /// </summary>
        private void CreateNewWebBrowser()
        {
            var autoSet = new AutoResetEvent(false);
          
            // Instruct CEF to not render to a window at all.
            CefWindowInfo cefWindowInfo = CefWindowInfo.Create();
            cefWindowInfo.SetAsWindowless(IntPtr.Zero, true);

            // 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 HeadLessCefClient(1024, 720);
            var loader = cefClient.GetCurrentLoadHandler();
            loader.BrowserCreated += (s, e) =>
            {

                //事件通知 当cef  browser 创建完毕
                //创建完毕后 保存 browser 对象的实例
                this.WebBrowser = e.Browser;
                this._is_cef_browser_has_created = true;

                //发送终止信号
                autoSet.Set();
            };
            //注册  加载完毕事件handler
            loader.LoadEnd += this.OnWebBrowserLoadEnd;
            // Start up the browser instance.
            string url = "about:blank";
            CefBrowserHost.CreateBrowser(cefWindowInfo, cefClient, cefBrowserSettings, url);

            //等待结束信号
            autoSet.WaitOne();
        }
コード例 #7
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
            {
                if (!_handleCreated)
                {
                    Paint += PaintInDesignMode;
                }
            }
            else
            {
                var windowInfo = CefWindowInfo.Create();
                windowInfo.SetAsChild(Handle, new CefRectangle {
                    X = 0, Y = 0, Width = Width, Height = Height
                });

                var client = CreateWebClient();

                var settings = BrowserSettings;
                if (settings == null)
                {
                    settings = new CefBrowserSettings {
                    }
                }
                ;

                CefBrowserHost.CreateBrowser(windowInfo, client, settings, StartUrl);
            }

            _handleCreated = true;
        }
コード例 #8
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
            {
                if (!_handleCreated)
                {
                    Paint += PaintInDesignMode;
                }
            }
            else
            {
                var windowInfo = CefWindowInfo.Create();
                windowInfo.SetAsChild(Handle, new CefRectangle {
                    X = 0, Y = 0, Width = Width, Height = Height
                });

                var client = new CefWebClient(this);

                var settings = new CefBrowserSettings
                {
                    // AuthorAndUserStylesDisabled = false,
                };

                CefBrowserHost.CreateBrowser(windowInfo, client, settings, StartUrl);
            }

            _handleCreated = true;
        }
コード例 #9
0
ファイル: Client.cs プロジェクト: PlumpMath/CefPaste
        private void CreateBrowser()
        {
            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetTransparentPainting(true);

            windowInfo.SetAsOffScreen(IntPtr.Zero);
            windowInfo.Width  = this.Width;
            windowInfo.Height = this.Height;

            var browserSettings = new CefBrowserSettings
            {
                AcceleratedCompositing = CefState.Disabled,
                FileAccessFromFileUrls = CefState.Enabled,
                Java = CefState.Disabled,
                JavaScriptAccessClipboard = CefState.Disabled,
                JavaScriptCloseWindows    = CefState.Disabled,
                WebGL = CefState.Disabled,
            };

            CefBrowserHost.CreateBrowser(
                client: this,
                windowInfo: windowInfo,
                settings: browserSettings,
                requestContext: CefRequestContext.CreateContext(new RequestContextHandler(this.CookieDirectory)));
        }
コード例 #10
0
        private Task <IWebBrowserWindowProvider> InitTask(string fullpath, IWebSessionLogger logger)
        {
            TaskCompletionSource <IWebBrowserWindowProvider> tcs = new TaskCompletionSource <IWebBrowserWindowProvider>();

            Task.Run(async() =>
            {
                var cefWindowInfo = CefWindowInfo.Create();
                cefWindowInfo.SetAsWindowless(IntPtr.Zero, true);

                //// Settings for the browser window itself (e.g. enable JavaScript?).
                var cefBrowserSettings = new CefBrowserSettings();

                // Initialize some the cust interactions with the browser process.
                var cefClient = new TestCefClient();

                // Start up the browser instance.
                CefBrowserHost.CreateBrowser(cefWindowInfo, cefClient, cefBrowserSettings, fullpath);

                _CefBrowser = await cefClient.GetLoadedBrowserAsync();

                _CefFrame = _CefBrowser.GetMainFrame();
                _TestCefGlueHTMLWindowProvider = new TestCefGlueHTMLWindowProvider(_CefFrame, cefClient);
                tcs.SetResult(_TestCefGlueHTMLWindowProvider);
            });

            return(tcs.Task);
        }
コード例 #11
0
ファイル: WebBrowserControl.cs プロジェクト: whztt07/SDK
        void CreateBrowser()
        {
            if (!isCefRuntimeInitialized)
            {
                InitializeCefRuntime();
            }

            if (isCefRuntimeInitialized)
            {
                this.viewSize = GetNeededSize();

                var windowInfo = CefWindowInfo.Create();
                windowInfo.SetAsWindowless(IntPtr.Zero, false);

                var client = new WebClient(this);

                var settings = new CefBrowserSettings
                {
                    // AuthorAndUserStylesDisabled = false,
                };

                CefBrowserHost.CreateBrowser(windowInfo, client, settings,
                                             !string.IsNullOrEmpty(StartURL) ? StartURL : "about:blank");

                if (!string.IsNullOrEmpty(startUrl))
                {
                    LoadURL(startUrl);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Create a new texture renderer.
        /// </summary>
        /// <param name="logger">The logger to log to.</param>
        /// <param name="frameRate">
        /// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint will
        /// be called for a windowless browser. The actual fps may be lower if the browser
        /// cannot generate frames at the requested rate. The minimum value is 1 and the
        /// maximum value is 60 (default 30).
        /// </param>
        public HTMLTextureRenderer(ILogger logger, int frameRate)
        {
            Logger    = logger;
            FrameRate = VMath.Clamp(frameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);

            FLoaded = false;

            var settings = new CefBrowserSettings();

            settings.FileAccessFromFileUrls = CefState.Enabled;
            settings.Plugins     = CefState.Enabled;
            settings.RemoteFonts = CefState.Enabled;
            settings.UniversalAccessFromFileUrls = CefState.Enabled;
            settings.WebGL               = CefState.Enabled;
            settings.WebSecurity         = CefState.Disabled;
            settings.WindowlessFrameRate = frameRate;

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsWindowless(IntPtr.Zero, true);

            FWebClient = new WebClient(this);
            // See http://magpcss.org/ceforum/viewtopic.php?f=6&t=5901
            // We need to maintain different request contexts in order to have different zoom levels
            // See https://bitbucket.org/chromiumembedded/cef/issues/1314
            var rcSettings = new CefRequestContextSettings()
            {
                IgnoreCertificateErrors = true
            };

            FRequestContext = CefRequestContext.CreateContext(rcSettings, new WebClient.RequestContextHandler());
            CefBrowserHost.CreateBrowser(windowInfo, FWebClient, settings, FRequestContext);
            // Block until browser is created
            FBrowserAttachedEvent.WaitOne();
        }
コード例 #13
0
ファイル: FormiumWebView.cs プロジェクト: LSluoshi/NanUI
        public void CreateBrowser(CefWindowInfo windowInfo)
        {
            if (BrowserClient == null)
            {
                BrowserClient = new BrowserClient(Owner);
            }

            CefBrowserHost.CreateBrowser(windowInfo, BrowserClient, _settings, _startUrl);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public void Create(CefWindowInfo windowInfo)
        {
            if (Client == null)
            {
                Client = new WebClient(this);
            }

            CefBrowserHost.CreateBrowser(windowInfo, Client, Host.Config.CefBrowserSettings, StartUrl);
        }
コード例 #16
0
        public void Create(CefWindowInfo windowInfo)
        {
            if (_client == null)
            {
                _client = new WebClient(this);
            }

            CefBrowserHost.CreateBrowser(windowInfo, _client, _settings, StartUrl);
        }
コード例 #17
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);
        }
コード例 #18
0
        /// <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");
        }
コード例 #19
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);
        }
コード例 #20
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);
        }
コード例 #21
0
        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 );
            }
        }
コード例 #22
0
ファイル: LVCefControl.cs プロジェクト: mstroehle/lvcef
 //Race condition? user calls createBrowser twice very quickly
 //Does CEF check for multiple uses of same handle?
 public void createBrowser()
 {
     Debug.WriteLine(DBGPREFIX + "createBrowser starting creation of CefBrowser");
     if (Browser == null)
     {
         var settings = new CefBrowserSettings {
         };
         CefBrowserHost.CreateBrowser(getCefWindowInfo(), CefClient, settings, StartUrl);
     }
     else
     {
         Debug.WriteLine(DBGPREFIX + "createBrowser has already created CefBrowser instance for this control, request ignored.");
     }
 }
コード例 #23
0
        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();
        }
コード例 #24
0
        public override void CreateControl()
        {
            base.CreateControl();

            if (!_controlCreated && !DesignMode)
            {
                if (!ParagonRuntime.IsInitialized)
                {
                    ParagonRuntime.Initialize();
                }

                _client = new CefWebClient(this);

                if (!IsPopup && _browser == null)
                {
                    var settings = new CefBrowserSettings
                    {
                        Java = CefState.Disabled
                    };

                    using (AutoStopwatch.TimeIt("Creating browser"))
                    {
                        var info = CefWindowInfo.Create();
                        var ea   = new BrowserCreateEventArgs();

                        using (AutoStopwatch.TimeIt("Raising BeforeBrowserCreate event"))
                        {
                            BeforeBrowserCreate.Raise(this, ea);
                        }

                        _router     = ea.Router;
                        _currentUrl = _sourceUrl;

                        if (IntPtr.Zero != ParentHandle)
                        {
                            RECT rect = new RECT();
                            Win32Api.GetClientRect(ParentHandle, ref rect);
                            info.SetAsChild(ParentHandle, new CefRectangle(rect.Left, rect.Top, rect.Width, rect.Height));
                        }

                        Logger.Info(string.Format("OnHandleCreated - Creating a browser with url {0}", _currentUrl));
                        CefBrowserHost.CreateBrowser(info, _client, settings, _currentUrl);
                    }
                }

                _controlCreated = true;
            }
        }
コード例 #25
0
        public CefGlueBrowser(IntPtr parentHandle, CefApp app, CefConfig config)
        {
            this.ParentHandle = parentHandle;
            this.App          = app;
            this.Config       = config;

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsChild(parentHandle, new CefRectangle(0, 0, config.Width, config.Height));

            this.WebBrowser          = new WebBrowser(this);
            this.WebBrowser.Created += WebBrowser_Created;
            this.Client              = new WebClient(this.WebBrowser);

            CefBrowserHost.CreateBrowser(windowInfo, Client, config.CefBrowserSettings, config.StartUrl);
        }
コード例 #26
0
        //BSCompletionCallback bsc = new BSCompletionCallback();
        //BSSetCookieCallback bscc = new BSSetCookieCallback();
        public BsCtl(Control ctl, string url, string type)
        {
            Parent = ctl;
            var cwi = CefWindowInfo.Create();

            cwi.SetAsChild(Parent.Handle, new CefRectangle(0, 0, Parent.Width, Parent.Height));
            var bc = new BsClient(type, ctl);

            bc.OnCreated += bc_OnCreated;
            var bss = new CefBrowserSettings()
            {
            };

            CefBrowserHost.CreateBrowser(cwi, bc, bss, url);//,rc);
            Parent.SizeChanged += Parent_SizeChanged;
        }
コード例 #27
0
        public XiboCefWebBrowser()
        {
            SetStyle(
                ControlStyles.ContainerControl
                | ControlStyles.ResizeRedraw
                | ControlStyles.FixedWidth
                | ControlStyles.FixedHeight
                | ControlStyles.StandardClick
                | ControlStyles.UserMouse
                | ControlStyles.SupportsTransparentBackColor
                | ControlStyles.StandardDoubleClick
                | ControlStyles.OptimizedDoubleBuffer
                | ControlStyles.CacheText
                | ControlStyles.EnableNotifyMessage
                | ControlStyles.DoubleBuffer
                | ControlStyles.OptimizedDoubleBuffer
                | ControlStyles.UseTextForAccessibility
                | ControlStyles.Opaque,
                false);

            SetStyle(
                ControlStyles.UserPaint
                | ControlStyles.AllPaintingInWmPaint
                | ControlStyles.Selectable,
                true);

            StartUrl = "about:blank";

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsChild(Handle, new CefRectangle {
                X = 0, Y = 0, Width = Width, Height = Height
            });

            var client = CreateWebClient();

            var settings = BrowserSettings;

            if (settings == null)
            {
                settings = new CefBrowserSettings {
                }
            }
            ;

            CefBrowserHost.CreateBrowser(windowInfo, client, settings, StartUrl);
        }
コード例 #28
0
ファイル: CefWebBrowser.cs プロジェクト: E024/Chromely
        private void CreateBrowser()
        {
            var windowInfo = CefWindowInfo.Create();
            windowInfo.SetAsChild(m_browserConfig.ParentHandle, m_browserConfig.CefRectangle);

            var client = CreateWebClient();

            var settings = BrowserSettings;
            if (settings == null) settings = new CefBrowserSettings { };

            settings.DefaultEncoding = "UTF-8";
            settings.FileAccessFromFileUrls = CefState.Enabled;
            settings.UniversalAccessFromFileUrls = CefState.Enabled;
            settings.WebSecurity = CefState.Enabled; 

            CefBrowserHost.CreateBrowser(windowInfo, client, settings, StartUrl);
        }
コード例 #29
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="windowInfo">
        /// The window info.
        /// </param>
        public void Create(CefWindowInfo windowInfo)
        {
            if (mClient == null)
            {
                IoC.RegisterInstance(typeof(CefGlueBrowser), typeof(CefGlueBrowser).FullName, this);
                mClient = new CefGlueClient(CefGlueClientParams.Create(this));
            }

            mSettings = mSettings ?? new CefBrowserSettings();

            mSettings.DefaultEncoding             = "UTF-8";
            mSettings.FileAccessFromFileUrls      = CefState.Enabled;
            mSettings.UniversalAccessFromFileUrls = CefState.Enabled;
            mSettings.WebSecurity = CefState.Enabled;

            CefBrowserHost.CreateBrowser(windowInfo, mClient, mSettings, StartUrl);
        }
コード例 #30
0
        public SharpDXCefBrowser(GraphicsDevice GraphicsDevice, int width = 1024, int height = 768)
        {
            Width  = width;
            Height = height;

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsOffScreen(IntPtr.Zero);
            windowInfo.TransparentPainting = true;


            var cefBrowserSettings = new CefBrowserSettings();

            _cefClient = new SharpDXCefClient(this, GraphicsDevice);

            CefBrowserHost.CreateBrowser(windowInfo, _cefClient, cefBrowserSettings);
        }