diff options
Diffstat (limited to 'chromium/ui/webui/resources/cr_components/customize_themes/browser_proxy.js')
-rw-r--r-- | chromium/ui/webui/resources/cr_components/customize_themes/browser_proxy.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/chromium/ui/webui/resources/cr_components/customize_themes/browser_proxy.js b/chromium/ui/webui/resources/cr_components/customize_themes/browser_proxy.js new file mode 100644 index 00000000000..a5d2c2a92df --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/customize_themes/browser_proxy.js @@ -0,0 +1,62 @@ +// Copyright 2020 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 A helper object used by the customize-themes component to + * interact with the browser. + */ + +import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js'; +import 'chrome://resources/mojo/skia/public/mojom/skcolor.mojom-lite.js'; +import './customize_themes.mojom-lite.js'; + +import {addSingletonGetter} from 'chrome://resources/js/cr.m.js'; + +/** @interface */ +export class CustomizeThemesBrowserProxy { + /** @return {customizeThemes.mojom.CustomizeThemesHandlerInterface} */ + handler() {} + + /** @return {customizeThemes.mojom.CustomizeThemesClientCallbackRouter} */ + callbackRouter() {} + + /** @param {string} url */ + open(url) {} +} + +/** @implements {CustomizeThemesBrowserProxy} */ +export class CustomizeThemesBrowserProxyImpl { + constructor() { + /** @private {customizeThemes.mojom.CustomizeThemesHandlerRemote} */ + this.handler_ = new customizeThemes.mojom.CustomizeThemesHandlerRemote(); + + /** @private {customizeThemes.mojom.CustomizeThemesClientCallbackRouter} */ + this.callbackRouter_ = + new customizeThemes.mojom.CustomizeThemesClientCallbackRouter(); + + /** @type {customizeThemes.mojom.CustomizeThemesHandlerFactoryRemote} */ + const factory = + customizeThemes.mojom.CustomizeThemesHandlerFactory.getRemote(); + factory.createCustomizeThemesHandler( + this.callbackRouter_.$.bindNewPipeAndPassRemote(), + this.handler_.$.bindNewPipeAndPassReceiver()); + } + + /** @override */ + handler() { + return this.handler_; + } + + /** @override */ + callbackRouter() { + return this.callbackRouter_; + } + + /** @override */ + open(url) { + window.open(url, '_blank'); + } +} + +addSingletonGetter(CustomizeThemesBrowserProxyImpl); |