Settings TS: Migrate downloads_page/, system_page folders.

Bug: 1234307
Change-Id: I3245fb851d9620292d86ec60444e3d40e95f585e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3066972
Commit-Queue: dpapad <dpapad@chromium.org>
Reviewed-by: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#908370}
diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn
index e80c5f2..14d26a1 100644
--- a/chrome/browser/resources/settings/BUILD.gn
+++ b/chrome/browser/resources/settings/BUILD.gn
@@ -120,7 +120,7 @@
     "controls/pref_control_behavior.js",
     "controls/settings_boolean_control_behavior.js",
     "controls/settings_idle_load.js",
-    "downloads_page/downloads_browser_proxy.js",
+    "downloads_page/downloads_browser_proxy.ts",
     "ensure_lazy_loaded.js",
     "extension_control_browser_proxy.ts",
     "global_scroll_target_mixin.js",
@@ -137,6 +137,7 @@
     "people_page/sync_browser_proxy.js",
     "people_page/profile_info_browser_proxy.js",
     "prefs/prefs_behavior.js",
+    "prefs/prefs_behavior_ts.ts",
     "prefs/prefs.js",
     "prefs/prefs_types.js",
     "prefs/pref_util.js",
@@ -170,7 +171,7 @@
     if (!is_chromeos_lacros) {
       in_files += [
         "default_browser_page/default_browser_browser_proxy.js",
-        "system_page/system_page_browser_proxy.js",
+        "system_page/system_page_browser_proxy.ts",
       ]
     }
     in_files += [
@@ -235,7 +236,7 @@
     "controls/settings_slider.js",
     "controls/settings_textarea.js",
     "controls/settings_toggle_button.js",
-    "downloads_page/downloads_page.js",
+    "downloads_page/downloads_page.ts",
     "icons.ts",
     "settings_menu/settings_menu.js",
     "on_startup_page/on_startup_page.js",
@@ -333,7 +334,7 @@
   if (!is_chromeos) {
     in_files += [
       "default_browser_page/default_browser_page.js",
-      "system_page/system_page.js",
+      "system_page/system_page.ts",
     ]
   }
 
@@ -375,7 +376,6 @@
     "basic_page:closure_compile",
     "clear_browsing_data_dialog:closure_compile",
     "controls:closure_compile",
-    "downloads_page:closure_compile",
     "on_startup_page:closure_compile",
     "people_page:closure_compile",
     "prefs:closure_compile",
@@ -396,10 +396,7 @@
   }
 
   if (!is_chromeos) {
-    deps += [
-      "default_browser_page:closure_compile",
-      "system_page:closure_compile",
-    ]
+    deps += [ "default_browser_page:closure_compile" ]
   }
 
   if (is_win) {
@@ -714,8 +711,8 @@
     "controls/settings_slider.js",
     "controls/settings_textarea.js",
     "controls/settings_toggle_button.js",
-    "downloads_page/downloads_browser_proxy.js",
-    "downloads_page/downloads_page.js",
+    "downloads_page/downloads_browser_proxy.ts",
+    "downloads_page/downloads_page.ts",
     "ensure_lazy_loaded.js",
     "extension_control_browser_proxy.ts",
     "global_scroll_target_mixin.js",
@@ -742,6 +739,7 @@
     "people_page/sync_encryption_options.js",
     "people_page/sync_page.js",
     "prefs/prefs_behavior.js",
+    "prefs/prefs_behavior_ts.ts",
     "prefs/prefs.js",
     "prefs/prefs_types.js",
     "prefs/pref_util.js",
@@ -855,8 +853,8 @@
       in_files += [
         "default_browser_page/default_browser_browser_proxy.js",
         "default_browser_page/default_browser_page.js",
-        "system_page/system_page_browser_proxy.js",
-        "system_page/system_page.js",
+        "system_page/system_page_browser_proxy.ts",
+        "system_page/system_page.ts",
       ]
     }
     in_files += [
diff --git a/chrome/browser/resources/settings/downloads_page/BUILD.gn b/chrome/browser/resources/settings/downloads_page/BUILD.gn
index e192aae..0e68db6 100644
--- a/chrome/browser/resources/settings/downloads_page/BUILD.gn
+++ b/chrome/browser/resources/settings/downloads_page/BUILD.gn
@@ -2,33 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//third_party/closure_compiler/compile_js.gni")
 import("//tools/polymer/html_to_js.gni")
-import("../settings.gni")
-
-js_type_check("closure_compile") {
-  is_polymer3 = true
-  closure_flags = settings_closure_flags
-  deps = [
-    ":downloads_browser_proxy",
-    ":downloads_page",
-  ]
-}
-
-js_library("downloads_browser_proxy") {
-  deps = [ "//ui/webui/resources/js:cr.m" ]
-}
-
-js_library("downloads_page") {
-  deps = [
-    ":downloads_browser_proxy",
-    "../prefs:prefs_behavior",
-    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
-    "//ui/webui/resources/js:util.m",
-    "//ui/webui/resources/js:web_ui_listener_behavior.m",
-  ]
-}
 
 html_to_js("web_components") {
-  js_files = [ "downloads_page.js" ]
+  js_files = [ "downloads_page.ts" ]
 }
diff --git a/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.js b/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.js
deleted file mode 100644
index 0511a1a..0000000
--- a/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2017 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.
-
-// clang-format off
-import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
-// clang-format on
-
-/** @interface */
-export class DownloadsBrowserProxy {
-  initializeDownloads() {}
-
-  /**
-   * @param {boolean} enableLink whether to link or unlink account.
-   */
-  setDownloadsConnectionAccountLink(enableLink) {}
-
-  selectDownloadLocation() {}
-
-  resetAutoOpenFileTypes() {}
-
-  // <if expr="chromeos">
-  /**
-   * @param {string} path path to sanitze.
-   * @return {!Promise<string>} string to display in UI.
-   */
-  getDownloadLocationText(path) {}
-  // </if>
-}
-
-/**
- * @implements {DownloadsBrowserProxy}
- */
-export class DownloadsBrowserProxyImpl {
-  /** @override */
-  initializeDownloads() {
-    chrome.send('initializeDownloads');
-  }
-
-  /** @override */
-  setDownloadsConnectionAccountLink(enableLink) {
-    chrome.send('setDownloadsConnectionAccountLink', [enableLink]);
-  }
-
-  /** @override */
-  selectDownloadLocation() {
-    chrome.send('selectDownloadLocation');
-  }
-
-  /** @override */
-  resetAutoOpenFileTypes() {
-    chrome.send('resetAutoOpenFileTypes');
-  }
-
-  // <if expr="chromeos">
-  /** @override */
-  getDownloadLocationText(path) {
-    return sendWithPromise('getDownloadLocationText', path);
-  }
-  // </if>
-}
-
-addSingletonGetter(DownloadsBrowserProxyImpl);
diff --git a/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.ts b/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.ts
new file mode 100644
index 0000000..14a25807
--- /dev/null
+++ b/chrome/browser/resources/settings/downloads_page/downloads_browser_proxy.ts
@@ -0,0 +1,62 @@
+// Copyright 2017 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.
+
+// clang-format off
+import {sendWithPromise} from 'chrome://resources/js/cr.m.js';
+// clang-format on
+
+export interface DownloadsBrowserProxy {
+  initializeDownloads(): void;
+
+  /**
+   * @param enableLink whether to link or unlink account.
+   */
+  setDownloadsConnectionAccountLink(enableLink: boolean): void;
+
+  selectDownloadLocation(): void;
+
+  resetAutoOpenFileTypes(): void;
+
+  // <if expr="chromeos">
+  /**
+   * @param path Path to sanitze.
+   * @return string to display in UI.
+   */
+  getDownloadLocationText(path: string): Promise<string>;
+  // </if>
+}
+
+export class DownloadsBrowserProxyImpl implements DownloadsBrowserProxy {
+  initializeDownloads() {
+    chrome.send('initializeDownloads');
+  }
+
+  setDownloadsConnectionAccountLink(enableLink: boolean) {
+    chrome.send('setDownloadsConnectionAccountLink', [enableLink]);
+  }
+
+  selectDownloadLocation() {
+    chrome.send('selectDownloadLocation');
+  }
+
+  resetAutoOpenFileTypes() {
+    chrome.send('resetAutoOpenFileTypes');
+  }
+
+  // <if expr="chromeos">
+  getDownloadLocationText(path: string) {
+    return sendWithPromise('getDownloadLocationText', path);
+  }
+  // </if>
+
+  static getInstance(): DownloadsBrowserProxy {
+    return instance || (instance = new DownloadsBrowserProxyImpl());
+  }
+
+  static setInstance(obj: DownloadsBrowserProxy) {
+    instance = obj;
+  }
+}
+
+let instance: DownloadsBrowserProxy|null = null;
diff --git a/chrome/browser/resources/settings/downloads_page/downloads_page.js b/chrome/browser/resources/settings/downloads_page/downloads_page.ts
similarity index 67%
rename from chrome/browser/resources/settings/downloads_page/downloads_page.js
rename to chrome/browser/resources/settings/downloads_page/downloads_page.ts
index d738093..ffb2aff 100644
--- a/chrome/browser/resources/settings/downloads_page/downloads_page.js
+++ b/chrome/browser/resources/settings/downloads_page/downloads_page.ts
@@ -15,22 +15,23 @@
 import '../settings_shared_css.js';
 
 import {listenOnce} from 'chrome://resources/js/util.m.js';
-import {WebUIListenerBehavior, WebUIListenerBehaviorInterface} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
+import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
 import {html, mixinBehaviors, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
 
-import {PrefsBehavior, PrefsBehaviorInterface} from '../prefs/prefs_behavior.js';
+import {PrefsBehavior} from '../prefs/prefs_behavior.js';
+import {PrefsBehaviorInterface} from '../prefs/prefs_behavior_ts.js';
 
 import {DownloadsBrowserProxy, DownloadsBrowserProxyImpl} from './downloads_browser_proxy.js';
 
+type AccountInfo = {
+  linked: boolean,
+  account: {name: string, login: string},
+  folder: {name: string, link: string},
+};
 
-/**
- * @constructor
- * @extends {PolymerElement}
- * @implements {WebUIListenerBehaviorInterface}
- * @implements {PrefsBehaviorInterface}
- */
 const SettingsDownloadsPageElementBase =
-    mixinBehaviors([WebUIListenerBehavior, PrefsBehavior], PolymerElement);
+    mixinBehaviors([WebUIListenerBehavior, PrefsBehavior], PolymerElement) as
+    {new (): PolymerElement & WebUIListenerBehavior & PrefsBehaviorInterface};
 
 /** @polymer */
 class SettingsDownloadsPageElement extends SettingsDownloadsPageElementBase {
@@ -52,13 +53,11 @@
         notify: true,
       },
 
-      /** @private */
       showConnection_: {
         type: Boolean,
         value: false,
       },
 
-      /** @private */
       connectionLearnMoreLink_: {
         type: String,
         value:
@@ -66,28 +65,20 @@
       },
 
       /**
-       * @private
        * The connection account info object. The definition is based on
        * chrome/browser/enterprise/connectors/file_system/signin_experience.cc:
        * GetFileSystemConnectorLinkedAccountInfoForSettingsPage()
-       * @type {{
-       *  linked: boolean,
-       *  account: {name: string, login: string},
-       *  folder: {name: string, link: string},
-       * }}
        */
       connectionAccountInfo_: {
         type: Object,
         notify: true,
       },
 
-      /** @private */
       connectionSetupInProgress_: {
         type: Boolean,
         value: false,
       },
 
-      /** @private */
       autoOpenDownloads_: {
         type: Boolean,
         value: false,
@@ -110,70 +101,71 @@
   }
   // </if>
 
-  /** @override */
-  constructor() {
-    super();
 
-    /** @private {!DownloadsBrowserProxy} */
-    this.browserProxy_ = DownloadsBrowserProxyImpl.getInstance();
-  }
+  private showConnection_: boolean;
+  private connectionLearnMoreLink_: string;
+  private connectionAccountInfo_: AccountInfo;
+  private connectionSetupInProgress_: boolean;
+  private autoOpenDownloads_: boolean;
 
-  /** @override */
+  // <if expr="chromeos">
+  private downloadLocation_: string;
+  // </if>
+
+  private browserProxy_: DownloadsBrowserProxy =
+      DownloadsBrowserProxyImpl.getInstance();
+
   ready() {
     super.ready();
 
-    this.addWebUIListener('auto-open-downloads-changed', autoOpen => {
-      this.autoOpenDownloads_ = autoOpen;
-    });
+    this.addWebUIListener(
+        'auto-open-downloads-changed', (autoOpen: boolean) => {
+          this.autoOpenDownloads_ = autoOpen;
+        });
 
     this.addWebUIListener(
-        'downloads-connection-policy-changed', downloadsConnectionEnabled => {
+        'downloads-connection-policy-changed',
+        (downloadsConnectionEnabled: boolean) => {
           this.showConnection_ = downloadsConnectionEnabled;
         });
 
-    this.addWebUIListener('downloads-connection-link-changed', accountInfo => {
-      this.connectionAccountInfo_ = accountInfo;
-      this.connectionSetupInProgress_ = false;
-    });
+    this.addWebUIListener(
+        'downloads-connection-link-changed', (accountInfo: AccountInfo) => {
+          this.connectionAccountInfo_ = accountInfo;
+          this.connectionSetupInProgress_ = false;
+        });
 
     this.browserProxy_.initializeDownloads();
   }
 
-  /** @private */
-  onLinkDownloadsConnectionClick_() {
+  private onLinkDownloadsConnectionClick_() {
     this.connectionSetupInProgress_ = true;
     this.browserProxy_.setDownloadsConnectionAccountLink(true);
   }
 
-  /** @private */
-  onUnlinkDownloadsConnectionClick_() {
+  private onUnlinkDownloadsConnectionClick_() {
     this.connectionSetupInProgress_ = true;
     this.browserProxy_.setDownloadsConnectionAccountLink(false);
   }
 
-  /** @private */
-  selectDownloadLocation_() {
+  private selectDownloadLocation_() {
     listenOnce(this, 'transitionend', () => {
       this.browserProxy_.selectDownloadLocation();
     });
   }
 
   // <if expr="chromeos">
-  /**
-   * @private
-   */
-  handleDownloadLocationChanged_() {
+  private handleDownloadLocationChanged_() {
     this.browserProxy_
-        .getDownloadLocationText(/** @type {string} */ (
-            this.getPref('download.default_directory').value))
+        .getDownloadLocationText(
+            this.getPref('download.default_directory').value)
         .then(text => {
           this.downloadLocation_ = text;
         });
   }
   // </if>
 
-  /** @private */
-  onClearAutoOpenFileTypesTap_() {
+  private onClearAutoOpenFileTypesTap_() {
     this.browserProxy_.resetAutoOpenFileTypes();
   }
 }
diff --git a/chrome/browser/resources/settings/lifetime_browser_proxy.ts b/chrome/browser/resources/settings/lifetime_browser_proxy.ts
index a7d49bb..88d9caa3 100644
--- a/chrome/browser/resources/settings/lifetime_browser_proxy.ts
+++ b/chrome/browser/resources/settings/lifetime_browser_proxy.ts
@@ -2,10 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// clang-format on
-import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
-// clang-format off
-
 export interface LifetimeBrowserProxy {
   // Triggers a browser restart.
   restart(): void;
@@ -43,6 +39,14 @@
     chrome.send('factoryReset', [requestTpmFirmwareUpdate]);
   }
   // </if>
+
+  static getInstance(): LifetimeBrowserProxy {
+    return instance || (instance = new LifetimeBrowserProxyImpl());
+  }
+
+  static setInstance(obj: LifetimeBrowserProxy) {
+    instance = obj;
+  }
 }
 
-addSingletonGetter(LifetimeBrowserProxyImpl);
+let instance: LifetimeBrowserProxy|null = null;
diff --git a/chrome/browser/resources/settings/prefs/prefs_behavior_ts.ts b/chrome/browser/resources/settings/prefs/prefs_behavior_ts.ts
new file mode 100644
index 0000000..e9794c1
--- /dev/null
+++ b/chrome/browser/resources/settings/prefs/prefs_behavior_ts.ts
@@ -0,0 +1,13 @@
+// Copyright 2021 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.
+
+// TODO(crbug.com/1234307): Delete this file once prefs_behavior.js has been
+// migrated to TypeScript.
+
+export interface PrefsBehaviorInterface {
+  getPref(prefPath: string): chrome.settingsPrivate.PrefObject;
+  setPrefValue(prefPath: string, value: any): void;
+  appendPrefListItem(key: string, item: any): void;
+  deletePrefListItem(key: string, item: any): void;
+}
diff --git a/chrome/browser/resources/settings/system_page/BUILD.gn b/chrome/browser/resources/settings/system_page/BUILD.gn
index 6dcc6d3..321a6c1b 100644
--- a/chrome/browser/resources/settings/system_page/BUILD.gn
+++ b/chrome/browser/resources/settings/system_page/BUILD.gn
@@ -2,35 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//third_party/closure_compiler/compile_js.gni")
 import("//tools/polymer/html_to_js.gni")
-import("../settings.gni")
-
-js_type_check("closure_compile") {
-  is_polymer3 = true
-  closure_flags = settings_closure_flags
-  deps = [
-    ":system_page",
-    ":system_page_browser_proxy",
-  ]
-}
-
-js_library("system_page") {
-  deps = [
-    ":system_page_browser_proxy",
-    "..:lifetime_browser_proxy",
-    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
-  ]
-  externs_list = [ "$externs_path/settings_private.js" ]
-}
-
-js_library("system_page_browser_proxy") {
-  deps = [
-    "//ui/webui/resources/js:cr.m",
-    "//ui/webui/resources/js:load_time_data.m",
-  ]
-}
 
 html_to_js("web_components") {
-  js_files = [ "system_page.js" ]
+  js_files = [ "system_page.ts" ]
 }
diff --git a/chrome/browser/resources/settings/system_page/system_page.js b/chrome/browser/resources/settings/system_page/system_page.ts
similarity index 84%
rename from chrome/browser/resources/settings/system_page/system_page.js
rename to chrome/browser/resources/settings/system_page/system_page.ts
index 63f7d0a..cf71728 100644
--- a/chrome/browser/resources/settings/system_page/system_page.js
+++ b/chrome/browser/resources/settings/system_page/system_page.ts
@@ -40,15 +40,8 @@
         notify: true,
       },
 
-      /** @private */
-      isProxyEnforcedByPolicy_: {
-        type: Boolean,
-      },
-
-      /** @private */
-      isProxyDefault_: {
-        type: Boolean,
-      },
+      isProxyEnforcedByPolicy_: Boolean,
+      isProxyDefault_: Boolean,
     };
   }
 
@@ -58,9 +51,11 @@
     ];
   }
 
-  /** @private */
-  observeProxyPrefChanged_() {
-    /** @type {!chrome.settingsPrivate.PrefObject} */
+  prefs: {proxy: chrome.settingsPrivate.PrefObject};
+  private isProxyEnforcedByPolicy_: boolean;
+  private isProxyDefault_: boolean;
+
+  private observeProxyPrefChanged_() {
     const pref = this.prefs.proxy;
     // TODO(dbeam): do types of policy other than USER apply on ChromeOS?
     this.isProxyEnforcedByPolicy_ =
@@ -69,8 +64,7 @@
     this.isProxyDefault_ = !this.isProxyEnforcedByPolicy_ && !pref.extensionId;
   }
 
-  /** @private */
-  onExtensionDisable_() {
+  private onExtensionDisable_() {
     // TODO(dbeam): this is a pretty huge bummer. It means there are things
     // (inputs) that our prefs system is not observing. And that changes from
     // other sources (i.e. disabling/enabling an extension from
@@ -80,15 +74,13 @@
         'refresh-pref', {bubbles: true, composed: true, detail: 'proxy'}));
   }
 
-  /** @private */
-  onProxyTap_() {
+  private onProxyTap_() {
     if (this.isProxyDefault_) {
       SystemPageBrowserProxyImpl.getInstance().showProxySettings();
     }
   }
 
-  /** @private */
-  onRestartTap_(e) {
+  private onRestartTap_(e: Event) {
     // Prevent event from bubbling up to the toggle button.
     e.stopPropagation();
     // TODO(dbeam): we should prompt before restarting the browser.
@@ -96,11 +88,9 @@
   }
 
   /**
-   * @param {boolean} enabled Whether hardware acceleration is currently
-   *     enabled.
-   * @private
+   * @param enabled Whether hardware acceleration is currently enabled.
    */
-  shouldShowRestart_(enabled) {
+  private shouldShowRestart_(enabled: boolean): boolean {
     const proxy = SystemPageBrowserProxyImpl.getInstance();
     return enabled !== proxy.wasHardwareAccelerationEnabledAtStartup();
   }
diff --git a/chrome/browser/resources/settings/system_page/system_page_browser_proxy.js b/chrome/browser/resources/settings/system_page/system_page_browser_proxy.js
deleted file mode 100644
index ba677e8..0000000
--- a/chrome/browser/resources/settings/system_page/system_page_browser_proxy.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 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.
-
-/** @fileoverview Handles interprocess communication for the system page. */
-
-// clang-format on
-import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
-import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
-// clang-format off
-
-  /** @interface */
-  export class SystemPageBrowserProxy {
-    /** Shows the native system proxy settings. */
-    showProxySettings() {}
-
-    /**
-     * @return {boolean} Whether hardware acceleration was enabled when the user
-     *     started Chrome.
-     */
-    wasHardwareAccelerationEnabledAtStartup() {}
-  }
-
-  /** @implements {SystemPageBrowserProxy} */
-  export class SystemPageBrowserProxyImpl {
-    /** @override */
-    showProxySettings() {
-      chrome.send('showProxySettings');
-    }
-
-    /** @override */
-    wasHardwareAccelerationEnabledAtStartup() {
-      return loadTimeData.getBoolean('hardwareAccelerationEnabledAtStartup');
-    }
-  }
-
-  addSingletonGetter(SystemPageBrowserProxyImpl);
-
diff --git a/chrome/browser/resources/settings/system_page/system_page_browser_proxy.ts b/chrome/browser/resources/settings/system_page/system_page_browser_proxy.ts
new file mode 100644
index 0000000..8f1038c3
--- /dev/null
+++ b/chrome/browser/resources/settings/system_page/system_page_browser_proxy.ts
@@ -0,0 +1,40 @@
+// Copyright 2016 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.
+
+/** @fileoverview Handles interprocess communication for the system page. */
+
+// clang-format on
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+// clang-format off
+
+export interface SystemPageBrowserProxy {
+  /** Shows the native system proxy settings. */
+  showProxySettings(): void;
+
+  /**
+   * @return Whether hardware acceleration was enabled when the user
+   *     started Chrome.
+   */
+  wasHardwareAccelerationEnabledAtStartup(): boolean;
+}
+
+export class SystemPageBrowserProxyImpl implements SystemPageBrowserProxy {
+  showProxySettings() {
+    chrome.send('showProxySettings');
+  }
+
+  wasHardwareAccelerationEnabledAtStartup() {
+    return loadTimeData.getBoolean('hardwareAccelerationEnabledAtStartup');
+  }
+
+  static getInstance(): SystemPageBrowserProxy {
+    return instance || (instance = new SystemPageBrowserProxyImpl());
+  }
+
+  static setInstance(obj: SystemPageBrowserProxy) {
+    instance = obj;
+  }
+}
+
+let instance: SystemPageBrowserProxy|null = null;
diff --git a/chrome/test/data/webui/settings/about_page_tests.js b/chrome/test/data/webui/settings/about_page_tests.js
index 56b447f..66aa214 100644
--- a/chrome/test/data/webui/settings/about_page_tests.js
+++ b/chrome/test/data/webui/settings/about_page_tests.js
@@ -64,7 +64,7 @@
 
     testRoutes = setupRouter();
     lifetimeBrowserProxy = new TestLifetimeBrowserProxy();
-    LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
+    LifetimeBrowserProxyImpl.setInstance(lifetimeBrowserProxy);
 
     aboutBrowserProxy = new TestAboutPageBrowserProxy();
     AboutPageBrowserProxyImpl.instance_ = aboutBrowserProxy;
diff --git a/chrome/test/data/webui/settings/chromeos/os_about_page_tests.js b/chrome/test/data/webui/settings/chromeos/os_about_page_tests.js
index d83d7e8..4d05655 100644
--- a/chrome/test/data/webui/settings/chromeos/os_about_page_tests.js
+++ b/chrome/test/data/webui/settings/chromeos/os_about_page_tests.js
@@ -28,7 +28,7 @@
 
     setup(function() {
       lifetimeBrowserProxy = new settings.TestLifetimeBrowserProxy();
-      settings.LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
+      settings.LifetimeBrowserProxyImpl.setInstance(lifetimeBrowserProxy);
 
       aboutBrowserProxy = new TestAboutPageBrowserProxyChromeOS();
       settings.AboutPageBrowserProxyImpl.instance_ = aboutBrowserProxy;
diff --git a/chrome/test/data/webui/settings/chromeos/os_languages_page_v2_tests.js b/chrome/test/data/webui/settings/chromeos/os_languages_page_v2_tests.js
index 6e04af0..d735a41b 100644
--- a/chrome/test/data/webui/settings/chromeos/os_languages_page_v2_tests.js
+++ b/chrome/test/data/webui/settings/chromeos/os_languages_page_v2_tests.js
@@ -60,7 +60,7 @@
     settings.LanguagesBrowserProxyImpl.instance_ = browserProxy;
 
     lifetimeProxy = new settings.TestLifetimeBrowserProxy();
-    settings.LifetimeBrowserProxyImpl.instance_ = lifetimeProxy;
+    settings.LifetimeBrowserProxyImpl.setInstance(lifetimeProxy);
 
     // Sets up test metrics proxy.
     metricsProxy = new settings.TestLanguagesMetricsProxy();
diff --git a/chrome/test/data/webui/settings/chromeos/os_reset_page_test.js b/chrome/test/data/webui/settings/chromeos/os_reset_page_test.js
index 539315f..f0c1c1e0 100644
--- a/chrome/test/data/webui/settings/chromeos/os_reset_page_test.js
+++ b/chrome/test/data/webui/settings/chromeos/os_reset_page_test.js
@@ -39,7 +39,7 @@
 
     setup(function() {
       lifetimeBrowserProxy = new settings.TestLifetimeBrowserProxy();
-      settings.LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
+      settings.LifetimeBrowserProxyImpl.setInstance(lifetimeBrowserProxy);
 
       resetPageBrowserProxy = new reset_page.TestOsResetBrowserProxy();
       settings.OsResetBrowserProxyImpl.instance_ = resetPageBrowserProxy;
diff --git a/chrome/test/data/webui/settings/downloads_page_test.js b/chrome/test/data/webui/settings/downloads_page_test.js
index fd2bc4a..018826b 100644
--- a/chrome/test/data/webui/settings/downloads_page_test.js
+++ b/chrome/test/data/webui/settings/downloads_page_test.js
@@ -44,7 +44,7 @@
 
   setup(function() {
     downloadsBrowserProxy = new TestDownloadsBrowserProxy();
-    DownloadsBrowserProxyImpl.instance_ = downloadsBrowserProxy;
+    DownloadsBrowserProxyImpl.setInstance(downloadsBrowserProxy);
 
     PolymerTest.clearBody();
 
diff --git a/chrome/test/data/webui/settings/safety_check_page_test.js b/chrome/test/data/webui/settings/safety_check_page_test.js
index 8bd202f..48af9616 100644
--- a/chrome/test/data/webui/settings/safety_check_page_test.js
+++ b/chrome/test/data/webui/settings/safety_check_page_test.js
@@ -417,7 +417,7 @@
 
   setup(function() {
     lifetimeBrowserProxy = new TestLifetimeBrowserProxy();
-    LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
+    LifetimeBrowserProxyImpl.setInstance(lifetimeBrowserProxy);
     metricsBrowserProxy = new TestMetricsBrowserProxy();
     MetricsBrowserProxyImpl.instance_ = metricsBrowserProxy;
 
diff --git a/chrome/test/data/webui/settings/system_page_tests.js b/chrome/test/data/webui/settings/system_page_tests.js
index 98d18ac..36f32075 100644
--- a/chrome/test/data/webui/settings/system_page_tests.js
+++ b/chrome/test/data/webui/settings/system_page_tests.js
@@ -44,9 +44,9 @@
   setup(function() {
     PolymerTest.clearBody();
     lifetimeBrowserProxy = new TestLifetimeBrowserProxy();
-    LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
+    LifetimeBrowserProxyImpl.setInstance(lifetimeBrowserProxy);
     systemBrowserProxy = new TestSystemPageBrowserProxy();
-    SystemPageBrowserProxyImpl.instance_ = systemBrowserProxy;
+    SystemPageBrowserProxyImpl.setInstance(systemBrowserProxy);
 
     systemPage = document.createElement('settings-system-page');
     systemPage.set('prefs', {