contents.js wrapper for contents service

This is PR #6671, rebased because it's a blocker for the text editor components, and @fperez asked me to make that high priority. So far, I've just rebased, I intend to test it and fix things I see.
promises are useful when you have multiple preconditions for an action, (e.g. make REST call A after REST calls B and C have responses), but apart from that they are pretty much equivalent to callbacks.  So I would opt for sticking with callbacks, it's simpler.