Detect local (file:///) HTML and XML files

Chrome doesn't include a content-type for local HTML and XML files, this adds support for them to be rendered as pages instead of code.

It's a bit hard to follow, but the second part will only be run if it's a `file:///` URL.

I tried to keep the code formatting consistent so this can be merged directly.