blob: 2f92f050d445e532bcb18f17c63286e01de6411d [file] [log] [blame]
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {PageCallbackRouter, PageHandlerFactory, PageHandlerRemote} from './contextual_tasks.mojom-webui.js';
import type {PageHandlerInterface} from './contextual_tasks.mojom-webui.js';
let instance: BrowserProxy|null = null;
export interface BrowserProxy {
callbackRouter: PageCallbackRouter;
handler: PageHandlerInterface;
}
export class BrowserProxyImpl implements BrowserProxy {
callbackRouter: PageCallbackRouter;
handler: PageHandlerInterface;
constructor() {
this.callbackRouter = new PageCallbackRouter();
this.handler = new PageHandlerRemote();
const factory = PageHandlerFactory.getRemote();
factory.createPageHandler(
this.callbackRouter.$.bindNewPipeAndPassRemote(),
(this.handler as PageHandlerRemote).$.bindNewPipeAndPassReceiver());
}
static getInstance(): BrowserProxy {
return instance || (instance = new BrowserProxyImpl());
}
static setInstance(proxy: BrowserProxy) {
instance = proxy;
}
}