hypothesis/h — pull request #1626 by aron (2014-11-03 11:28:49+00:00)
Title: Show highlights by default in the Chrome Extension

This pull request aims to reduce the confusion when a page is loaded with the Chrome extension enabled and no highlights are shown. Now we have an additional `showHighlights` option that can be passed to the Host constructor to enable the visible highlights mode by default.

This is passed into the Chrome Extension using a new *config.js* file that is injected into the page via a script tag. We need to use a script tag here because otherwise the bootstrap script will not pick it up.

Implementing this feature has highlighted a couple of things we may wish to look into in future.

1) Our Chrome Extension currently runs in a mix of contexts. The inject script and subsequent callback that sets `window.annotator = true` runs in the extension context and so window.annotator is not visible to the page. But the destroy script is injected via a script tag and so affects both. We ideally need a way of building the extension so that it is initialised independently from any hypothesis code in the page, especially as we are now overwriting any hypothesisConfig variables that may exist already.
2) We need a better way of configuring the application state. Originally I had looked at adding a configuration method to the host and then calling it in the services file when the host was initialised. But this doesn't guarantee the order in which the panels are connected so if two guests connect then the host, the two guests would have the incorrect settings unless the sidebar rebroadcast the settings once the host was configured. Instead I just left this to the Host to update the configuration manually. This has the benefit of broadcasting out to guests and updating the sidebar state without having to add any extra config functions.

This builds on top of #1622