Add initial support for start/stop tracing using an extension

To start/stop tracing from the UI, an extension will be used. In this CL
the base code for make the extension work has been added under
"src/chrome_extension". Now "RecordController" is the responsible to
start/stop tracing based on the value of "recordingInProgress" inside
the state. The communications between the controller and the extension
are proxied through a MessageChannel by the front-end, because the
controller is running on a worker and doesn't have access to the API
to send messages to the extension.

In the record page are now displayed 2 additional buttons on the
bottom to start and stop a trace. They are visible only if the
extension is installed. If it isn't installed, this CL should not make
change to the previous UI.

Bug: 138433107
Change-Id: I20c3c6da7cc5f554dad2ee11c4e6cb9b5bc686d9
diff --git a/ui/src/controller/app_controller.ts b/ui/src/controller/app_controller.ts
index cf8e6f0..8e6e3c9 100644
--- a/ui/src/controller/app_controller.ts
+++ b/ui/src/controller/app_controller.ts
@@ -23,8 +23,14 @@
 // the other controllers (e.g., track and query controllers) according to the
 // global state.
 export class AppController extends Controller<'main'> {
-  constructor() {
+  // extensionPort is needed for the RecordController to communicate with the
+  // extension through the frontend. This is because the controller is running
+  // on a worker, and isn't able to directly send messages to the extension.
+  private extensionPort: MessagePort;
+
+  constructor(extensionPort: MessagePort) {
     super('main');
+    this.extensionPort = extensionPort;
   }
 
   // This is the root method that is called every time the controller tree is
@@ -35,7 +41,10 @@
   run() {
     const childControllers: ControllerInitializerAny[] = [
       Child('permalink', PermalinkController, {}),
-      Child('record', RecordController, {app: globals}),
+      Child(
+          'record',
+          RecordController,
+          {app: globals, extensionPort: this.extensionPort}),
     ];
     for (const engineCfg of Object.values(globals.state.engines)) {
       childControllers.push(Child(engineCfg.id, TraceController, engineCfg.id));