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; } }
/// <summary> /// Launch the first application in the host process /// </summary> /// <param name="package"></param> /// <param name="metadata"></param> public void RunApplication(ParagonCommandLineParser cmdLine, IApplicationPackage package, ApplicationMetadata metadata) { if (IsInitialized) { throw new Exception("Application manger is already initialized"); } var manifest = package.Manifest; // Initialize the following from the first application manifest ProcessGroup = manifest.ProcessGroup ?? string.Empty; CacheFolder = Path.Combine(_paragonFolder, string.IsNullOrEmpty(manifest.ProcessGroup) ? manifest.Id : manifest.ProcessGroup); Environment = metadata.Environment; DisableSpellChecking = manifest.DisableSpellChecking; // set browser language from manifest - default is en-US // "automatic" will set browser language to os culture info if (!string.IsNullOrEmpty(manifest.BrowserLanguage)) { if (string.Equals(manifest.BrowserLanguage, "Automatic", StringComparison.InvariantCultureIgnoreCase)) { BrowserLanguage = CultureInfo.CurrentCulture.Name; } else { //verify specified culture CultureInfo cultureInfo = null; try { cultureInfo = new CultureInfo(manifest.BrowserLanguage); } catch (Exception) { Logger.Error("Manifest browser language is not valid. Using default browser language en-US"); } BrowserLanguage = (cultureInfo != null) ? (cultureInfo.Name) : (BrowserLanguage); } Logger.Info(string.Format("Browser language being used is {0}", BrowserLanguage)); } string auth_server_whitelist = null; string auth_delegate_whitelist = null; if (cmdLine != null) { cmdLine.GetValue("auth-server-whitelist", out auth_server_whitelist); Logger.Info(string.Format("auth-server-whitelist [{0}]", auth_server_whitelist)); cmdLine.GetValue("auth-delegate-whitelist", out auth_delegate_whitelist); Logger.Info(string.Format("auth-delegate-whitelist [{0}]", auth_delegate_whitelist)); } // Initialize CEF using (AutoStopwatch.TimeIt("CEF initialization")) { ParagonRuntime.Initialize( CacheFolder, null, BrowserLanguage, auth_server_whitelist, auth_delegate_whitelist, DisableSpellChecking, Environment == ApplicationEnvironment.Development); } RunApplicationInternal(cmdLine, package, metadata); }