/// <summary> /// Initializes a new instance of the <see cref="DefaultRequestHandler"/> class. /// </summary> public DefaultRequestHandler(IChromelyConfiguration config, IChromelyCommandTaskRunner commandTaskRunner, IChromelyWindow window, CefResourceRequestHandler resourceRequestHandler = null) { _config = config; _commandTaskRunner = commandTaskRunner; _browser = window as ChromiumBrowser; _resourceRequestHandler = resourceRequestHandler; }
public static IChromelyNativeHost GetNativeHost(IChromelyConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } switch (config.Platform) { case ChromelyPlatform.MacOSX: return(new MacCocoaHost()); case ChromelyPlatform.Linux: return(new LinuxGtk3Host()); case ChromelyPlatform.Windows: if (config.WindowOptions != null && config.WindowOptions.WindowFrameless) { return(new FramelessWinAPIHost()); } return(new WinAPIHost()); default: return(new WinAPIHost()); } }
public Window(IChromelyNativeHost nativeHost, IChromelyConfiguration config, ChromelyHandlersResolver handlersResolver) : base(nativeHost, config, handlersResolver) { Created += OnBrowserCreated; }
/// <summary> /// Initializes a new instance of the <see cref="DemoController"/> class. /// </summary> public DemoController(IChromelyConfiguration config) { _config = config; RegisterGetRequest("/democontroller/movies", GetMovies); RegisterPostRequest("/democontroller/movies", SaveMovies); }
private AppBuilder() { _config = null; _chromelyUseConfigType = null; _chromelyUseWindowType = null; _stepCompleted = 1; }
public DefaultResourceSchemeHandler(IChromelyConfiguration config, IChromelyErrorHandler chromelyErrorHandler) { _config = config; _chromelyErrorHandler = chromelyErrorHandler; _chromelyResource = new ChromelyResource(); _fileInfo = null; }
public void CreateWindow(IChromelyConfiguration config) { _config = config; ChromelyParam configParam = InitParam(RunCallback, ShutdownCallback, InitCallback, CreateCallback, MovingCallback, ResizeCallback, QuitCallback); configParam.centerscreen = _config.WindowState == WindowState.Normal && _config.WindowCenterScreen ? 1 : 0; configParam.frameless = _config.WindowFrameless ? 1 : 0; configParam.fullscreen = _config.WindowState == Core.Host.WindowState.Fullscreen ? 1 : 0; configParam.noresize = _config.WindowNoResize ? 1 : 0; configParam.nominbutton = _config.WindowNoMinMaxBoxes ? 1 : 0; configParam.nomaxbutton = _config.WindowNoMinMaxBoxes ? 1 : 0; configParam.title = _config.WindowTitle; configParam.x = _config.WindowLeft; configParam.y = _config.WindowTop; configParam.width = _config.WindowWidth; configParam.height = _config.WindowHeight; createwindow(ref configParam); }
/// <inheritdoc/> public WindowController(IChromelyWindow window, IChromelyNativeHost nativeHost, IChromelyConfiguration config, IChromelyRouteProvider routeProvider, IChromelyRequestHandler requestHandler, IChromelyRequestSchemeProvider requestSchemeProvider, ChromelyHandlersResolver handlersResolver) : base(window, nativeHost, config, routeProvider, requestHandler, handlersResolver) { // WindowController.NativeWindow _nativeHost.HostCreated += OnWindowCreated; _nativeHost.HostMoving += OnWindowMoving; _nativeHost.HostSizeChanged += OnWindowSizeChanged; _nativeHost.HostClose += OnWindowClose; _requestSchemeProvider = requestSchemeProvider; // Set CefBinariesDownloader var objList = _handlersResolver?.Invoke(typeof(ICefBinariesDownloader)); var tempLoader = objList?.FirstOrDefault() as ICefBinariesDownloader; if (tempLoader is not null) { _binariesDownloader = tempLoader; } }
/// <summary>Gets integer value from custom settings dictionary.</summary> /// <param name="config">The config object - instance of the <see cref="IChromelyConfiguration" /> class.</param> /// <param name="key">The key.</param> /// <param name="defaultValue">The default value.</param> /// <returns>The <see cref="int" /> value.</returns> public static int GetIntegerValue(this IChromelyConfiguration config, string key, int defaultValue = 0) { try { if (config?.CustomSettings != null && config.CustomSettings.ContainsKey(key)) { var value = config.CustomSettings[key]; if (value == null) { return(defaultValue); } if (int.TryParse(value.ToString(), out var result)) { return(result); } } return(defaultValue); } catch (Exception exception) { Logger.Instance.Log.LogError(exception, exception.Message); } return(defaultValue); }
public CefBrowserApp(IChromelyConfiguration config, IChromelyRequestSchemeProvider requestSchemeProvider) { _config = config; _requestSchemeProvider = requestSchemeProvider; _renderProcessHandler = new DefaultRenderProcessHandler(_config); _browserProcessHandler = new DefaultBrowserProcessHandler(_config); }
public CefGlueApp(IChromelyContainer container, IChromelyConfiguration config) { _container = container; _config = config; _renderProcessHandler = RenderProcessHandler; _browserProcessHandler = BrowserProcessHandler; }
protected HostBase(IChromelyContainer container, IChromelyConfiguration config, IChromelyRequestTaskRunner requestTaskRunner, IChromelyCommandTaskRunner commandTaskRunner) { _container = container; _config = config; _requestTaskRunner = requestTaskRunner; _commandTaskRunner = commandTaskRunner; }
public static void SetMacOSAppName(IChromelyConfiguration config) { if (config.Platform == ChromelyPlatform.MacOSX) { Task.Run(() => { try { var appName = config.AppName; if (string.IsNullOrWhiteSpace(appName)) { appName = Assembly.GetEntryAssembly()?.GetName().Name; } var appDirectory = AppDomain.CurrentDomain.BaseDirectory; var pInfoFile = Path.Combine(appDirectory, MacOSConfigFile); if (File.Exists(pInfoFile)) { var pInfoFileText = File.ReadAllText(pInfoFile); pInfoFileText = pInfoFileText.Replace(MacOSDefaultAppName, appName); File.WriteAllText(MacOSConfigFile, pInfoFileText); } } catch { } }); } }
protected void InitConfiguration(IChromelyConfiguration config) { if (config == null) { throw new Exception("Configuration cannot be null."); } if (config.UrlSchemes == null) { config.UrlSchemes = new List <UrlScheme>(); } if (config.ControllerAssemblies == null) { config.ControllerAssemblies = new List <ControllerAssemblyInfo>(); } if (config.CommandLineArgs == null) { config.CommandLineArgs = new Dictionary <string, string>(); } if (config.CommandLineOptions == null) { config.CommandLineOptions = new List <string>(); } if (config.CustomSettings == null) { config.CustomSettings = new Dictionary <string, string>(); } if (config.WindowOptions == null) { config.WindowOptions = new Configuration.WindowOptions(); } }
public static void LoadNativeHostFile(IChromelyConfiguration config) { if (config.Platform != ChromelyPlatform.MacOSX) { return; } var appDirectory = AppDomain.CurrentDomain.BaseDirectory; string fullPathNativeDll = Path.Combine(appDirectory, MacOSNativeDllFile); if (File.Exists(fullPathNativeDll)) { return; } Task.Run(() => { string resourcePath = $"Chromely.Native.MacCocoa.{MacOSNativeDllFile}"; using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath)) { using (var file = new FileStream(fullPathNativeDll, FileMode.Create, FileAccess.Write)) { resource?.CopyTo(file); } } }); }
/// <summary> /// Gets string value from custom settings dictionary. /// </summary> /// <param name="config"> /// The config object - instance of the <see cref="IChromelyConfiguration"/> class. /// </param> /// <param name="key"> /// The key. /// </param> /// <param name="defaultValue"> /// The default value. /// </param> /// <returns> /// The <see cref="string"/> value. /// </returns> public static string GetStringValue(this IChromelyConfiguration config, string key, string defaultValue = "") { try { if (config?.CustomSettings != null && config.CustomSettings.ContainsKey(key)) { var value = config.CustomSettings[key]; if (value == null) { return(defaultValue); } if (value is string strValue) { return(strValue); } return(value.ToString()); } return(defaultValue); } catch (Exception exception) { Logger.Instance.Log.Error(exception); } return(defaultValue); }
public DemoWindow(IChromelyNativeHost nativeHost, IChromelyConfiguration config, ChromelyHandlersResolver handlersResolver) : base(nativeHost, config, handlersResolver) { #region Events FrameLoadStart += DemoWindow_FrameLoadStart; FrameLoadEnd += DemoWindow_FrameLoadEnd; LoadingStateChanged += DemoWindow_LoadingStateChanged; JavascriptMessageReceived += DemoWindow_JavascriptMessageReceived; ConsoleMessage += DemoWindow_ConsoleMessage; AddressChanged += DemoWindow_AddressChanged; #endregion Events #region Handlers // Optionally set custom handlers here or register them in DI // If they have dependencies it is better to use the DI. // LifeSpanHandler = new CustomLifeSpanHandler(); // LoadHandler = new CustomLoadHandler(); // RequestHandler = new CustomRequestHandler(); // DisplayHandler = new CustomDisplayHandler(); // MenuHandler = new CustomMenuHandler(); // KeyboardHandler = new CustomKeyboardHandler(); // JsDialogHandler = new JsDialogHandler(); // DialogHandler = new CustomDialogHandler(); // DragHandler = new CustomDragHandler(); // DownloadHandler = new CustomDownloadHandler(); // FindHandler = new CustomFindHandler(); // ResourceRequestHandlerFactory = new CustomResourceRequestHandlerFactory(); // RenderProcessMessageHandler = new CustomRenderProcessMessageHandler(); #endregion }
/// <summary> /// The warn user on load. /// </summary> private static void DownloadAndNotifyUser(ICefDownloader cefBinariesDownloader, IChromelyConfiguration config) { var downloadNotification = cefBinariesDownloader.Notification; try { var stopwatch = new Stopwatch(); stopwatch.Start(); downloadNotification.OnDownloadStarted(); cefBinariesDownloader.Download(config); stopwatch.Stop(); downloadNotification.OnDownloadCompleted(stopwatch.Elapsed); Thread.Sleep(TimeSpan.FromSeconds(2)); } catch (Exception ex) { Logger.Instance.Log.LogError(ex); downloadNotification.OnDownloadFailed(ex); Environment.Exit(0); } }
/// <summary> /// Gets boolean value from custom settings dictionary. /// </summary> /// <param name="config"> /// The config object - instance of the <see cref="ChromelyConfiguration"/> class. /// </param> /// <param name="key"> /// The key. /// </param> /// <param name="defaultValue"> /// The default value. /// </param> /// <returns> /// The <see cref="bool"/> value. /// </returns> public static bool GetBooleanValue(this IChromelyConfiguration config, string key, bool defaultValue = false) { try { if (config?.CustomSettings != null && config.CustomSettings.ContainsKey(key)) { var value = config.CustomSettings[key]; if (value == null) { return(defaultValue); } if (bool.TryParse(value.ToString(), out var result)) { return(result); } } return(defaultValue); } catch (Exception exception) { Logger.Instance.Log.Error(exception); } return(defaultValue); }
public ChromiumBrowser(IChromelyNativeHost nativeHost, IChromelyConfiguration config, ChromelyHandlersResolver handlersResolver) { Browser = null; NativeHost = nativeHost; _config = config; _handlersResolver = handlersResolver; }
private AppBuilder() { _config = null; _chromelyUseConfigType = null; _chromelyUseWindowType = null; _chromelyUseErrorHandlerType = null; _stepCompleted = -1; }
public CefBrowserApp(IChromelyConfiguration config, IChromelyRequestSchemeProvider requestSchemeProvider, ChromelyHandlersResolver handlersResolver) { _config = config; _requestSchemeProvider = requestSchemeProvider; _handlersResolver = handlersResolver; _renderProcessHandler = RenderProcessHandler; _browserProcessHandler = BrowserProcessHandler; }
/// <summary> /// Initializes a new instance of the <see cref="DemoController"/> class. /// </summary> public DemoController(IChromelyConfiguration config, IChromelySerializerUtil serializerUtil) { _config = config; _serializerUtil = serializerUtil; RegisterRequest("/democontroller/movies/get", GetMovies); RegisterRequest("/democontroller/movies/post", SaveMovies); }
public DefaultAssemblyResourceSchemeHandler(IChromelyConfiguration config, IChromelyErrorHandler chromelyErrorHandler) { _config = config; _chromelyErrorHandler = chromelyErrorHandler; _statusCode = ResourceConstants.StatusOK; _statusText = ResourceConstants.StatusOKText; _mime = "text/plain"; }
public DefaultAssemblyResourceSchemeHandler(IChromelyConfiguration config) { _config = config; var status = ResourceFileStatus.Ok.GetStatus(); _status = status.Item1; _statusText = status.Item2; _mime = "text/plain"; }
public Window(IChromelyNativeHost nativeHost, IChromelyConfiguration config, ChromelyHandlersResolver handlersResolver) : base(nativeHost, config) { _handlersResolver = handlersResolver; IsBrowserInitializedChanged += BrowserInitializedChanged; }
public DefaultRequestHandler(IChromelyConfiguration config, IChromelyRequestSchemeHandlerProvider requestSchemeHandlerProvider, IResourceRequestHandler resourceRequestHandler, IChromelyCommandTaskRunner commandTaskRunner) { _config = config; _requestSchemeHandlerProvider = requestSchemeHandlerProvider; _resourceRequestHandler = resourceRequestHandler; _commandTaskRunner = commandTaskRunner; }
/// <summary> /// Creates the CefGlue browser. /// </summary> /// <param name="owner"></param> /// <param name="container"></param> /// <param name="config"></param> /// <param name="commandTaskRunner"></param> /// <param name="browserMessageRouter"></param> /// <param name="settings"></param> public CefGlueBrowser(object owner, IChromelyContainer container, IChromelyConfiguration config, IChromelyCommandTaskRunner commandTaskRunner, CefMessageRouterBrowserSide browserMessageRouter, CefBrowserSettings settings) { Owner = owner; _container = container; _config = config; _commandTaskRunner = commandTaskRunner; _browserMessageRouter = browserMessageRouter; _settings = settings; StartUrl = config.StartUrl; }
public DefaultLifeSpanHandler(IChromelyConfiguration config, IChromelyRequestHandler requestHandler, IChromelyRouteProvider routeProvider, IChromelyWindow window) { _config = config; _requestHandler = requestHandler; _routeProvider = routeProvider; _browser = window as ChromiumBrowser; }
public ChromelyMacHost(IChromelyConfiguration config) { _config = config; _options = _config?.WindowOptions ?? new WindowOptions(); _appHandle = IntPtr.Zero; _poolHandle = IntPtr.Zero; _windowHandle = IntPtr.Zero; _viewHandle = IntPtr.Zero; _isInitialized = false; }