// chrome/browser/ui/views/drive_picker_host/drive_picker_result_handler.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 { UrlSpec as url_mojom_UrlSpec } from '//resources/mojo/url/mojom/url.mojom-webui.js';
export const DrivePickerErrorSpec = { $: mojo.internal.Enum() };
export var DrivePickerError;
(function (DrivePickerError) {
    DrivePickerError[DrivePickerError["MIN_VALUE"] = 0] = "MIN_VALUE";
    DrivePickerError[DrivePickerError["MAX_VALUE"] = 12] = "MAX_VALUE";
    DrivePickerError[DrivePickerError["kTokenFetchFailure"] = 0] = "kTokenFetchFailure";
    DrivePickerError[DrivePickerError["kInvalidResponse"] = 1] = "kInvalidResponse";
    DrivePickerError[DrivePickerError["kInvalidFileId"] = 2] = "kInvalidFileId";
    DrivePickerError[DrivePickerError["kInvalidFileMetadata"] = 3] = "kInvalidFileMetadata";
    DrivePickerError[DrivePickerError["kUnsupportedFileType"] = 4] = "kUnsupportedFileType";
    DrivePickerError[DrivePickerError["kInvalidFileSize"] = 5] = "kInvalidFileSize";
    DrivePickerError[DrivePickerError["kAlreadyActive"] = 6] = "kAlreadyActive";
    DrivePickerError[DrivePickerError["kWindowNotFound"] = 7] = "kWindowNotFound";
    DrivePickerError[DrivePickerError["kApiLoadFailure"] = 8] = "kApiLoadFailure";
    DrivePickerError[DrivePickerError["kMojoDisconnected"] = 9] = "kMojoDisconnected";
    DrivePickerError[DrivePickerError["kWebUINotFound"] = 10] = "kWebUINotFound";
    DrivePickerError[DrivePickerError["kViewNotFound"] = 11] = "kViewNotFound";
    DrivePickerError[DrivePickerError["kUnknown"] = 12] = "kUnknown";
})(DrivePickerError || (DrivePickerError = {}));
export class DrivePickerResultHandlerPendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'drive_picker_host.mojom.DrivePickerResultHandler', scope);
    }
}
export class DrivePickerResultHandlerRemote {
    proxy;
    $;
    onConnectionError;
    constructor(handle) {
        this.proxy =
            new mojo.internal.interfaceSupport.InterfaceRemoteBase(DrivePickerResultHandlerPendingReceiver, handle);
        this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
        this.onConnectionError = this.proxy.getConnectionErrorEventRouter();
    }
    onSelection(files) {
        this.proxy.sendMessage(880967248, DrivePickerResultHandler_OnSelection_ParamsSpec.$, null, [
            files
        ], false);
    }
    onCancel() {
        this.proxy.sendMessage(353244078, DrivePickerResultHandler_OnCancel_ParamsSpec.$, null, [], false);
    }
    onError(error) {
        this.proxy.sendMessage(813286501, DrivePickerResultHandler_OnError_ParamsSpec.$, null, [
            error
        ], false);
    }
}
;
/**
 * An object which receives request messages for the DrivePickerResultHandler
 * mojom interface. Must be constructed over an object which implements that
 * interface.
 */
export class DrivePickerResultHandlerReceiver {
    helper_internal_;
    $;
    onConnectionError;
    constructor(impl) {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(DrivePickerResultHandlerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.helper_internal_.registerHandler(880967248, DrivePickerResultHandler_OnSelection_ParamsSpec.$, null, impl.onSelection.bind(impl), false);
        this.helper_internal_.registerHandler(353244078, DrivePickerResultHandler_OnCancel_ParamsSpec.$, null, impl.onCancel.bind(impl), false);
        this.helper_internal_.registerHandler(813286501, DrivePickerResultHandler_OnError_ParamsSpec.$, null, impl.onError.bind(impl), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class DrivePickerResultHandler {
    static get $interfaceName() {
        return "drive_picker_host.mojom.DrivePickerResultHandler";
    }
    /**
     * 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 DrivePickerResultHandlerRemote;
        remote.$.bindNewPipeAndPassReceiver().bindInBrowser();
        return remote;
    }
}
/**
 * An object which receives request messages for the DrivePickerResultHandler
 * 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 DrivePickerResultHandlerCallbackRouter {
    helper_internal_;
    $;
    router_;
    onSelection;
    onCancel;
    onError;
    onConnectionError;
    constructor() {
        this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(DrivePickerResultHandlerRemote);
        this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
        this.router_ = new mojo.internal.interfaceSupport.CallbackRouter;
        this.onSelection =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(880967248, DrivePickerResultHandler_OnSelection_ParamsSpec.$, null, this.onSelection.createReceiverHandler(false /* expectsResponse */), false);
        this.onCancel =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(353244078, DrivePickerResultHandler_OnCancel_ParamsSpec.$, null, this.onCancel.createReceiverHandler(false /* expectsResponse */), false);
        this.onError =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(813286501, DrivePickerResultHandler_OnError_ParamsSpec.$, null, this.onError.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 DriveFileSpec = { $: {} };
export const DrivePickerResultHandler_OnSelection_ParamsSpec = { $: {} };
export const DrivePickerResultHandler_OnCancel_ParamsSpec = { $: {} };
export const DrivePickerResultHandler_OnError_ParamsSpec = { $: {} };
mojo.internal.Struct(DriveFileSpec.$, 'DriveFile', [
    mojo.internal.StructField('id', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('mimeType', 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('type', 24, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('sizeBytes', 32, 0, mojo.internal.Uint64, BigInt(0), false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('resourceKey', 40, 0, mojo.internal.String, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('iconUrl', 48, 0, url_mojom_UrlSpec.$, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('thumbnailUrl', 56, 0, url_mojom_UrlSpec.$, null, true /* nullable */, 0, undefined, undefined),
], [[0, 72],]);
mojo.internal.Struct(DrivePickerResultHandler_OnSelection_ParamsSpec.$, 'DrivePickerResultHandler_OnSelection_Params', [
    mojo.internal.StructField('files', 0, 0, mojo.internal.Array(DriveFileSpec.$, false), null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(DrivePickerResultHandler_OnCancel_ParamsSpec.$, 'DrivePickerResultHandler_OnCancel_Params', [], [[0, 8],]);
mojo.internal.Struct(DrivePickerResultHandler_OnError_ParamsSpec.$, 'DrivePickerResultHandler_OnError_Params', [
    mojo.internal.StructField('error', 0, 0, DrivePickerErrorSpec.$, 0, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
