// components/enterprise/connectors/connectors_internals.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';
export const KeyManagerInitializedValueSpec = { $: mojo.internal.Enum() };
export var KeyManagerInitializedValue;
(function (KeyManagerInitializedValue) {
    KeyManagerInitializedValue[KeyManagerInitializedValue["MIN_VALUE"] = 0] = "MIN_VALUE";
    KeyManagerInitializedValue[KeyManagerInitializedValue["MAX_VALUE"] = 2] = "MAX_VALUE";
    KeyManagerInitializedValue[KeyManagerInitializedValue["UNSUPPORTED"] = 0] = "UNSUPPORTED";
    KeyManagerInitializedValue[KeyManagerInitializedValue["KEY_LOADED"] = 1] = "KEY_LOADED";
    KeyManagerInitializedValue[KeyManagerInitializedValue["NO_KEY"] = 2] = "NO_KEY";
})(KeyManagerInitializedValue || (KeyManagerInitializedValue = {}));
export const KeyTrustLevelSpec = { $: mojo.internal.Enum() };
export var KeyTrustLevel;
(function (KeyTrustLevel) {
    KeyTrustLevel[KeyTrustLevel["MIN_VALUE"] = 0] = "MIN_VALUE";
    KeyTrustLevel[KeyTrustLevel["MAX_VALUE"] = 3] = "MAX_VALUE";
    KeyTrustLevel[KeyTrustLevel["UNSPECIFIED"] = 0] = "UNSPECIFIED";
    KeyTrustLevel[KeyTrustLevel["HW"] = 1] = "HW";
    KeyTrustLevel[KeyTrustLevel["OS"] = 2] = "OS";
    KeyTrustLevel[KeyTrustLevel["OS_SOFTWARE"] = 3] = "OS_SOFTWARE";
})(KeyTrustLevel || (KeyTrustLevel = {}));
export const KeyTypeSpec = { $: mojo.internal.Enum() };
export var KeyType;
(function (KeyType) {
    KeyType[KeyType["MIN_VALUE"] = 0] = "MIN_VALUE";
    KeyType[KeyType["MAX_VALUE"] = 2] = "MAX_VALUE";
    KeyType[KeyType["UNKNOWN"] = 0] = "UNKNOWN";
    KeyType[KeyType["RSA"] = 1] = "RSA";
    KeyType[KeyType["EC"] = 2] = "EC";
})(KeyType || (KeyType = {}));
export const KeyManagerPermanentFailureSpec = { $: mojo.internal.Enum() };
export var KeyManagerPermanentFailure;
(function (KeyManagerPermanentFailure) {
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["MIN_VALUE"] = 0] = "MIN_VALUE";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["MAX_VALUE"] = 4] = "MAX_VALUE";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["UNSPECIFIED"] = 0] = "UNSPECIFIED";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["CREATION_UPLOAD_CONFLICT"] = 1] = "CREATION_UPLOAD_CONFLICT";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["INSUFFICIENT_PERMISSIONS"] = 2] = "INSUFFICIENT_PERMISSIONS";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["OS_RESTRICTION"] = 3] = "OS_RESTRICTION";
    KeyManagerPermanentFailure[KeyManagerPermanentFailure["INVALID_INSTALLATION"] = 4] = "INVALID_INSTALLATION";
})(KeyManagerPermanentFailure || (KeyManagerPermanentFailure = {}));
export class PageHandlerPendingReceiver {
    handle;
    constructor(handle) {
        this.handle = mojo.internal.interfaceSupport.getEndpointForReceiver(handle);
    }
    bindInBrowser(scope = 'context') {
        mojo.internal.interfaceSupport.bind(this.handle, 'connectors_internals.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();
    }
    getDeviceTrustState() {
        return this.proxy.sendMessage(1021481800, PageHandler_GetDeviceTrustState_ParamsSpec.$, PageHandler_GetDeviceTrustState_ResponseParamsSpec.$, [], false);
    }
    deleteDeviceTrustKey() {
        return this.proxy.sendMessage(2066630691, PageHandler_DeleteDeviceTrustKey_ParamsSpec.$, PageHandler_DeleteDeviceTrustKey_ResponseParamsSpec.$, [], false);
    }
    getClientCertificateState() {
        return this.proxy.sendMessage(358279562, PageHandler_GetClientCertificateState_ParamsSpec.$, PageHandler_GetClientCertificateState_ResponseParamsSpec.$, [], false);
    }
    getSignalsReportingState() {
        return this.proxy.sendMessage(833579114, PageHandler_GetSignalsReportingState_ParamsSpec.$, PageHandler_GetSignalsReportingState_ResponseParamsSpec.$, [], 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(1021481800, PageHandler_GetDeviceTrustState_ParamsSpec.$, PageHandler_GetDeviceTrustState_ResponseParamsSpec.$, impl.getDeviceTrustState.bind(impl), false);
        this.helper_internal_.registerHandler(2066630691, PageHandler_DeleteDeviceTrustKey_ParamsSpec.$, PageHandler_DeleteDeviceTrustKey_ResponseParamsSpec.$, impl.deleteDeviceTrustKey.bind(impl), false);
        this.helper_internal_.registerHandler(358279562, PageHandler_GetClientCertificateState_ParamsSpec.$, PageHandler_GetClientCertificateState_ResponseParamsSpec.$, impl.getClientCertificateState.bind(impl), false);
        this.helper_internal_.registerHandler(833579114, PageHandler_GetSignalsReportingState_ParamsSpec.$, PageHandler_GetSignalsReportingState_ResponseParamsSpec.$, impl.getSignalsReportingState.bind(impl), false);
        this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
    }
}
export class PageHandler {
    static get $interfaceName() {
        return "connectors_internals.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_;
    getDeviceTrustState;
    deleteDeviceTrustKey;
    getClientCertificateState;
    getSignalsReportingState;
    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.getDeviceTrustState =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(1021481800, PageHandler_GetDeviceTrustState_ParamsSpec.$, PageHandler_GetDeviceTrustState_ResponseParamsSpec.$, this.getDeviceTrustState.createReceiverHandler(true /* expectsResponse */), false);
        this.deleteDeviceTrustKey =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(2066630691, PageHandler_DeleteDeviceTrustKey_ParamsSpec.$, PageHandler_DeleteDeviceTrustKey_ResponseParamsSpec.$, this.deleteDeviceTrustKey.createReceiverHandler(true /* expectsResponse */), false);
        this.getClientCertificateState =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(358279562, PageHandler_GetClientCertificateState_ParamsSpec.$, PageHandler_GetClientCertificateState_ResponseParamsSpec.$, this.getClientCertificateState.createReceiverHandler(true /* expectsResponse */), false);
        this.getSignalsReportingState =
            new mojo.internal.interfaceSupport.InterfaceCallbackReceiver(this.router_);
        this.helper_internal_.registerHandler(833579114, PageHandler_GetSignalsReportingState_ParamsSpec.$, PageHandler_GetSignalsReportingState_ResponseParamsSpec.$, this.getSignalsReportingState.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 const Int32ValueSpec = { $: {} };
export const LoadedKeyInfoSpec = { $: {} };
export const KeyInfoSpec = { $: {} };
export const ConsentMetadataSpec = { $: {} };
export const DeviceTrustStateSpec = { $: {} };
export const CertificateMetadataSpec = { $: {} };
export const ClientIdentitySpec = { $: {} };
export const ClientCertificateStateSpec = { $: {} };
export const SignalsReportingStateSpec = { $: {} };
export const PageHandler_GetDeviceTrustState_ParamsSpec = { $: {} };
export const PageHandler_GetDeviceTrustState_ResponseParamsSpec = { $: {} };
export const PageHandler_DeleteDeviceTrustKey_ParamsSpec = { $: {} };
export const PageHandler_DeleteDeviceTrustKey_ResponseParamsSpec = { $: {} };
export const PageHandler_GetClientCertificateState_ParamsSpec = { $: {} };
export const PageHandler_GetClientCertificateState_ResponseParamsSpec = { $: {} };
export const PageHandler_GetSignalsReportingState_ParamsSpec = { $: {} };
export const PageHandler_GetSignalsReportingState_ResponseParamsSpec = { $: {} };
export const KeyUploadStatusSpec = { $: {} };
mojo.internal.Struct(Int32ValueSpec.$, 'Int32Value', [
    mojo.internal.StructField('value', 0, 0, mojo.internal.Int32, 0, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(LoadedKeyInfoSpec.$, 'LoadedKeyInfo', [
    mojo.internal.StructField('trustLevel', 0, 0, KeyTrustLevelSpec.$, 0, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('keyType', 4, 0, KeyTypeSpec.$, 0, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('encodedSpkiHash', 8, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('keyUploadStatus', 16, 0, KeyUploadStatusSpec.$, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('hasSslKey', 32, 0, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
], [[0, 48],]);
mojo.internal.Struct(KeyInfoSpec.$, 'KeyInfo', [
    mojo.internal.StructField('isKeyManagerInitialized', 0, 0, KeyManagerInitializedValueSpec.$, 0, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('loadedKeyInfo', 8, 0, LoadedKeyInfoSpec.$, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('permanentFailure', 4, 0, KeyManagerPermanentFailureSpec.$, 0, false /* nullable */, 0, undefined, undefined),
], [[0, 24],]);
mojo.internal.Struct(ConsentMetadataSpec.$, 'ConsentMetadata', [
    mojo.internal.StructField('canCollectSignals', 0, 0, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('consentReceived', 0, 1, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(DeviceTrustStateSpec.$, 'DeviceTrustState', [
    mojo.internal.StructField('isEnabled', 0, 0, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('policyEnabledLevels', 8, 0, mojo.internal.Array(mojo.internal.String, false), null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('keyInfo', 16, 0, KeyInfoSpec.$, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('signalsJson', 24, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('consentMetadata', 32, 0, ConsentMetadataSpec.$, null, true /* nullable */, 0, undefined, undefined),
], [[0, 48],]);
mojo.internal.Struct(CertificateMetadataSpec.$, 'CertificateMetadata', [
    mojo.internal.StructField('serialNumber', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('fingerprint', 8, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('creationDateString', 16, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('expirationDateString', 24, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('subjectDisplayName', 32, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('issuerDisplayName', 40, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
], [[0, 56],]);
mojo.internal.Struct(ClientIdentitySpec.$, 'ClientIdentity', [
    mojo.internal.StructField('identityName', 0, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('loadedKeyInfo', 8, 0, LoadedKeyInfoSpec.$, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('certificateMetadata', 16, 0, CertificateMetadataSpec.$, null, true /* nullable */, 0, undefined, undefined),
], [[0, 32],]);
mojo.internal.Struct(ClientCertificateStateSpec.$, 'ClientCertificateState', [
    mojo.internal.StructField('policyEnabledLevels', 0, 0, mojo.internal.Array(mojo.internal.String, false), null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('managedProfileIdentity', 8, 0, ClientIdentitySpec.$, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('managedBrowserIdentity', 16, 0, ClientIdentitySpec.$, null, true /* nullable */, 0, undefined, undefined),
], [[0, 32],]);
mojo.internal.Struct(SignalsReportingStateSpec.$, 'SignalsReportingState', [
    mojo.internal.StructField('errorInfo', 0, 0, mojo.internal.String, null, true /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('statusReportEnabled', 8, 0, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('signalsReportEnabled', 8, 1, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('lastUploadAttemptTimestamp', 16, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('lastUploadSuccessTimestamp', 24, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('lastSignalsUploadConfig', 32, 0, mojo.internal.String, null, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('canCollectAllFields', 8, 2, mojo.internal.Bool, false, false /* nullable */, 0, undefined, undefined),
    mojo.internal.StructField('signalsJson', 40, 0, mojo.internal.String, null, true /* nullable */, 0, undefined, undefined),
], [[0, 56],]);
mojo.internal.Struct(PageHandler_GetDeviceTrustState_ParamsSpec.$, 'PageHandler_GetDeviceTrustState_Params', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_GetDeviceTrustState_ResponseParamsSpec.$, 'PageHandler_GetDeviceTrustState_ResponseParams', [
    mojo.internal.StructField('state', 0, 0, DeviceTrustStateSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(PageHandler_DeleteDeviceTrustKey_ParamsSpec.$, 'PageHandler_DeleteDeviceTrustKey_Params', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_DeleteDeviceTrustKey_ResponseParamsSpec.$, 'PageHandler_DeleteDeviceTrustKey_ResponseParams', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_GetClientCertificateState_ParamsSpec.$, 'PageHandler_GetClientCertificateState_Params', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_GetClientCertificateState_ResponseParamsSpec.$, 'PageHandler_GetClientCertificateState_ResponseParams', [
    mojo.internal.StructField('state', 0, 0, ClientCertificateStateSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Struct(PageHandler_GetSignalsReportingState_ParamsSpec.$, 'PageHandler_GetSignalsReportingState_Params', [], [[0, 8],]);
mojo.internal.Struct(PageHandler_GetSignalsReportingState_ResponseParamsSpec.$, 'PageHandler_GetSignalsReportingState_ResponseParams', [
    mojo.internal.StructField('state', 0, 0, SignalsReportingStateSpec.$, null, false /* nullable */, 0, undefined, undefined),
], [[0, 16],]);
mojo.internal.Union(KeyUploadStatusSpec.$, 'KeyUploadStatus', {
    'syncKeyResponseCode': {
        'ordinal': 0,
        'type': Int32ValueSpec.$,
    },
    'uploadClientError': {
        'ordinal': 1,
        'type': mojo.internal.String,
    },
});
export var KeyUploadStatusFieldTags;
(function (KeyUploadStatusFieldTags) {
    KeyUploadStatusFieldTags[KeyUploadStatusFieldTags["SYNC_KEY_RESPONSE_CODE"] = 0] = "SYNC_KEY_RESPONSE_CODE";
    KeyUploadStatusFieldTags[KeyUploadStatusFieldTags["UPLOAD_CLIENT_ERROR"] = 1] = "UPLOAD_CLIENT_ERROR";
})(KeyUploadStatusFieldTags || (KeyUploadStatusFieldTags = {}));
export function whichKeyUploadStatus(u) {
    if (u.syncKeyResponseCode !== null && u.syncKeyResponseCode !== undefined) {
        return KeyUploadStatusFieldTags.SYNC_KEY_RESPONSE_CODE;
    }
    if (u.uploadClientError !== null && u.uploadClientError !== undefined) {
        return KeyUploadStatusFieldTags.UPLOAD_CLIENT_ERROR;
    }
    throw new Error("no union field has been set, this is an illegal state");
}
