// chrome/browser/ui/webui/iwa_dev/iwa_dev.mojom-webui.ts is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { mojo } from '//resources/mojo/mojo/public/js/bindings.js';
import { MojoBrowserProxyFactory } from '//resources/mojo/mojo_browser_proxy.js';
import { FilePathSpec as mojoBase_mojom_FilePathSpec } from '//resources/mojo/mojo/public/mojom/base/file_path.mojom-webui.js';
import { OriginSpec as url_mojom_OriginSpec } from '//resources/mojo/url/mojom/origin.mojom-webui.js';
import { UrlSpec as url_mojom_UrlSpec } from '//resources/mojo/url/mojom/url.mojom-webui.js';
export class PageHandlerPendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'iwa_dev.mojom.PageHandler', scope);
    }
}
export class PageHandlerRemote {
    proxy;
    $;
    onConnectionError;
    constructor(handle) {
        this.proxy =
            new mojo.internal.interfaceSupport.InterfaceRemoteBase(PageHandlerPendingReceiver, handle);
        this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
        this.onConnectionError = this.proxy.getConnectionErrorEventRouter();
    }
    getInstalledAppsInfo() {
        return this.proxy.sendMessage(1505391902, PageHandler_GetInstalledAppsInfo_ParamsSpec.$, PageHandler_GetInstalledAppsInfo_ResponseParamsSpec.$, [], false);
    }
    uninstallApp(appId) {
        return this.proxy.sendMessage(69985596, PageHandler_UninstallApp_ParamsSpec.$, PageHandler_UninstallApp_ResponseParamsSpec.$, [
            appId
        ], false);
    }
}
;
/**
 * An object which receives request messages for the PageHandler
 * mojom interface. Must be constructed over an object which implements that
 * interface.
 */
export class PageHandlerReceiver {
    helper_internal_;
    $;
    onConnectionError;
    constructor(impl) {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageHandlerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.helper_internal_.registerHandler(1505391902, PageHandler_GetInstalledAppsInfo_ParamsSpec.$, PageHandler_GetInstalledAppsInfo_ResponseParamsSpec.$, impl.getInstalledAppsInfo.bind(impl), false);
        this.helper_internal_.registerHandler(69985596, PageHandler_UninstallApp_ParamsSpec.$, PageHandler_UninstallApp_ResponseParamsSpec.$, impl.uninstallApp.bind(impl), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class PageHandler {
    static get $interfaceName() {
        return "iwa_dev.mojom.PageHandler";
    }
    /**
     * Returns a remote for this interface which sends messages to the browser.
     * The browser must have an interface request binder registered for this
     * interface and accessible to the calling document's frame.
     */
    static getRemote() {
        let remote = new PageHandlerRemote;
        remote.$.bindNewPipeAndPassReceiver().bindInBrowser();
        return remote;
    }
}
/**
 * An object which receives request messages for the PageHandler
 * mojom interface and dispatches them as callbacks. One callback receiver exists
 * on this object for each message defined in the mojom interface, and each
 * receiver can have any number of listeners added to it.
 */
export class PageHandlerCallbackRouter {
    helper_internal_;
    $;
    router_;
    getInstalledAppsInfo;
    uninstallApp;
    onConnectionError;
    constructor() {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageHandlerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.router_ = new mojo.internal.interfaceSupport.CallbackRouter;
        this.getInstalledAppsInfo =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(1505391902, PageHandler_GetInstalledAppsInfo_ParamsSpec.$, PageHandler_GetInstalledAppsInfo_ResponseParamsSpec.$, this.getInstalledAppsInfo.createReceiverHandler(true /* expectsResponse */), false);
        this.uninstallApp =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(69985596, PageHandler_UninstallApp_ParamsSpec.$, PageHandler_UninstallApp_ResponseParamsSpec.$, this.uninstallApp.createReceiverHandler(true /* expectsResponse */), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
    /**
     * @param id An ID returned by a prior call to addListener.
     * @return True iff the identified listener was found and removed.
     */
    removeListener(id) {
        return this.router_.removeListener(id);
    }
}
export class PagePendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'iwa_dev.mojom.Page', scope);
    }
}
export class PageRemote {
    proxy;
    $;
    onConnectionError;
    constructor(handle) {
        this.proxy =
            new mojo.internal.interfaceSupport.InterfaceRemoteBase(PagePendingReceiver, handle);
        this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
        this.onConnectionError = this.proxy.getConnectionErrorEventRouter();
    }
    onAppInstalled(appInfo) {
        this.proxy.sendMessage(1039755430, Page_OnAppInstalled_ParamsSpec.$, null, [
            appInfo
        ], false);
    }
    onAppUpdated(appInfo) {
        this.proxy.sendMessage(836669452, Page_OnAppUpdated_ParamsSpec.$, null, [
            appInfo
        ], false);
    }
    onAppUninstalled(appId) {
        this.proxy.sendMessage(140130930, Page_OnAppUninstalled_ParamsSpec.$, null, [
            appId
        ], false);
    }
}
;
/**
 * An object which receives request messages for the Page
 * mojom interface. Must be constructed over an object which implements that
 * interface.
 */
export class PageReceiver {
    helper_internal_;
    $;
    onConnectionError;
    constructor(impl) {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.helper_internal_.registerHandler(1039755430, Page_OnAppInstalled_ParamsSpec.$, null, impl.onAppInstalled.bind(impl), false);
        this.helper_internal_.registerHandler(836669452, Page_OnAppUpdated_ParamsSpec.$, null, impl.onAppUpdated.bind(impl), false);
        this.helper_internal_.registerHandler(140130930, Page_OnAppUninstalled_ParamsSpec.$, null, impl.onAppUninstalled.bind(impl), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class Page {
    static get $interfaceName() {
        return "iwa_dev.mojom.Page";
    }
    /**
     * Returns a remote for this interface which sends messages to the browser.
     * The browser must have an interface request binder registered for this
     * interface and accessible to the calling document's frame.
     */
    static getRemote() {
        let remote = new PageRemote;
        remote.$.bindNewPipeAndPassReceiver().bindInBrowser();
        return remote;
    }
}
/**
 * An object which receives request messages for the Page
 * mojom interface and dispatches them as callbacks. One callback receiver exists
 * on this object for each message defined in the mojom interface, and each
 * receiver can have any number of listeners added to it.
 */
export class PageCallbackRouter {
    helper_internal_;
    $;
    router_;
    onAppInstalled;
    onAppUpdated;
    onAppUninstalled;
    onConnectionError;
    constructor() {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.router_ = new mojo.internal.interfaceSupport.CallbackRouter;
        this.onAppInstalled =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(1039755430, Page_OnAppInstalled_ParamsSpec.$, null, this.onAppInstalled.createReceiverHandler(false /* expectsResponse */), false);
        this.onAppUpdated =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(836669452, Page_OnAppUpdated_ParamsSpec.$, null, this.onAppUpdated.createReceiverHandler(false /* expectsResponse */), false);
        this.onAppUninstalled =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(140130930, Page_OnAppUninstalled_ParamsSpec.$, null, this.onAppUninstalled.createReceiverHandler(false /* expectsResponse */), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
    /**
     * @param id An ID returned by a prior call to addListener.
     * @return True iff the identified listener was found and removed.
     */
    removeListener(id) {
        return this.router_.removeListener(id);
    }
}
export class PageHandlerFactoryPendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'iwa_dev.mojom.PageHandlerFactory', scope);
    }
}
export class PageHandlerFactoryRemote {
    proxy;
    $;
    onConnectionError;
    constructor(handle) {
        this.proxy =
            new mojo.internal.interfaceSupport.InterfaceRemoteBase(PageHandlerFactoryPendingReceiver, handle);
        this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
        this.onConnectionError = this.proxy.getConnectionErrorEventRouter();
    }
    createPageHandler(page, handler) {
        this.proxy.sendMessage(327500211, PageHandlerFactory_CreatePageHandler_ParamsSpec.$, null, [
            page,
            handler
        ], false);
    }
}
;
/**
 * An object which receives request messages for the PageHandlerFactory
 * mojom interface. Must be constructed over an object which implements that
 * interface.
 */
export class PageHandlerFactoryReceiver {
    helper_internal_;
    $;
    onConnectionError;
    constructor(impl) {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageHandlerFactoryRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.helper_internal_.registerHandler(327500211, PageHandlerFactory_CreatePageHandler_ParamsSpec.$, null, impl.createPageHandler.bind(impl), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class PageHandlerFactory {
    static get $interfaceName() {
        return "iwa_dev.mojom.PageHandlerFactory";
    }
    /**
     * Returns a remote for this interface which sends messages to the browser.
     * The browser must have an interface request binder registered for this
     * interface and accessible to the calling document's frame.
     */
    static getRemote() {
        let remote = new PageHandlerFactoryRemote;
        remote.$.bindNewPipeAndPassReceiver().bindInBrowser();
        return remote;
    }
}
/**
 * An object which receives request messages for the PageHandlerFactory
 * mojom interface and dispatches them as callbacks. One callback receiver exists
 * on this object for each message defined in the mojom interface, and each
 * receiver can have any number of listeners added to it.
 */
export class PageHandlerFactoryCallbackRouter {
    helper_internal_;
    $;
    router_;
    createPageHandler;
    onConnectionError;
    constructor() {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(PageHandlerFactoryRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.router_ = new mojo.internal.interfaceSupport.CallbackRouter;
        this.createPageHandler =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(327500211, PageHandlerFactory_CreatePageHandler_ParamsSpec.$, null, this.createPageHandler.createReceiverHandler(false /* expectsResponse */), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
    /**
     * @param id An ID returned by a prior call to addListener.
     * @return True iff the identified listener was found and removed.
     */
    removeListener(id) {
        return this.router_.removeListener(id);
    }
}
export const UpdateInfoSpec = { $: {} };
export const IwaDevModeAppInfoSpec = { $: {} };
export const PageHandler_GetInstalledAppsInfo_ParamsSpec = { $: {} };
export const PageHandler_GetInstalledAppsInfo_ResponseParamsSpec = { $: {} };
export const PageHandler_UninstallApp_ParamsSpec = { $: {} };
export const PageHandler_UninstallApp_ResponseParamsSpec = { $: {} };
export const Page_OnAppInstalled_ParamsSpec = { $: {} };
export const Page_OnAppUpdated_ParamsSpec = { $: {} };
export const Page_OnAppUninstalled_ParamsSpec = { $: {} };
export const PageHandlerFactory_CreatePageHandler_ParamsSpec = { $: {} };
export const IwaDevModeSourceSpec = { $: {} };
mojo.internal.Struct(UpdateInfoSpec.$, 'UpdateInfo', [
    mojo.internal.StructField('updateManifestUrl', 0, 0, url_mojom_UrlSpec.$, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('updateChannel', 8, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
], [[0, 24],]);
mojo.internal.Struct(IwaDevModeAppInfoSpec.$, 'IwaDevModeAppInfo', [
    mojo.internal.StructField('appId', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('webBundleId', 8, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('name', 16, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('source', 24, 0, IwaDevModeSourceSpec.$, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('installedVersion', 40, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
], [[0, 56],]);
mojo.internal.Struct(PageHandler_GetInstalledAppsInfo_ParamsSpec.$, 'PageHandler_GetInstalledAppsInfo_Params', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_GetInstalledAppsInfo_ResponseParamsSpec.$, 'PageHandler_GetInstalledAppsInfo_ResponseParams', [
    mojo.internal.StructField('apps', 0, 0, mojo.internal.Array(IwaDevModeAppInfoSpec.$, false), null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(PageHandler_UninstallApp_ParamsSpec.$, 'PageHandler_UninstallApp_Params', [
    mojo.internal.StructField('appId', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(PageHandler_UninstallApp_ResponseParamsSpec.$, 'PageHandler_UninstallApp_ResponseParams', [
    mojo.internal.StructField('success', 0, 0, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(Page_OnAppInstalled_ParamsSpec.$, 'Page_OnAppInstalled_Params', [
    mojo.internal.StructField('appInfo', 0, 0, IwaDevModeAppInfoSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(Page_OnAppUpdated_ParamsSpec.$, 'Page_OnAppUpdated_Params', [
    mojo.internal.StructField('appInfo', 0, 0, IwaDevModeAppInfoSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(Page_OnAppUninstalled_ParamsSpec.$, 'Page_OnAppUninstalled_Params', [
    mojo.internal.StructField('appId', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(PageHandlerFactory_CreatePageHandler_ParamsSpec.$, 'PageHandlerFactory_CreatePageHandler_Params', [
    mojo.internal.StructField('page', 0, 0, mojo.internal.InterfaceProxy(PageRemote), null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('handler', 8, 0, mojo.internal.InterfaceRequest(PageHandlerPendingReceiver), null, false /* nullable */, 0, undefined, undefined),
], [[0, 24],]);
mojo.internal.Union(IwaDevModeSourceSpec.$, 'IwaDevModeSource', {
    'proxyOrigin': {
        'ordinal': 0,
        'type': url_mojom_OriginSpec.$,
    },
    'bundlePath': {
        'ordinal': 1,
        'type': mojoBase_mojom_FilePathSpec.$,
    },
    'updateInfo': {
        'ordinal': 2,
        'type': UpdateInfoSpec.$,
    },
});
export var IwaDevModeSourceFieldTags;
(function (IwaDevModeSourceFieldTags) {
    IwaDevModeSourceFieldTags[IwaDevModeSourceFieldTags["PROXY_ORIGIN"] = 0] = "PROXY_ORIGIN";
    IwaDevModeSourceFieldTags[IwaDevModeSourceFieldTags["BUNDLE_PATH"] = 1] = "BUNDLE_PATH";
    IwaDevModeSourceFieldTags[IwaDevModeSourceFieldTags["UPDATE_INFO"] = 2] = "UPDATE_INFO";
})(IwaDevModeSourceFieldTags || (IwaDevModeSourceFieldTags = {}));
export function whichIwaDevModeSource(u) {
    if (u.proxyOrigin !== null && u.proxyOrigin !== undefined) {
        return IwaDevModeSourceFieldTags.PROXY_ORIGIN;
    }
    if (u.bundlePath !== null && u.bundlePath !== undefined) {
        return IwaDevModeSourceFieldTags.BUNDLE_PATH;
    }
    if (u.updateInfo !== null && u.updateInfo !== undefined) {
        return IwaDevModeSourceFieldTags.UPDATE_INFO;
    }
    throw new Error("no union field has been set, this is an illegal state");
}
export const browserProxyFactory = new MojoBrowserProxyFactory(PageHandlerRemote, PageCallbackRouter, (remote, receiver) => PageHandlerFactory.getRemote().createPageHandler(remote, receiver));
