/// <summary> /// The on before browse. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="request"> /// The request. /// </param> /// <param name="userGesture"> /// The user gesture. /// </param> /// <param name="isRedirect"> /// The is redirect. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect) { var isUrlExternal = UrlSchemeProvider.IsUrlRegisteredExternal(request.Url); if (isUrlExternal) { // https://brockallen.com/2016/09/24/process-start-for-urls-on-net-core/ try { Process.Start(request.Url); } catch { try { // hack because of this: https://github.com/dotnet/corefx/issues/10361 if (CefRuntime.Platform == CefRuntimePlatform.Windows) { var url = request.Url.Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); } else if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Process.Start("xdg-open", request.Url); } else if (CefRuntime.Platform == CefRuntimePlatform.MacOSX) { Process.Start("open", request.Url); } } catch (Exception exception) { Log.Error(exception); } } return(true); } var isUrlCommand = UrlSchemeProvider.IsUrlRegisteredCommand(request.Url); if (isUrlCommand) { CommandTaskRunner.RunAsync(request.Url); return(true); } return(false); }
/// <summary> /// The on before popup. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="targetUrl"> /// The target url. /// </param> /// <param name="targetFrameName"> /// The target frame name. /// </param> /// <param name="targetDisposition"> /// The target disposition. /// </param> /// <param name="userGesture"> /// The user gesture. /// </param> /// <param name="popupFeatures"> /// The popup features. /// </param> /// <param name="windowInfo"> /// The window info. /// </param> /// <param name="client"> /// The client. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <param name="noJavascriptAccess"> /// The no javascript access. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { var isUrlExternal = UrlSchemeProvider.IsUrlRegisteredExternal(targetUrl); if (isUrlExternal) { RegisteredExternalUrl.Launch(targetUrl); } var isUrlCommand = UrlSchemeProvider.IsUrlRegisteredCommand(targetUrl); if (isUrlCommand) { CommandTaskRunner.RunAsync(targetUrl); } return(true); }
/// <summary> /// The on before browse. /// </summary> /// <param name="browserControl"> /// The browser control. /// </param> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="request"> /// The request. /// </param> /// <param name="userGesture"> /// The user Gesture. /// </param> /// <param name="isRedirect"> /// The is redirect. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) { bool isUrlExternal = UrlSchemeProvider.IsUrlRegisteredExternal(request.Url); if (isUrlExternal) { System.Diagnostics.Process.Start(request.Url); return(true); } var isUrlCommand = UrlSchemeProvider.IsUrlRegisteredCommand(request.Url); if (isUrlCommand) { CommandTaskRunner.RunAsync(request.Url); return(true); } return(false); }
/// <summary> /// The on before popup. /// </summary> /// <param name="browserControl"> /// The browser control. /// </param> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="targetUrl"> /// The target url. /// </param> /// <param name="targetFrameName"> /// The target frame name. /// </param> /// <param name="targetDisposition"> /// The target disposition. /// </param> /// <param name="userGesture"> /// The user gesture. /// </param> /// <param name="popupFeatures"> /// The popup features. /// </param> /// <param name="windowInfo"> /// The window info. /// </param> /// <param name="browserSettings"> /// The browser settings. /// </param> /// <param name="noJavascriptAccess"> /// The no javascript access. /// </param> /// <param name="newBrowser"> /// The new browser. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) { newBrowser = null; var isUrlExternal = UrlSchemeProvider.IsUrlRegisteredExternal(targetUrl); if (isUrlExternal) { System.Diagnostics.Process.Start(targetUrl); } var isUrlCommand = UrlSchemeProvider.IsUrlRegisteredCommand(targetUrl); if (isUrlCommand) { CommandTaskRunner.RunAsync(targetUrl); } return(true); }