// components/browser_apis/tab_strip/tab_strip_ui_controller.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 { NodeIdSpec as tabsApi_mojom_NodeIdSpec } from './tab_strip_api_types.mojom-webui.js';
import { EmptySpec as mojoBase_mojom_EmptySpec } from '//resources/mojo/mojo/public/mojom/base/empty.mojom-webui.js';
import { ErrorSpec as mojoBase_mojom_ErrorSpec } from '//resources/mojo/mojo/public/mojom/base/error.mojom-webui.js';
import { PointSpec as gfx_mojom_PointSpec } from '//resources/mojo/ui/gfx/geometry/mojom/geometry.mojom-webui.js';
export class TabStripUIControllerPendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'tabs_api.mojom.TabStripUIController', scope);
    }
}
export class TabStripUIControllerRemote {
    proxy;
    $;
    onConnectionError;
    constructor(handle) {
        this.proxy =
            new mojo.internal.interfaceSupport.InterfaceRemoteBase(TabStripUIControllerPendingReceiver, handle);
        this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
        this.onConnectionError = this.proxy.getConnectionErrorEventRouter();
    }
    showTabContextMenu(id, location) {
        return this.proxy.sendMessage(1019098740, TabStripUIController_ShowTabContextMenu_ParamsSpec.$, TabStripUIController_ShowTabContextMenu_ResponseParamsSpec.$, [
            id,
            location
        ], true);
    }
}
;
/**
 * An object which receives request messages for the TabStripUIController
 * mojom interface. Must be constructed over an object which implements that
 * interface.
 */
export class TabStripUIControllerReceiver {
    helper_internal_;
    $;
    onConnectionError;
    constructor(impl) {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(TabStripUIControllerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.helper_internal_.registerHandler(1019098740, TabStripUIController_ShowTabContextMenu_ParamsSpec.$, TabStripUIController_ShowTabContextMenu_ResponseParamsSpec.$, impl.showTabContextMenu.bind(impl), true);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class TabStripUIController {
    static get $interfaceName() {
        return "tabs_api.mojom.TabStripUIController";
    }
    /**
     * 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 TabStripUIControllerRemote;
        remote.$.bindNewPipeAndPassReceiver().bindInBrowser();
        return remote;
    }
}
/**
 * An object which receives request messages for the TabStripUIController
 * 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 TabStripUIControllerCallbackRouter {
    helper_internal_;
    $;
    router_;
    showTabContextMenu;
    onConnectionError;
    constructor() {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(TabStripUIControllerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.router_ = new mojo.internal.interfaceSupport.CallbackRouter;
        this.showTabContextMenu =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(1019098740, TabStripUIController_ShowTabContextMenu_ParamsSpec.$, TabStripUIController_ShowTabContextMenu_ResponseParamsSpec.$, this.showTabContextMenu.createReceiverHandler(true /* expectsResponse */), true);
        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 TabStripUIController_ShowTabContextMenu_ParamsSpec = { $: {} };
export const TabStripUIController_ShowTabContextMenu_ResponseParamsSpec = { $: {} };
export const TabStripUIController_ShowTabContextMenu_ResponseParam_ResultSpec = { $: {} };
mojo.internal.Struct(TabStripUIController_ShowTabContextMenu_ParamsSpec.$, 'TabStripUIController_ShowTabContextMenu_Params', [
    mojo.internal.StructField('id', 0, 0, tabsApi_mojom_NodeIdSpec.$, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('location', 8, 0, gfx_mojom_PointSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 24],]);
mojo.internal.Struct(TabStripUIController_ShowTabContextMenu_ResponseParamsSpec.$, 'TabStripUIController_ShowTabContextMenu_ResponseParams', [
    mojo.internal.StructField('result', 0, 0, TabStripUIController_ShowTabContextMenu_ResponseParam_ResultSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 24],]);
mojo.internal.Union(TabStripUIController_ShowTabContextMenu_ResponseParam_ResultSpec.$, 'TabStripUIController_ShowTabContextMenu_ResponseParam_Result', {
    'success': {
        'ordinal': 0,
        'type': mojoBase_mojom_EmptySpec.$,
    },
    'failure': {
        'ordinal': 1,
        'type': mojoBase_mojom_ErrorSpec.$,
    },
});
export var TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags;
(function (TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags) {
    TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags[TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags["SUCCESS"] = 0] = "SUCCESS";
    TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags[TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags["FAILURE"] = 1] = "FAILURE";
})(TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags || (TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags = {}));
export function whichTabStripUIController_ShowTabContextMenu_ResponseParam_Result(u) {
    if (u.success !== null && u.success !== undefined) {
        return TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags.SUCCESS;
    }
    if (u.failure !== null && u.failure !== undefined) {
        return TabStripUIController_ShowTabContextMenu_ResponseParam_ResultFieldTags.FAILURE;
    }
    throw new Error("no union field has been set, this is an illegal state");
}
