IdentityCredentialSerializationHelpers.h (4032B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_identitycredentialserializationhelpers_h__ 8 #define mozilla_dom_identitycredentialserializationhelpers_h__ 9 10 #include "mozilla/dom/BindingIPCUtils.h" 11 #include "mozilla/dom/CredentialManagementBinding.h" 12 #include "mozilla/dom/IdentityCredential.h" 13 #include "mozilla/dom/IdentityCredentialBinding.h" 14 #include "mozilla/dom/LoginStatusBinding.h" 15 16 namespace IPC { 17 18 template <> 19 struct ParamTraits<mozilla::dom::IdentityProviderConfig> { 20 typedef mozilla::dom::IdentityProviderConfig paramType; 21 22 static void Write(MessageWriter* aWriter, const paramType& aParam) { 23 WriteParam(aWriter, aParam.mConfigURL); 24 WriteParam(aWriter, aParam.mClientId); 25 } 26 27 static bool Read(MessageReader* aReader, paramType* aResult) { 28 return ReadParam(aReader, &aResult->mConfigURL) && 29 ReadParam(aReader, &aResult->mClientId); 30 } 31 }; 32 33 template <> 34 struct ParamTraits<mozilla::dom::IdentityProviderRequestOptions> { 35 typedef mozilla::dom::IdentityProviderRequestOptions paramType; 36 37 static void Write(MessageWriter* aWriter, const paramType& aParam) { 38 WriteParam(aWriter, aParam.mConfigURL); 39 WriteParam(aWriter, aParam.mClientId); 40 WriteParam(aWriter, aParam.mNonce); 41 WriteParam(aWriter, aParam.mLoginHint); 42 WriteParam(aWriter, aParam.mDomainHint); 43 } 44 45 static bool Read(MessageReader* aReader, paramType* aResult) { 46 return ReadParam(aReader, &aResult->mConfigURL) && 47 ReadParam(aReader, &aResult->mClientId) && 48 ReadParam(aReader, &aResult->mNonce) && 49 ReadParam(aReader, &aResult->mLoginHint) && 50 ReadParam(aReader, &aResult->mDomainHint); 51 } 52 }; 53 54 template <> 55 struct ParamTraits<mozilla::dom::IdentityCredentialDisconnectOptions> { 56 typedef mozilla::dom::IdentityCredentialDisconnectOptions paramType; 57 58 static void Write(MessageWriter* aWriter, const paramType& aParam) { 59 WriteParam(aWriter, aParam.mConfigURL); 60 WriteParam(aWriter, aParam.mClientId); 61 WriteParam(aWriter, aParam.mAccountHint); 62 } 63 64 static bool Read(MessageReader* aReader, paramType* aResult) { 65 return ReadParam(aReader, &aResult->mConfigURL) && 66 ReadParam(aReader, &aResult->mClientId) && 67 ReadParam(aReader, &aResult->mAccountHint); 68 } 69 }; 70 71 template <> 72 struct ParamTraits<mozilla::dom::CredentialMediationRequirement> 73 : public mozilla::dom::WebIDLEnumSerializer< 74 mozilla::dom::CredentialMediationRequirement> {}; 75 76 template <> 77 struct ParamTraits<mozilla::dom::IdentityCredentialRequestOptions> { 78 typedef mozilla::dom::IdentityCredentialRequestOptions paramType; 79 80 static void Write(MessageWriter* aWriter, const paramType& aParam) { 81 WriteParam(aWriter, aParam.mProviders); 82 WriteParam(aWriter, aParam.mMode); 83 } 84 85 static bool Read(MessageReader* aReader, paramType* aResult) { 86 return ReadParam(aReader, &aResult->mProviders) && 87 ReadParam(aReader, &aResult->mMode); 88 } 89 }; 90 91 template <> 92 struct ParamTraits<mozilla::dom::LoginStatus> 93 : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::LoginStatus> {}; 94 95 template <> 96 struct ParamTraits<mozilla::dom::IdentityCredentialRequestOptionsMode> 97 : public mozilla::dom::WebIDLEnumSerializer< 98 mozilla::dom::IdentityCredentialRequestOptionsMode> {}; 99 100 template <> 101 struct ParamTraits<mozilla::dom::IdentityResolveOptions> { 102 typedef mozilla::dom::IdentityResolveOptions paramType; 103 104 static void Write(MessageWriter* aWriter, const paramType& aParam) { 105 WriteParam(aWriter, aParam.mAccountId); 106 } 107 108 static bool Read(MessageReader* aReader, paramType* aResult) { 109 return ReadParam(aReader, &aResult->mAccountId); 110 } 111 }; 112 113 } // namespace IPC 114 115 #endif // mozilla_dom_identitycredentialserializationhelpers_h__