mozilla/r2d2b2g — pull request #592 by ochameau (2013-06-10 18:21:52+00:00)
Title: Introduce devtool toolbox per app.

So here is the work I was mentioning in PR #567 https://github.com/mozilla/r2d2b2g/pull/567#issuecomment-19115271

This is a more substantial patch, but with a lot more value.
It introduces a `connect` button next to each app that is displayed/hidden whenever the app is opened/closed. Once you click on this button, a remote devtool toolbox is being displayed as a regular web one, in the same window as a "bottom bar".
Then, if you close the simulation or close the app the toolbox is automatically closed.
If you click on another app `connect` button, a new one connected to the related app replace the eventual current toolbox.

In order to do that, instead of hacking `dbg-browser-actor.js` I decided to add new requests in `dbg-webapps-actor.js` in order to stop hacking around tabs and finally provide access to apps through dedicated `apps` keywords (So I copy pasted a piece of dbg-browser-actor, mainly `AppActor`)
Also, I tried to come up with modifications that would be easily upstreamed to firefox codebase. Moving apps stuff out of `listTabs` request is particularely important regarding firefox as we will most likely not always care about apps, so that building apps actors on each remote connection startup would be in most cases unecessary (listTabs is requested on each connection startup).

So, the webapps actors gained 3 methods:
* `listApps`, that returns a dictionary of all current opened app actors, indexed by they manifest URL.
* `watchApps`, order the webapps actor to start watching for app opening/closing. The actor is going to dispatch `webappsOpen`/`webappsClose` events.
* `unwatchApps, order the actor to stop listening for webapps opening/closing.

Finally, there is this challenging piece of code that aims to open the toolbox on all 4 current Firefox versions. It includes some hacks in order to make work the toolbox as a "bottom bar" and a bunch of conditional code in order to match every subtle differences around target and toolbox we have over firefox releases.