Factored out the window observer bit, in preparation for bigger e10s changes

The code will get a little more complex because of Electrolysis
(multi-process Firefox), so I'm breaking down the script into modules.
It was already necessary, anyway.

This is the first step: factoring out the window observer code. The
next step is to factor out the page load handler and move it to the
content window, so that it works with e10s using CPOWs.