Update TTS Engine extension to use an event page.

This CL updates the TTS Engine extension to:

1. Use an event page, allowing ChromeOS to tear it down when it is
   not actively in-use. Chrome will also avoid loading the extension
   at startup, until it is actually used, which allows the TTS
   controller to query the extension's manifest for the set of
   supported voices without causing the event page to be loaded.
   Chrome will only (re-)load the extension to dispatch onSpeak,
   or system-upgrade, events to it.

2. Tear down the Native Client subcomponent when idle, rather than
   just disconnecting the audio output stream. Active NaCl plugins
   cause the event page to stay in-use, effectively creating a
   reference-cycle and preventing Chrome tearing them down when
   idle.

This can save as much as 70MB of memory usage in long-running
sessions, and helps avoid the TTS components running for users who
aren't actually using TTS.

BUG=chromium:616636
TEST=Open Task Manager. Load a web-site which queries TTS capabilities, e.g. https://www.guardian.co.uk. Observe that TTS extension does not load, or loads but then unloads again within a minute or so.

Change-Id: I6d2d6d2f969ed2ad61fa7008b8b8e41093418f37
Reviewed-on: https://chromium-review.googlesource.com/447000
Commit-Ready: James Weatherall <wez@chromium.org>
Tested-by: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: David Tseng <dtseng@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
4 files changed