Factoring out getTrustedHosts()
Adding event to let plugins add new JS global variables.
Merge remote-tracking branch 'origin/master'