Beispiel #1
0
    /// <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);
        }
    }
Beispiel #2
0
    /// <inheritdoc/>
    public WindowController(IChromelyWindow window,
                            IChromelyNativeHost nativeHost,
                            IChromelyConfiguration config,
                            IChromelyRouteProvider routeProvider,
                            IChromelyRequestHandler requestHandler,
                            IChromelyRequestSchemeProvider requestSchemeProvider,
                            ICefDownloader binariesDownloader,
                            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;
        _binariesDownloader    = binariesDownloader;
    }
Beispiel #3
0
    /// <summary>Load Cef binaries</summary>
    /// <param name="cefBinariesDownloader">The cef binaries downloader.</param>
    /// <param name="config">Instance of <see cref="IChromelyConfiguration"/>.</param>
    public static void Load(ICefDownloader cefBinariesDownloader, IChromelyConfiguration config)
    {
        try
        {
            var platform = CefRuntime.Platform;
            var version  = CefRuntime.ChromeVersion;
            Logger.Instance.Log.LogInformation("Running {platform} chromium {version}", platform, version);

            try
            {
                CefRuntime.Load();
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.LogError(ex);

                if (config.CefDownloadOptions.AutoDownloadWhenMissing)
                {
                    if (config.CefDownloadOptions.DownloadSilently)
                    {
                        cefBinariesDownloader.Download(config);
                        CefLoader.SetMacOSAppName(config);
                    }
                    else
                    {
                        DownloadAndNotifyUser(cefBinariesDownloader, config);
                        CefLoader.SetMacOSAppName(config);
                        return;
                    }
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }
        catch (Exception ex)
        {
            Logger.Instance.Log.LogError(ex);
            Environment.Exit(0);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Clean up methods - example html notification generates temporary files.
    /// The files should be deleted here.
    /// </summary>
    /// <param name="cefBinariesDownloader">The cef binaries downloader.</param>
    public static void Cleanup(ICefDownloader cefBinariesDownloader)
    {
        var downloadNotification = cefBinariesDownloader.Notification;

        downloadNotification.Cleanup();
    }