Bloom.Browser.HandleLinkClick C# (CSharp) Method

HandleLinkClick() public method

When you receive a OnBrowserClick and have determined that nothing was clicked on that the c# needs to pay attention to, pass it on to this method. It will either let the browser handle it normally, or redirect it to the operating system so that it can open the file or external website itself.
public HandleLinkClick ( GeckoAnchorElement anchor, DomEventArgs eventArgs, string workingDirectoryForFileLinks ) : void
anchor GeckoAnchorElement
eventArgs DomEventArgs
workingDirectoryForFileLinks string
return void
        public void HandleLinkClick(GeckoAnchorElement anchor, DomEventArgs eventArgs, string workingDirectoryForFileLinks)
        {
            Debug.Assert(!InvokeRequired);
            if (anchor.Href.ToLowerInvariant().StartsWith("http")) //will cover https also
            {
                Process.Start(anchor.Href);
                eventArgs.Handled = true;
                return;
            }
            if (anchor.Href.ToLowerInvariant().StartsWith("file"))
            //links to files are handled externally if we can tell they aren't html/javascript related
            {
                // TODO: at this point spaces in the file name will cause the link to fail.
                // That seems to be a problem in the DomEventArgs.Target.CastToGeckoElement() method.
                var href = anchor.Href;

                var path = href.Replace("file:///", "");

                if (new List<string>(new[] { ".pdf", ".odt", ".doc", ".docx", ".txt" }).Contains(Path.GetExtension(path).ToLowerInvariant()))
                {
                    eventArgs.Handled = true;
                    Process.Start(new ProcessStartInfo()
                    {
                        FileName = path,
                        WorkingDirectory = workingDirectoryForFileLinks
                    });
                    return;
                }
                eventArgs.Handled = false; //let gecko handle it
                return;
            }
            else if (anchor.Href.ToLowerInvariant().StartsWith("mailto"))
            {
                eventArgs.Handled = true;
                Process.Start(anchor.Href); //let the system open the email program
                Debug.WriteLine("Opening email program " + anchor.Href);
            }
            else
            {
                ErrorReport.NotifyUserOfProblem("Bloom did not understand this link: " + anchor.Href);
                eventArgs.Handled = true;
            }
        }