Exemplo n.º 1
0
        /// <summary>
        /// this is done just once, to globally initialize CefSharp/CEF
        /// </summary>
        private void InitBrowser()
        {
            CefSettings settings = new CefSettings();

            settings.RemoteDebuggingPort = 8088;
            settings.CachePath           = "cache";
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            settings.CefCommandLineArgs.Add("allow-running-insecure-content", "1");
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");
            //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others.
            //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
            settings.CefCommandLineArgs.Add("--enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash.



            settings.RegisterScheme(new CefCustomScheme {
                SchemeName           = "sharpbrowser",
                SchemeHandlerFactory = new SchemeHandlerFactory()
            });

            settings.UserAgent = UserAgent;

            settings.IgnoreCertificateErrors = true;

            settings.CachePath = GetAppDir("Cache");
            if (Cef.IsInitialized == false)
            {
                Cef.Initialize(settings);
            }



            dHandler   = new DownloadHandler(this);
            lHandler   = new LifeSpanHandler(this);
            mHandler   = new ContextMenuHandler(this);
            kHandler   = new KeyboardHandler(this);
            rHandler   = new RequestHandler(this);
            Dsphandler = new DisplayHandler();


            InitDownloads();

            host = new HostHandler(this);

            AddNewBrowser(tabStrip1, HomepageURL);
        }
Exemplo n.º 2
0
        /// <summary>
        /// these hotkeys work when the user is focussed on the .NET form and its controls,
        /// AND when the user is focussed on the browser (CefSharp portion)
        /// </summary>
        private void InitHotkeys()
        {
            // browser hotkeys
            KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.W, true);
            KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.Escape, true);
            KeyboardHandler.AddHotKey(this, AddBlankWindow, Keys.N, true);
            KeyboardHandler.AddHotKey(this, AddBlankTab, Keys.T, true);
            KeyboardHandler.AddHotKey(this, RefreshActiveTab, Keys.F5);
            KeyboardHandler.AddHotKey(this, OpenDeveloperTools, Keys.F12);
            KeyboardHandler.AddHotKey(this, NextTab, Keys.Tab, true);
            KeyboardHandler.AddHotKey(this, PrevTab, Keys.Tab, true, true);

            // search hotkeys
            KeyboardHandler.AddHotKey(this, OpenSearch, Keys.F, true);
            KeyboardHandler.AddHotKey(this, CloseSearch, Keys.Escape);
            KeyboardHandler.AddHotKey(this, StopActiveTab, Keys.Escape);
        }