private void LifeSpanHandler_PopupRequested(PopupRequestedEventArgs args) { var validCurrentUri = Uri.TryCreate(control.Address, UriKind.Absolute, out var currentUri); var validNewUri = Uri.TryCreate(args.Url, UriKind.Absolute, out var newUri); var sameHost = validCurrentUri && validNewUri && string.Equals(currentUri.Host, newUri.Host, StringComparison.OrdinalIgnoreCase); switch (settings.PopupPolicy) { case PopupPolicy.Allow: case PopupPolicy.AllowSameHost when sameHost: logger.Debug($"Forwarding request to open new window{(WindowSettings.UrlPolicy.CanLog() ? $" for '{args.Url}'" : "")}..."); PopupRequested?.Invoke(args); break; case PopupPolicy.AllowSameWindow: case PopupPolicy.AllowSameHostAndWindow when sameHost: logger.Info($"Discarding request to open new window and loading{(WindowSettings.UrlPolicy.CanLog() ? $" '{args.Url}'" : "")} directly..."); control.NavigateTo(args.Url); break; case PopupPolicy.AllowSameHost when !sameHost: case PopupPolicy.AllowSameHostAndWindow when !sameHost: logger.Info($"Blocked request to open new window{(WindowSettings.UrlPolicy.CanLog() ? $" for '{args.Url}'" : "")} as it targets a different host."); break; default: logger.Info($"Blocked request to open new window{(WindowSettings.UrlPolicy.CanLog() ? $" for '{args.Url}'" : "")}."); break; } }
public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) { var args = new PopupRequestedEventArgs { Url = targetUrl }; newBrowser = default(IWebBrowser); PopupRequested?.Invoke(args); return(true); }
private void LifeSpanHandler_PopupRequested(PopupRequestedEventArgs args) { if (settings.AllowPopups) { logger.Debug($"Forwarding request to open new window for '{args.Url}'..."); PopupRequested?.Invoke(args); } else { logger.Debug($"Blocked attempt to open new window for '{args.Url}'."); } }
private void Control_PopupRequested(PopupRequestedEventArgs args) { PopupRequested?.Invoke(args); }