Commit d84cb764 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Fix LargeBlob support in Credentials

Credentials type converter can access a dictionary member[1] when it is
not available.
This CL fixes the issue.


[1] PublicKeyCredentialCreationOptions.extensions.largeBlob.support

Bug: 839389
Change-Id: Ica1b43775e221a37a4be0befc920035f32fa214f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558133Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830987}
parent 13aebe7c
...@@ -321,12 +321,15 @@ TypeConverter<AuthenticatorAttachment, base::Optional<String>>::Convert( ...@@ -321,12 +321,15 @@ TypeConverter<AuthenticatorAttachment, base::Optional<String>>::Convert(
} }
// static // static
LargeBlobSupport TypeConverter<LargeBlobSupport, String>::Convert( LargeBlobSupport
const String& large_blob_support) { TypeConverter<LargeBlobSupport, base::Optional<String>>::Convert(
if (large_blob_support == "required") const base::Optional<String>& large_blob_support) {
if (large_blob_support) {
if (*large_blob_support == "required")
return LargeBlobSupport::REQUIRED; return LargeBlobSupport::REQUIRED;
if (large_blob_support == "preferred") if (*large_blob_support == "preferred")
return LargeBlobSupport::PREFERRED; return LargeBlobSupport::PREFERRED;
}
// Unknown values are treated as preferred. // Unknown values are treated as preferred.
return LargeBlobSupport::PREFERRED; return LargeBlobSupport::PREFERRED;
...@@ -570,9 +573,12 @@ TypeConverter<PublicKeyCredentialCreationOptionsPtr, ...@@ -570,9 +573,12 @@ TypeConverter<PublicKeyCredentialCreationOptionsPtr,
WebAuthenticationResidentKeyRequirementEnabled()); WebAuthenticationResidentKeyRequirementEnabled());
mojo_options->cred_props = true; mojo_options->cred_props = true;
} }
if (extensions->largeBlob()) { if (extensions->hasLargeBlob()) {
mojo_options->large_blob_enable = base::Optional<WTF::String> support;
ConvertTo<LargeBlobSupport>(extensions->largeBlob()->support()); if (extensions->largeBlob()->hasSupport()) {
support = extensions->largeBlob()->support();
}
mojo_options->large_blob_enable = ConvertTo<LargeBlobSupport>(support);
} }
} }
......
...@@ -106,8 +106,10 @@ struct TypeConverter<blink::mojom::blink::AuthenticatorAttachment, ...@@ -106,8 +106,10 @@ struct TypeConverter<blink::mojom::blink::AuthenticatorAttachment,
}; };
template <> template <>
struct TypeConverter<blink::mojom::blink::LargeBlobSupport, String> { struct TypeConverter<blink::mojom::blink::LargeBlobSupport,
static blink::mojom::blink::LargeBlobSupport Convert(const String&); base::Optional<String>> {
static blink::mojom::blink::LargeBlobSupport Convert(
const base::Optional<String>&);
}; };
template <> template <>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment