예제 #1
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);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CefGlueClient"/> class.
 /// </summary>
 /// <param name="clientParams">
 /// The client params.
 /// </param>
 public CefGlueClient(CefGlueClientParams clientParams)
 {
     CoreBrowser         = clientParams.Browser;
     mLifeSpanHandler    = clientParams.LifeSpanHandler;
     mLoadHandler        = clientParams.LoadHandler;
     mRequestHandler     = clientParams.RequestHandler;
     mDisplayHandler     = clientParams.DisplayHandler;
     mContextMenuHandler = clientParams.ContextMenuHandler;
     mFocusHandler       = clientParams.FocusHandler;
     mKeyboardHandler    = clientParams.KeyboardHandler;
     mJsDialogHandler    = clientParams.JsDialogHandler;
     mDialogHandler      = clientParams.DialogHandler;
     mDragHandler        = clientParams.DragHandler;
     mDownloadHandler    = clientParams.DownloadHandler;
     mFindHandler        = clientParams.FindHandler;
 }
예제 #3
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);
        }
예제 #4
0
 public CefGlueClient(CefGlueClientParams clientParams)
 {
     m_core               = clientParams.Browser;
     m_lifeSpanHandler    = clientParams.LifeSpanHandler;
     m_loadHandler        = clientParams.LoadHandler;
     m_requestHandler     = clientParams.RequestHandler;
     m_displayHandler     = clientParams.DisplayHandler;
     m_contextMenuHandler = clientParams.ContextMenuHandler;
     m_focusHandler       = clientParams.FocusHandler;
     m_keyboardHandler    = clientParams.KeyboardHandler;
     m_jsDialogHandler    = clientParams.JSDialogHandler;
     m_dialogHandler      = clientParams.DialogHandler;
     m_dragHandler        = clientParams.DragHandler;
     m_geolocationHandler = clientParams.GeolocationHandler;
     m_downloadHandler    = clientParams.DownloadHandler;
     m_findHandler        = clientParams.FindHandler;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CefGlueClient"/> class.
 /// </summary>
 /// <param name="clientParams">
 /// The client params.
 /// </param>
 public CefGlueClient(CefGlueClientParams clientParams)
 {
     this.CoreBrowser         = clientParams.Browser;
     this.mLifeSpanHandler    = clientParams.LifeSpanHandler;
     this.mLoadHandler        = clientParams.LoadHandler;
     this.mRequestHandler     = clientParams.RequestHandler;
     this.mDisplayHandler     = clientParams.DisplayHandler;
     this.mContextMenuHandler = clientParams.ContextMenuHandler;
     this.mFocusHandler       = clientParams.FocusHandler;
     this.mKeyboardHandler    = clientParams.KeyboardHandler;
     this.mJsDialogHandler    = clientParams.JsDialogHandler;
     this.mDialogHandler      = clientParams.DialogHandler;
     this.mDragHandler        = clientParams.DragHandler;
     this.mGeolocationHandler = clientParams.GeolocationHandler;
     this.mDownloadHandler    = clientParams.DownloadHandler;
     this.mFindHandler        = clientParams.FindHandler;
 }
예제 #6
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="browser">
        /// The browser.
        /// </param>
        /// <returns>
        /// The <see cref="CefGlueClientParams"/>.
        /// </returns>
        public static CefGlueClientParams Create(CefGlueBrowser browser)
        {
            var clientParams = new CefGlueClientParams {
                Browser = browser
            };

            try
            {
                foreach (var enumKey in CefCustomHandlerFakeTypes.GetAllCustomHandlerKeys())
                {
                    object instance = null;

                    var service = CefCustomHandlerFakeTypes.GetHandlerType(enumKey);
                    var keyStr  = enumKey.EnumToString();
                    try
                    {
                        if (IoC.IsRegistered(service, keyStr))
                        {
                            instance = IoC.GetInstance(service, keyStr);
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error(exception);
                    }

                    switch (enumKey)
                    {
                    case CefHandlerKey.LifeSpanHandler:
                        if (instance is CefLifeSpanHandler spanHandler)
                        {
                            clientParams.LifeSpanHandler = spanHandler;
                        }
                        else
                        {
                            clientParams.LifeSpanHandler = new CefGlueLifeSpanHandler();
                        }

                        break;

                    case CefHandlerKey.LoadHandler:
                        if (instance is CefLoadHandler loadHandler)
                        {
                            clientParams.LoadHandler = loadHandler;
                        }
                        else
                        {
                            clientParams.LoadHandler = new CefGlueLoadHandler();
                        }

                        break;

                    case CefHandlerKey.RequestHandler:
                        if (instance is CefRequestHandler requestHandler)
                        {
                            clientParams.RequestHandler = requestHandler;
                        }
                        else
                        {
                            clientParams.RequestHandler = new CefGlueRequestHandler();
                        }

                        break;

                    case CefHandlerKey.DisplayHandler:
                        if (instance is CefDisplayHandler displayHandler)
                        {
                            clientParams.DisplayHandler = displayHandler;
                        }
                        else
                        {
                            clientParams.DisplayHandler = new CefGlueDisplayHandler();
                        }

                        break;

                    case CefHandlerKey.ContextMenuHandler:
                        if (instance is CefContextMenuHandler menuHandler)
                        {
                            clientParams.ContextMenuHandler = menuHandler;
                        }
                        else
                        {
                            clientParams.ContextMenuHandler = new CefGlueContextMenuHandler();
                        }

                        break;

                    case CefHandlerKey.FocusHandler:
                        if (instance is CefFocusHandler focusHandler)
                        {
                            clientParams.FocusHandler = focusHandler;
                        }

                        break;

                    case CefHandlerKey.KeyboardHandler:
                        if (instance is CefKeyboardHandler keyboardHandler)
                        {
                            clientParams.KeyboardHandler = keyboardHandler;
                        }

                        break;

                    case CefHandlerKey.JsDialogHandler:
                        if (instance is CefJSDialogHandler jsDialogHandler)
                        {
                            clientParams.JsDialogHandler = jsDialogHandler;
                        }

                        break;

                    case CefHandlerKey.DialogHandler:
                        if (instance is CefDialogHandler dialogHandler)
                        {
                            clientParams.DialogHandler = dialogHandler;
                        }

                        break;

                    case CefHandlerKey.DragHandler:
                        if (instance is CefDragHandler dragHandler)
                        {
                            clientParams.DragHandler = dragHandler;
                        }

                        break;

                    case CefHandlerKey.DownloadHandler:
                        if (instance is CefDownloadHandler downloadHandler)
                        {
                            clientParams.DownloadHandler = downloadHandler;
                        }

                        break;

                    case CefHandlerKey.FindHandler:
                        if (instance is CefFindHandler handler)
                        {
                            clientParams.FindHandler = handler;
                        }

                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(clientParams);
        }
예제 #7
0
        public static CefGlueClientParams Create(CefGlueBrowser browser)
        {
            CefGlueClientParams clientParams = new CefGlueClientParams();

            clientParams.Browser = browser;

            try
            {
                foreach (var enumKey in CefHandlerDummyTypes.GetAllHandlerKeys())
                {
                    object instance = null;

                    Type   service = CefHandlerDummyTypes.GetHandlerType(enumKey);
                    string keyStr  = enumKey.EnumToString();
                    try
                    {
                        if (IoC.IsRegistered(service, keyStr))
                        {
                            instance = IoC.GetInstance(service, keyStr);
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error(exception);
                    }

                    switch (enumKey)
                    {
                    case CefHandlerKey.LifeSpanHandler:
                        if ((instance != null) && (instance is CefLifeSpanHandler))
                        {
                            clientParams.LifeSpanHandler = (CefLifeSpanHandler)instance;
                        }
                        else
                        {
                            clientParams.LifeSpanHandler = new CefGlueLifeSpanHandler();
                        }
                        break;

                    case CefHandlerKey.LoadHandler:
                        if ((instance != null) && (instance is CefLoadHandler))
                        {
                            clientParams.LoadHandler = (CefLoadHandler)instance;
                        }
                        else
                        {
                            clientParams.LoadHandler = new CefGlueLoadHandler();
                        }
                        break;

                    case CefHandlerKey.RequestHandler:
                        if ((instance != null) && (instance is CefRequestHandler))
                        {
                            clientParams.RequestHandler = (CefRequestHandler)instance;
                        }
                        else
                        {
                            clientParams.RequestHandler = new CefGlueRequestHandler();
                        }
                        break;

                    case CefHandlerKey.DisplayHandler:
                        if ((instance != null) && (instance is CefDisplayHandler))
                        {
                            clientParams.DisplayHandler = (CefDisplayHandler)instance;
                        }
                        else
                        {
                            clientParams.DisplayHandler = new CefGlueDisplayHandler();
                        }
                        break;

                    case CefHandlerKey.ContextMenuHandler:
                        if ((instance != null) && (instance is CefContextMenuHandler))
                        {
                            clientParams.ContextMenuHandler = (CefContextMenuHandler)instance;
                        }
                        else
                        {
                            clientParams.ContextMenuHandler = new CefGlueContextMenuHandler();
                        }
                        break;

                    case CefHandlerKey.FocusHandler:
                        if ((instance != null) && (instance is CefFocusHandler))
                        {
                            clientParams.FocusHandler = (CefFocusHandler)instance;
                        }
                        break;

                    case CefHandlerKey.KeyboardHandler:
                        if ((instance != null) && (instance is CefKeyboardHandler))
                        {
                            clientParams.KeyboardHandler = (CefKeyboardHandler)instance;
                        }
                        break;

                    case CefHandlerKey.JSDialogHandler:
                        if ((instance != null) && (instance is CefJSDialogHandler))
                        {
                            clientParams.JSDialogHandler = (CefJSDialogHandler)instance;
                        }
                        break;

                    case CefHandlerKey.DialogHandler:
                        if ((instance != null) && (instance is CefDialogHandler))
                        {
                            clientParams.DialogHandler = (CefDialogHandler)instance;
                        }
                        break;

                    case CefHandlerKey.DragHandler:
                        if ((instance != null) && (instance is CefDragHandler))
                        {
                            clientParams.DragHandler = (CefDragHandler)instance;
                        }
                        break;

                    case CefHandlerKey.GeolocationHandler:
                        if ((instance != null) && (instance is CefGeolocationHandler))
                        {
                            clientParams.GeolocationHandler = (CefGeolocationHandler)instance;
                        }
                        break;

                    case CefHandlerKey.DownloadHandler:
                        if ((instance != null) && (instance is CefDownloadHandler))
                        {
                            clientParams.DownloadHandler = (CefDownloadHandler)instance;
                        }
                        break;

                    case CefHandlerKey.FindHandler:
                        if ((instance != null) && (instance is CefFindHandler))
                        {
                            clientParams.FindHandler = (CefFindHandler)instance;
                        }
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(clientParams);
        }