Move InspectorFrontendHostAPI to externs

This was an interface that was already treated as an extern, but was not
explicitly in the externs.js file.

Bug: 1006759
Change-Id: I95301c059cc1213931498788cff553f955abb646
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829098
Commit-Queue: Tim Van der Lippe <[email protected]>
Reviewed-by: Yang Guo <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#700724}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c6c1bf57acb1c9ed7304674e7d5df51122cb22b1
diff --git a/front_end/Tests.js b/front_end/Tests.js
index 33dc3a0..f61b3bf 100644
--- a/front_end/Tests.js
+++ b/front_end/Tests.js
@@ -735,9 +735,9 @@
       this.assertEquals(0, event.data.modifiers);
       this.assertEquals('', event.data.code);
       InspectorFrontendHost.events.removeEventListener(
-          InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyDown, this);
+          Host.InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyDown, this);
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyUp, this);
+          Host.InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyUp, this);
       SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent(
           {type: 'keyUp', key: 'F8', code: 'F8', windowsVirtualKeyCode: 119, nativeVirtualKeyCode: 119});
     }
@@ -751,7 +751,7 @@
     }
     this.takeControl();
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyDown, this);
+        Host.InspectorFrontendHostAPI.Events.KeyEventUnhandled, onKeyEventUnhandledKeyDown, this);
     SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent(
         {type: 'rawKeyDown', key: 'F8', windowsVirtualKeyCode: 119, nativeVirtualKeyCode: 119});
   };
diff --git a/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js b/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js
index a6e75d1..6910f2a 100644
--- a/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js
+++ b/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js
@@ -43,7 +43,7 @@
     BindingsTestRunner.TestFileSystem._instances[this.fileSystemPath] = this;
 
     InspectorFrontendHost.events.dispatchEventToListeners(
-        InspectorFrontendHostAPI.Events.FileSystemAdded,
+        Host.InspectorFrontendHostAPI.Events.FileSystemAdded,
         {fileSystem: {fileSystemPath: this.fileSystemPath, fileSystemName: this.fileSystemPath, type}});
 
     Persistence.isolatedFileSystemManager.addEventListener(
@@ -64,7 +64,7 @@
   reportRemoved: function() {
     delete BindingsTestRunner.TestFileSystem._instances[this.fileSystemPath];
     InspectorFrontendHost.events.dispatchEventToListeners(
-        InspectorFrontendHostAPI.Events.FileSystemRemoved, this.fileSystemPath);
+        Host.InspectorFrontendHostAPI.Events.FileSystemRemoved, this.fileSystemPath);
   },
 
   addFile: function(path, content, lastModified) {
@@ -124,7 +124,7 @@
     child.parent = null;
 
     InspectorFrontendHost.events.dispatchEventToListeners(
-        InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
+        Host.InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
         {changed: [], added: [], removed: [fullPath]});
 
     success();
@@ -149,7 +149,7 @@
     const fullPath = this._fileSystem.fileSystemPath + child.fullPath;
 
     InspectorFrontendHost.events.dispatchEventToListeners(
-        InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
+        Host.InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
         {changed: [], added: [fullPath], removed: []});
 
     return child;
@@ -162,7 +162,7 @@
     const fullPath = this._fileSystem.fileSystemPath + this.fullPath;
 
     InspectorFrontendHost.events.dispatchEventToListeners(
-        InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
+        Host.InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved,
         {changed: [fullPath], added: [], removed: []});
   },
 
diff --git a/front_end/color_picker/ContrastDetails.js b/front_end/color_picker/ContrastDetails.js
index 18cd246..5cd8415 100644
--- a/front_end/color_picker/ContrastDetails.js
+++ b/front_end/color_picker/ContrastDetails.js
@@ -252,10 +252,10 @@
     InspectorFrontendHost.setEyeDropperActive(enabled);
     if (enabled) {
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._bgColorPickedBound);
+          Host.InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._bgColorPickedBound);
     } else {
       InspectorFrontendHost.events.removeEventListener(
-          InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._bgColorPickedBound);
+          Host.InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._bgColorPickedBound);
     }
   }
 
diff --git a/front_end/color_picker/Spectrum.js b/front_end/color_picker/Spectrum.js
index 098433e..65b8645 100644
--- a/front_end/color_picker/Spectrum.js
+++ b/front_end/color_picker/Spectrum.js
@@ -889,10 +889,10 @@
     InspectorFrontendHost.setEyeDropperActive(enabled);
     if (enabled) {
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._colorPickedBound);
+          Host.InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._colorPickedBound);
     } else {
       InspectorFrontendHost.events.removeEventListener(
-          InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._colorPickedBound);
+          Host.InspectorFrontendHostAPI.Events.EyeDropperPickedColor, this._colorPickedBound);
     }
   }
 
diff --git a/front_end/devices/DevicesView.js b/front_end/devices/DevicesView.js
index 3b8e480..59f72dd 100644
--- a/front_end/devices/DevicesView.js
+++ b/front_end/devices/DevicesView.js
@@ -44,13 +44,12 @@
     this._selectSidebarListItem(this._discoveryListItem, this._discoveryView);
 
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.DevicesUpdated, this._devicesUpdated, this);
+        Host.InspectorFrontendHostAPI.Events.DevicesUpdated, this._devicesUpdated, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
+        Host.InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged, this._devicesPortForwardingStatusChanged,
-        this);
-
+        Host.InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged,
+        this._devicesPortForwardingStatusChanged, this);
   }
 
   /**
diff --git a/front_end/extensions/ExtensionServer.js b/front_end/extensions/ExtensionServer.js
index 5953633..c1a2a09 100644
--- a/front_end/extensions/ExtensionServer.js
+++ b/front_end/extensions/ExtensionServer.js
@@ -83,7 +83,7 @@
     window.addEventListener('message', this._onWindowMessage.bind(this), false);  // Only for main window.
 
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.SetInspectedTabId, this._setInspectedTabId, this);
+        Host.InspectorFrontendHostAPI.Events.SetInspectedTabId, this._setInspectedTabId, this);
 
     this._initExtensions();
   }
diff --git a/front_end/externs.js b/front_end/externs.js
index 48017b8..eaaf2a7 100644
--- a/front_end/externs.js
+++ b/front_end/externs.js
@@ -1164,3 +1164,315 @@
  * @return {string}
  */
 Lighthouse.ReportGenerator.replaceStrings;
+
+/** @interface */
+class InspectorFrontendHostAPI {
+  /**
+   * @param {string=} type
+   */
+  addFileSystem(type) {
+  }
+
+  loadCompleted() {
+  }
+
+  /**
+   * @param {number} requestId
+   * @param {string} fileSystemPath
+   * @param {string} excludedFolders
+   */
+  indexPath(requestId, fileSystemPath, excludedFolders) {
+  }
+
+  /**
+   * Requests inspected page to be placed atop of the inspector frontend with specified bounds.
+   * @param {{x: number, y: number, width: number, height: number}} bounds
+   */
+  setInspectedPageBounds(bounds) {
+  }
+
+  /**
+   * @param {!Array<string>} certChain
+   */
+  showCertificateViewer(certChain) {
+  }
+
+  /**
+   * @param {string} shortcuts
+   */
+  setWhitelistedShortcuts(shortcuts) {
+  }
+
+  /**
+   * @param {boolean} active
+   */
+  setEyeDropperActive(active) {
+  }
+
+  inspectElementCompleted() {
+  }
+
+  /**
+   * @param {string} url
+   */
+  openInNewTab(url) {
+  }
+
+  /**
+   * @param {string} fileSystemPath
+   */
+  showItemInFolder(fileSystemPath) {
+  }
+
+  /**
+   * @param {string} fileSystemPath
+   */
+  removeFileSystem(fileSystemPath) {
+  }
+
+  requestFileSystems() {
+  }
+
+  /**
+   * @param {string} url
+   * @param {string} content
+   * @param {boolean} forceSaveAs
+   */
+  save(url, content, forceSaveAs) {
+  }
+
+  /**
+   * @param {string} url
+   * @param {string} content
+   */
+  append(url, content) {
+  }
+
+  /**
+   * @param {string} url
+   */
+  close(url) {
+  }
+
+  /**
+   * @param {number} requestId
+   * @param {string} fileSystemPath
+   * @param {string} query
+   */
+  searchInPath(requestId, fileSystemPath, query) {
+  }
+
+  /**
+   * @param {number} requestId
+   */
+  stopIndexing(requestId) {
+  }
+
+  bringToFront() {
+  }
+
+  closeWindow() {
+  }
+
+  copyText(text) {
+  }
+
+  /**
+   * @param {string} url
+   */
+  inspectedURLChanged(url) {
+  }
+
+  /**
+   * @param {string} fileSystemId
+   * @param {string} registeredName
+   * @return {?DOMFileSystem}
+   */
+  isolatedFileSystem(fileSystemId, registeredName) {
+  }
+
+  /**
+   * @param {string} url
+   * @param {string} headers
+   * @param {number} streamId
+   * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} callback
+   */
+  loadNetworkResource(url, headers, streamId, callback) {
+  }
+
+  /**
+   * @param {function(!Object<string, string>)} callback
+   */
+  getPreferences(callback) {
+  }
+
+  /**
+   * @param {string} name
+   * @param {string} value
+   */
+  setPreference(name, value) {
+  }
+
+  /**
+   * @param {string} name
+   */
+  removePreference(name) {
+  }
+
+  clearPreferences() {
+  }
+
+  /**
+   * @param {!FileSystem} fileSystem
+   */
+  upgradeDraggedFileSystemPermissions(fileSystem) {
+  }
+
+  /**
+   * @return {string}
+   */
+  platform() {
+  }
+
+  /**
+   * @param {string} actionName
+   * @param {number} actionCode
+   * @param {number} bucketSize
+   */
+  recordEnumeratedHistogram(actionName, actionCode, bucketSize) {
+  }
+
+  /**
+   * @param {string} histogramName
+   * @param {number} duration
+   */
+  recordPerformanceHistogram(histogramName, duration) {
+  }
+
+  /**
+   * @param {string} umaName
+   */
+  recordUserMetricsAction(umaName) {
+  }
+
+  /**
+   * @param {string} message
+   */
+  sendMessageToBackend(message) {
+  }
+
+  /**
+   * @param {!Adb.Config} config
+   */
+  setDevicesDiscoveryConfig(config) {
+  }
+
+  /**
+   * @param {boolean} enabled
+   */
+  setDevicesUpdatesEnabled(enabled) {
+  }
+
+  /**
+   * @param {string} pageId
+   * @param {string} action
+   */
+  performActionOnRemotePage(pageId, action) {
+  }
+
+  /**
+   * @param {string} browserId
+   * @param {string} url
+   */
+  openRemotePage(browserId, url) {
+  }
+
+  openNodeFrontend() {
+  }
+
+  /**
+   * @param {string} origin
+   * @param {string} script
+   */
+  setInjectedScriptForOrigin(origin, script) {
+  }
+
+  /**
+   * @param {boolean} isDocked
+   * @param {function()} callback
+   */
+  setIsDocked(isDocked, callback) {
+  }
+
+  /**
+   * @return {number}
+   */
+  zoomFactor() {
+  }
+
+  zoomIn() {
+  }
+
+  zoomOut() {
+  }
+
+  resetZoom() {
+  }
+
+  /**
+   * @param {number} x
+   * @param {number} y
+   * @param {!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>} items
+   * @param {!Document} document
+   */
+  showContextMenuAtPoint(x, y, items, document) {
+  }
+
+  /**
+   * @param {function()} callback
+   */
+  reattach(callback) {
+  }
+
+  readyForTest() {
+  }
+
+  connectionReady() {
+  }
+
+  /**
+   * @param {boolean} value
+   */
+  setOpenNewWindowForPopups(value) {
+  }
+
+  /**
+   * @return {boolean}
+   */
+  isHostedMode() {
+  }
+
+  /**
+   * @param {function(!ExtensionDescriptor)} callback
+   */
+  setAddExtensionCallback(callback) {
+  }
+}
+
+/** @typedef
+{{
+    type: string,
+    id: (number|undefined),
+    label: (string|undefined),
+    enabled: (boolean|undefined),
+    checked: (boolean|undefined),
+    subItems: (!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>|undefined)
+}} */
+InspectorFrontendHostAPI.ContextMenuDescriptor;
+
+/** @typedef
+{{
+    statusCode: number,
+    headers: (!Object.<string, string>|undefined)
+}} */
+InspectorFrontendHostAPI.LoadNetworkResourceResult;
\ No newline at end of file
diff --git a/front_end/host/InspectorFrontendHost.js b/front_end/host/InspectorFrontendHost.js
index af2b163..6249a30 100644
--- a/front_end/host/InspectorFrontendHost.js
+++ b/front_end/host/InspectorFrontendHost.js
@@ -50,6 +50,11 @@
      * @type {!Map<string, !Array<string>>}
      */
     this._urlsBeingSaved = new Map();
+
+    /**
+     * @type {!Common.EventTarget}
+     */
+    this.events;
   }
 
   /**
@@ -128,10 +133,12 @@
 
   /**
    * @override
-   * @param {string} text
+   * @param {?(string|undefined)} text
    * @suppressGlobalPropertiesCheck
    */
   copyText(text) {
+    if (text === undefined || text === null)
+      return;
     if (navigator.clipboard) {
       navigator.clipboard.writeText(text);
     } else if (document.queryCommandSupported('copy')) {
@@ -175,7 +182,7 @@
       this._urlsBeingSaved.set(url, buffer);
     }
     buffer.push(content);
-    this.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.SavedURL, {url, fileSystemPath: url});
+    this.events.dispatchEventToListeners(Host.InspectorFrontendHostAPI.Events.SavedURL, {url, fileSystemPath: url});
   }
 
   /**
@@ -186,7 +193,7 @@
   append(url, content) {
     const buffer = this._urlsBeingSaved.get(url);
     buffer.push(content);
-    this.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.AppendedToURL, url);
+    this.events.dispatchEventToListeners(Host.InspectorFrontendHostAPI.Events.AppendedToURL, url);
   }
 
   /**
@@ -239,7 +246,7 @@
    * @override
    */
   requestFileSystems() {
-    this.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.FileSystemsLoaded, []);
+    this.events.dispatchEventToListeners(Host.InspectorFrontendHostAPI.Events.FileSystemsLoaded, []);
   }
 
   /**
@@ -496,7 +503,7 @@
     this._debugFrontend =
         !!Runtime.queryParam('debugFrontend') || (window['InspectorTest'] && window['InspectorTest']['debugTest']);
 
-    const descriptors = InspectorFrontendHostAPI.EventDescriptors;
+    const descriptors = Host.InspectorFrontendAPIImpl.EventDescriptors;
     for (let i = 0; i < descriptors.length; ++i)
       this[descriptors[i][1]] = this._dispatch.bind(this, descriptors[i][0], descriptors[i][2], descriptors[i][3]);
   }
@@ -544,8 +551,47 @@
   }
 };
 
+Host.InspectorFrontendAPIImpl.EventDescriptors = [
+  [Host.InspectorFrontendHostAPI.Events.AppendedToURL, 'appendedToURL', ['url']],
+  [Host.InspectorFrontendHostAPI.Events.CanceledSaveURL, 'canceledSaveURL', ['url']],
+  [Host.InspectorFrontendHostAPI.Events.ContextMenuCleared, 'contextMenuCleared', []],
+  [Host.InspectorFrontendHostAPI.Events.ContextMenuItemSelected, 'contextMenuItemSelected', ['id']],
+  [Host.InspectorFrontendHostAPI.Events.DeviceCountUpdated, 'deviceCountUpdated', ['count']],
+  [Host.InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, 'devicesDiscoveryConfigChanged', ['config']],
+  [
+    Host.InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged, 'devicesPortForwardingStatusChanged',
+    ['status']
+  ],
+  [Host.InspectorFrontendHostAPI.Events.DevicesUpdated, 'devicesUpdated', ['devices']],
+  [Host.InspectorFrontendHostAPI.Events.DispatchMessage, 'dispatchMessage', ['messageObject']],
+  [Host.InspectorFrontendHostAPI.Events.DispatchMessageChunk, 'dispatchMessageChunk', ['messageChunk', 'messageSize']],
+  [Host.InspectorFrontendHostAPI.Events.EnterInspectElementMode, 'enterInspectElementMode', []],
+  [Host.InspectorFrontendHostAPI.Events.EyeDropperPickedColor, 'eyeDropperPickedColor', ['color']],
+  [Host.InspectorFrontendHostAPI.Events.FileSystemsLoaded, 'fileSystemsLoaded', ['fileSystems']],
+  [Host.InspectorFrontendHostAPI.Events.FileSystemRemoved, 'fileSystemRemoved', ['fileSystemPath']],
+  [Host.InspectorFrontendHostAPI.Events.FileSystemAdded, 'fileSystemAdded', ['errorMessage', 'fileSystem']],
+  [
+    Host.InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved, 'fileSystemFilesChangedAddedRemoved',
+    ['changed', 'added', 'removed']
+  ],
+  [
+    Host.InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, 'indexingTotalWorkCalculated',
+    ['requestId', 'fileSystemPath', 'totalWork']
+  ],
+  [Host.InspectorFrontendHostAPI.Events.IndexingWorked, 'indexingWorked', ['requestId', 'fileSystemPath', 'worked']],
+  [Host.InspectorFrontendHostAPI.Events.IndexingDone, 'indexingDone', ['requestId', 'fileSystemPath']],
+  [Host.InspectorFrontendHostAPI.Events.KeyEventUnhandled, 'keyEventUnhandled', ['event']],
+  [Host.InspectorFrontendHostAPI.Events.ReloadInspectedPage, 'reloadInspectedPage', ['hard']],
+  [Host.InspectorFrontendHostAPI.Events.RevealSourceLine, 'revealSourceLine', ['url', 'lineNumber', 'columnNumber']],
+  [Host.InspectorFrontendHostAPI.Events.SavedURL, 'savedURL', ['url', 'fileSystemPath']],
+  [Host.InspectorFrontendHostAPI.Events.SearchCompleted, 'searchCompleted', ['requestId', 'fileSystemPath', 'files']],
+  [Host.InspectorFrontendHostAPI.Events.SetInspectedTabId, 'setInspectedTabId', ['tabId']],
+  [Host.InspectorFrontendHostAPI.Events.SetUseSoftMenu, 'setUseSoftMenu', ['useSoftMenu']],
+  [Host.InspectorFrontendHostAPI.Events.ShowPanel, 'showPanel', ['panelName']]
+];
+
 /**
- * @type {!InspectorFrontendHostAPI}
+ * @type {!Host.InspectorFrontendHostStub}
  */
 let InspectorFrontendHost = window.InspectorFrontendHost;
 (function() {
@@ -580,11 +626,6 @@
 })();
 
 /**
- * @type {!Common.EventTarget}
- */
-InspectorFrontendHost.events;
-
-/**
  * @param {!Object<string, string>=} prefs
  * @return {boolean}
  */
diff --git a/front_end/host/InspectorFrontendHostAPI.js b/front_end/host/InspectorFrontendHostAPI.js
index f148630..e017314 100644
--- a/front_end/host/InspectorFrontendHostAPI.js
+++ b/front_end/host/InspectorFrontendHostAPI.js
@@ -1,30 +1,11 @@
 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
-/** @interface */
-function InspectorFrontendHostAPI() {
-}
-window.InspectorFrontendHostAPI = InspectorFrontendHostAPI;
-/** @typedef
-{{
-    type: string,
-    id: (number|undefined),
-    label: (string|undefined),
-    enabled: (boolean|undefined),
-    checked: (boolean|undefined),
-    subItems: (!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>|undefined)
-}} */
-InspectorFrontendHostAPI.ContextMenuDescriptor;
 
-/** @typedef
-{{
-    statusCode: number,
-    headers: (!Object.<string, string>|undefined)
-}} */
-InspectorFrontendHostAPI.LoadNetworkResourceResult;
+Host.InspectorFrontendHostAPI = {};
 
 /** @enum {symbol} */
-InspectorFrontendHostAPI.Events = {
+Host.InspectorFrontendHostAPI.Events = {
   AppendedToURL: Symbol('appendedToURL'),
   CanceledSaveURL: Symbol('canceledSaveURL'),
   ContextMenuCleared: Symbol('contextMenuCleared'),
@@ -53,283 +34,3 @@
   SetUseSoftMenu: Symbol('setUseSoftMenu'),
   ShowPanel: Symbol('showPanel')
 };
-
-InspectorFrontendHostAPI.EventDescriptors = [
-  [InspectorFrontendHostAPI.Events.AppendedToURL, 'appendedToURL', ['url']],
-  [InspectorFrontendHostAPI.Events.CanceledSaveURL, 'canceledSaveURL', ['url']],
-  [InspectorFrontendHostAPI.Events.ContextMenuCleared, 'contextMenuCleared', []],
-  [InspectorFrontendHostAPI.Events.ContextMenuItemSelected, 'contextMenuItemSelected', ['id']],
-  [InspectorFrontendHostAPI.Events.DeviceCountUpdated, 'deviceCountUpdated', ['count']],
-  [InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, 'devicesDiscoveryConfigChanged', ['config']],
-  [
-    InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged, 'devicesPortForwardingStatusChanged', ['status']
-  ],
-  [InspectorFrontendHostAPI.Events.DevicesUpdated, 'devicesUpdated', ['devices']],
-  [InspectorFrontendHostAPI.Events.DispatchMessage, 'dispatchMessage', ['messageObject']],
-  [InspectorFrontendHostAPI.Events.DispatchMessageChunk, 'dispatchMessageChunk', ['messageChunk', 'messageSize']],
-  [InspectorFrontendHostAPI.Events.EnterInspectElementMode, 'enterInspectElementMode', []],
-  [InspectorFrontendHostAPI.Events.EyeDropperPickedColor, 'eyeDropperPickedColor', ['color']],
-  [InspectorFrontendHostAPI.Events.FileSystemsLoaded, 'fileSystemsLoaded', ['fileSystems']],
-  [InspectorFrontendHostAPI.Events.FileSystemRemoved, 'fileSystemRemoved', ['fileSystemPath']],
-  [InspectorFrontendHostAPI.Events.FileSystemAdded, 'fileSystemAdded', ['errorMessage', 'fileSystem']],
-  [
-    InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved, 'fileSystemFilesChangedAddedRemoved',
-    ['changed', 'added', 'removed']
-  ],
-  [
-    InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, 'indexingTotalWorkCalculated',
-    ['requestId', 'fileSystemPath', 'totalWork']
-  ],
-  [InspectorFrontendHostAPI.Events.IndexingWorked, 'indexingWorked', ['requestId', 'fileSystemPath', 'worked']],
-  [InspectorFrontendHostAPI.Events.IndexingDone, 'indexingDone', ['requestId', 'fileSystemPath']],
-  [InspectorFrontendHostAPI.Events.KeyEventUnhandled, 'keyEventUnhandled', ['event']],
-  [InspectorFrontendHostAPI.Events.ReloadInspectedPage, 'reloadInspectedPage', ['hard']],
-  [InspectorFrontendHostAPI.Events.RevealSourceLine, 'revealSourceLine', ['url', 'lineNumber', 'columnNumber']],
-  [InspectorFrontendHostAPI.Events.SavedURL, 'savedURL', ['url', 'fileSystemPath']],
-  [InspectorFrontendHostAPI.Events.SearchCompleted, 'searchCompleted', ['requestId', 'fileSystemPath', 'files']],
-  [InspectorFrontendHostAPI.Events.SetInspectedTabId, 'setInspectedTabId', ['tabId']],
-  [InspectorFrontendHostAPI.Events.SetUseSoftMenu, 'setUseSoftMenu', ['useSoftMenu']],
-  [InspectorFrontendHostAPI.Events.ShowPanel, 'showPanel', ['panelName']]
-];
-
-InspectorFrontendHostAPI.prototype = {
-  /**
-   * @param {string=} type
-   */
-  addFileSystem(type) {},
-
-  loadCompleted() {},
-
-  /**
-   * @param {number} requestId
-   * @param {string} fileSystemPath
-   * @param {string} excludedFolders
-   */
-  indexPath(requestId, fileSystemPath, excludedFolders) {},
-
-  /**
-   * Requests inspected page to be placed atop of the inspector frontend with specified bounds.
-   * @param {{x: number, y: number, width: number, height: number}} bounds
-   */
-  setInspectedPageBounds(bounds) {},
-
-  /**
-   * @param {!Array<string>} certChain
-   */
-  showCertificateViewer(certChain) {},
-
-  /**
-   * @param {string} shortcuts
-   */
-  setWhitelistedShortcuts(shortcuts) {},
-
-  /**
-   * @param {boolean} active
-   */
-  setEyeDropperActive(active) {},
-
-  inspectElementCompleted() {},
-
-  /**
-   * @param {string} url
-   */
-  openInNewTab(url) {},
-
-  /**
-   * @param {string} fileSystemPath
-   */
-  showItemInFolder(fileSystemPath) {},
-
-  /**
-   * @param {string} fileSystemPath
-   */
-  removeFileSystem(fileSystemPath) {},
-
-  requestFileSystems() {},
-
-  /**
-   * @param {string} url
-   * @param {string} content
-   * @param {boolean} forceSaveAs
-   */
-  save(url, content, forceSaveAs) {},
-
-  /**
-   * @param {string} url
-   * @param {string} content
-   */
-  append(url, content) {},
-
-  /**
-   * @param {string} url
-   */
-  close(url) {},
-
-  /**
-   * @param {number} requestId
-   * @param {string} fileSystemPath
-   * @param {string} query
-   */
-  searchInPath(requestId, fileSystemPath, query) {},
-
-  /**
-   * @param {number} requestId
-   */
-  stopIndexing(requestId) {},
-
-  bringToFront() {},
-
-  closeWindow() {},
-
-  copyText(text) {},
-
-  /**
-   * @param {string} url
-   */
-  inspectedURLChanged(url) {},
-
-  /**
-   * @param {string} fileSystemId
-   * @param {string} registeredName
-   * @return {?DOMFileSystem}
-   */
-  isolatedFileSystem(fileSystemId, registeredName) {},
-
-  /**
-   * @param {string} url
-   * @param {string} headers
-   * @param {number} streamId
-   * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} callback
-   */
-  loadNetworkResource(url, headers, streamId, callback) {},
-
-  /**
-   * @param {function(!Object<string, string>)} callback
-   */
-  getPreferences(callback) {},
-
-  /**
-   * @param {string} name
-   * @param {string} value
-   */
-  setPreference(name, value) {},
-
-  /**
-   * @param {string} name
-   */
-  removePreference(name) {},
-
-  clearPreferences() {},
-
-  /**
-   * @param {!FileSystem} fileSystem
-   */
-  upgradeDraggedFileSystemPermissions(fileSystem) {},
-
-  /**
-   * @return {string}
-   */
-  platform() {},
-
-  /**
-   * @param {string} actionName
-   * @param {number} actionCode
-   * @param {number} bucketSize
-   */
-  recordEnumeratedHistogram(actionName, actionCode, bucketSize) {},
-
-  /**
-   * @param {string} histogramName
-   * @param {number} duration
-   */
-  recordPerformanceHistogram(histogramName, duration) {},
-
-  /**
-   * @param {string} umaName
-   */
-  recordUserMetricsAction(umaName) {},
-
-  /**
-   * @param {string} message
-   */
-  sendMessageToBackend(message) {},
-
-  /**
-   * @param {!Adb.Config} config
-   */
-  setDevicesDiscoveryConfig(config) {},
-
-  /**
-   * @param {boolean} enabled
-   */
-  setDevicesUpdatesEnabled(enabled) {},
-
-  /**
-   * @param {string} pageId
-   * @param {string} action
-   */
-  performActionOnRemotePage(pageId, action) {},
-
-  /**
-   * @param {string} browserId
-   * @param {string} url
-   */
-  openRemotePage(browserId, url) {},
-
-  openNodeFrontend() {},
-
-  /**
-   * @param {string} origin
-   * @param {string} script
-   */
-  setInjectedScriptForOrigin(origin, script) {},
-
-  /**
-   * @param {boolean} isDocked
-   * @param {function()} callback
-   */
-  setIsDocked(isDocked, callback) {},
-
-  /**
-   * @return {number}
-   */
-  zoomFactor() {},
-
-  zoomIn() {},
-
-  zoomOut() {},
-
-  resetZoom() {},
-
-  /**
-   * @param {number} x
-   * @param {number} y
-   * @param {!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>} items
-   * @param {!Document} document
-   */
-  showContextMenuAtPoint(x, y, items, document) {},
-
-  /**
-   * @param {function()} callback
-   */
-  reattach(callback) {},
-
-  readyForTest() {},
-
-  connectionReady() {},
-
-  /**
-   * @param {boolean} value
-   */
-  setOpenNewWindowForPopups(value) {},
-
-  /**
-   * @return {boolean}
-   */
-  isHostedMode() {},
-
-  /**
-   * @param {function(!ExtensionDescriptor)} callback
-   */
-  setAddExtensionCallback(callback) {}
-};
diff --git a/front_end/inspector_main/InspectorMain.js b/front_end/inspector_main/InspectorMain.js
index 6808e0b..079b4e5 100644
--- a/front_end/inspector_main/InspectorMain.js
+++ b/front_end/inspector_main/InspectorMain.js
@@ -38,7 +38,7 @@
     new InspectorMain.BackendSettingsSync();
     new MobileThrottling.NetworkPanelIndicator();
 
-    InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.ReloadInspectedPage, event => {
+    InspectorFrontendHost.events.addEventListener(Host.InspectorFrontendHostAPI.Events.ReloadInspectedPage, event => {
       const hard = /** @type {boolean} */ (event.data);
       SDK.ResourceTreeModel.reloadAllPages(hard);
     });
diff --git a/front_end/main/Main.js b/front_end/main/Main.js
index 787c31a..cf09560 100644
--- a/front_end/main/Main.js
+++ b/front_end/main/Main.js
@@ -236,11 +236,11 @@
     // TODO: we should not access actions from other modules.
     if (toggleSearchNodeAction) {
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.EnterInspectElementMode,
+          Host.InspectorFrontendHostAPI.Events.EnterInspectElementMode,
           toggleSearchNodeAction.execute.bind(toggleSearchNodeAction), this);
     }
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.RevealSourceLine, this._revealSourceLine, this);
+        Host.InspectorFrontendHostAPI.Events.RevealSourceLine, this._revealSourceLine, this);
 
     UI.inspectorView.createToolbars();
     InspectorFrontendHost.loadCompleted();
diff --git a/front_end/node_main/NodeConnectionsPanel.js b/front_end/node_main/NodeConnectionsPanel.js
index 7c49dbb..25e7259 100644
--- a/front_end/node_main/NodeConnectionsPanel.js
+++ b/front_end/node_main/NodeConnectionsPanel.js
@@ -14,7 +14,7 @@
     image.src = 'https://nodejs.org/static/images/logos/nodejs-new-pantone-black.png';
 
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
+        Host.InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
 
     /** @type {!Adb.Config} */
     this._config;
diff --git a/front_end/node_main/NodeMain.js b/front_end/node_main/NodeMain.js
index 1b51528..10afb88 100644
--- a/front_end/node_main/NodeMain.js
+++ b/front_end/node_main/NodeMain.js
@@ -39,7 +39,7 @@
     this._targetAgent.setDiscoverTargets(true);
 
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
+        Host.InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
     InspectorFrontendHost.setDevicesUpdatesEnabled(false);
     InspectorFrontendHost.setDevicesUpdatesEnabled(true);
   }
@@ -64,7 +64,7 @@
    */
   dispose() {
     InspectorFrontendHost.events.removeEventListener(
-        InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
+        Host.InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
 
     for (const sessionId of this._childTargets.keys())
       this.detachedFromTarget(sessionId, undefined);
diff --git a/front_end/persistence/IsolatedFileSystemManager.js b/front_end/persistence/IsolatedFileSystemManager.js
index 3ea1dc8..2c3604b 100644
--- a/front_end/persistence/IsolatedFileSystemManager.js
+++ b/front_end/persistence/IsolatedFileSystemManager.js
@@ -43,19 +43,19 @@
     this._progresses = new Map();
 
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.FileSystemRemoved, this._onFileSystemRemoved, this);
+        Host.InspectorFrontendHostAPI.Events.FileSystemRemoved, this._onFileSystemRemoved, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.FileSystemAdded, this._onFileSystemAdded, this);
+        Host.InspectorFrontendHostAPI.Events.FileSystemAdded, this._onFileSystemAdded, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved, this._onFileSystemFilesChanged, this);
+        Host.InspectorFrontendHostAPI.Events.FileSystemFilesChangedAddedRemoved, this._onFileSystemFilesChanged, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this);
+        Host.InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.IndexingWorked, this._onIndexingWorked, this);
+        Host.InspectorFrontendHostAPI.Events.IndexingWorked, this._onIndexingWorked, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.IndexingDone, this._onIndexingDone, this);
+        Host.InspectorFrontendHostAPI.Events.IndexingDone, this._onIndexingDone, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.SearchCompleted, this._onSearchCompleted, this);
+        Host.InspectorFrontendHostAPI.Events.SearchCompleted, this._onSearchCompleted, this);
 
     this._initExcludePatterSetting();
 
@@ -71,7 +71,7 @@
     let fulfill;
     const promise = new Promise(f => fulfill = f);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.FileSystemsLoaded, onFileSystemsLoaded, this);
+        Host.InspectorFrontendHostAPI.Events.FileSystemsLoaded, onFileSystemsLoaded, this);
     InspectorFrontendHost.requestFileSystems();
     return promise;
 
diff --git a/front_end/sdk/Connections.js b/front_end/sdk/Connections.js
index be2a939..a3ea04b 100644
--- a/front_end/sdk/Connections.js
+++ b/front_end/sdk/Connections.js
@@ -13,9 +13,9 @@
     this._messageSize = 0;
     this._eventListeners = [
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.DispatchMessage, this._dispatchMessage, this),
+          Host.InspectorFrontendHostAPI.Events.DispatchMessage, this._dispatchMessage, this),
       InspectorFrontendHost.events.addEventListener(
-          InspectorFrontendHostAPI.Events.DispatchMessageChunk, this._dispatchMessageChunk, this),
+          Host.InspectorFrontendHostAPI.Events.DispatchMessageChunk, this._dispatchMessageChunk, this),
     ];
   }
 
diff --git a/front_end/sdk/RuntimeModel.js b/front_end/sdk/RuntimeModel.js
index f26799a..acda0f1 100644
--- a/front_end/sdk/RuntimeModel.js
+++ b/front_end/sdk/RuntimeModel.js
@@ -366,7 +366,7 @@
    */
   _copyRequested(object) {
     if (!object.objectId) {
-      InspectorFrontendHost.copyText(object.unserializableValue() || object.value);
+      InspectorFrontendHost.copyText(object.unserializableValue() || /** @type {string} */ (object.value));
       return;
     }
     object.callFunctionJSON(toStringForClipboard, [{value: object.subtype}])
diff --git a/front_end/ui/ContextMenu.js b/front_end/ui/ContextMenu.js
index 69b9b89..9e877c7 100644
--- a/front_end/ui/ContextMenu.js
+++ b/front_end/ui/ContextMenu.js
@@ -368,7 +368,7 @@
   }
 
   static initialize() {
-    InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetUseSoftMenu, setUseSoftMenu);
+    InspectorFrontendHost.events.addEventListener(Host.InspectorFrontendHostAPI.Events.SetUseSoftMenu, setUseSoftMenu);
     /**
      * @param {!Common.Event} event
      */
@@ -447,9 +447,9 @@
        */
       function listenToEvents() {
         InspectorFrontendHost.events.addEventListener(
-            InspectorFrontendHostAPI.Events.ContextMenuCleared, this._menuCleared, this);
+            Host.InspectorFrontendHostAPI.Events.ContextMenuCleared, this._menuCleared, this);
         InspectorFrontendHost.events.addEventListener(
-            InspectorFrontendHostAPI.Events.ContextMenuItemSelected, this._onItemSelected, this);
+            Host.InspectorFrontendHostAPI.Events.ContextMenuItemSelected, this._onItemSelected, this);
       }
 
       // showContextMenuAtPoint call above synchronously issues a clear event for previous context menu (if any),
@@ -492,9 +492,9 @@
 
   _menuCleared() {
     InspectorFrontendHost.events.removeEventListener(
-        InspectorFrontendHostAPI.Events.ContextMenuCleared, this._menuCleared, this);
+        Host.InspectorFrontendHostAPI.Events.ContextMenuCleared, this._menuCleared, this);
     InspectorFrontendHost.events.removeEventListener(
-        InspectorFrontendHostAPI.Events.ContextMenuItemSelected, this._onItemSelected, this);
+        Host.InspectorFrontendHostAPI.Events.ContextMenuItemSelected, this._onItemSelected, this);
   }
 
   /**
diff --git a/front_end/ui/ForwardedInputEventHandler.js b/front_end/ui/ForwardedInputEventHandler.js
index 6baa49a..fa85a40 100644
--- a/front_end/ui/ForwardedInputEventHandler.js
+++ b/front_end/ui/ForwardedInputEventHandler.js
@@ -7,7 +7,7 @@
 UI.ForwardedInputEventHandler = class {
   constructor() {
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.KeyEventUnhandled, this._onKeyEventUnhandled, this);
+        Host.InspectorFrontendHostAPI.Events.KeyEventUnhandled, this._onKeyEventUnhandled, this);
   }
 
   /**
diff --git a/front_end/ui/InspectorView.js b/front_end/ui/InspectorView.js
index c19d282..960c308 100644
--- a/front_end/ui/InspectorView.js
+++ b/front_end/ui/InspectorView.js
@@ -93,7 +93,7 @@
     this._drawerSplitWidget.setMainWidget(this._tabbedPane);
 
     this._keyDownBound = this._keyDown.bind(this);
-    InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.ShowPanel, showPanel.bind(this));
+    InspectorFrontendHost.events.addEventListener(Host.InspectorFrontendHostAPI.Events.ShowPanel, showPanel.bind(this));
 
     /**
      * @this {UI.InspectorView}
diff --git a/front_end/workspace/FileManager.js b/front_end/workspace/FileManager.js
index 740a6ec..21b5cbe 100644
--- a/front_end/workspace/FileManager.js
+++ b/front_end/workspace/FileManager.js
@@ -36,11 +36,11 @@
     super();
     /** @type {!Map<string, function(?{fileSystemPath: (string|undefined)})>} */
     this._saveCallbacks = new Map();
-    InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SavedURL, this._savedURL, this);
+    InspectorFrontendHost.events.addEventListener(Host.InspectorFrontendHostAPI.Events.SavedURL, this._savedURL, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.CanceledSaveURL, this._canceledSavedURL, this);
+        Host.InspectorFrontendHostAPI.Events.CanceledSaveURL, this._canceledSavedURL, this);
     InspectorFrontendHost.events.addEventListener(
-        InspectorFrontendHostAPI.Events.AppendedToURL, this._appendedToURL, this);
+        Host.InspectorFrontendHostAPI.Events.AppendedToURL, this._appendedToURL, this);
   }
 
   /**