Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: third_party/WebKit/Source/modules/webauth/WebAuthentication.cpp

Issue 2966523002: Blink-layer update to match WebAuthN spec (Closed)
Patch Set: Remove undesired expected files Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webauth/WebAuthentication.h" 5 #include "modules/webauth/WebAuthentication.h"
6 6
7 #include <stdint.h> 7 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h"
8
9 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMArrayBuffer.h"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
13 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
14 #include "core/frame/LocalFrame.h" 14 #include "core/frame/LocalFrame.h"
15 #include "modules/webauth/RelyingPartyAccount.h" 15 #include "modules/webauth/AuthenticatorAttestationResponse.h"
16 #include "modules/webauth/ScopedCredential.h" 16 #include "modules/webauth/MakeCredentialOptions.h"
17 #include "modules/webauth/ScopedCredentialOptions.h" 17 #include "public/platform/InterfaceProvider.h"
18 #include "modules/webauth/ScopedCredentialParameters.h"
19 #include "services/service_manager/public/cpp/interface_provider.h" 18 #include "services/service_manager/public/cpp/interface_provider.h"
20 19
20 namespace blink {
21 typedef ArrayBufferOrArrayBufferView BufferSource;
22 } // namespace blink
23
21 namespace { 24 namespace {
22 const char kNoAuthenticatorError[] = "Authenticator unavailable."; 25 constexpr char kNoAuthenticatorError[] = "Authenticator unavailable.";
23 // Time to wait for an authenticator to successfully complete an operation. 26 // Time to wait for an authenticator to successfully complete an operation.
24 const int kAdjustedTimeoutLowerInSeconds = 60; 27 constexpr WTF::TimeDelta kAdjustedTimeoutLower = WTF::TimeDelta::FromMinutes(1);
25 const int kAdjustedTimeoutUpperInSeconds = 120; 28 constexpr WTF::TimeDelta kAdjustedTimeoutUpper = WTF::TimeDelta::FromMinutes(2);
26 } // anonymous namespace 29 } // anonymous namespace
27 30
28 namespace mojo { 31 namespace mojo {
29 using webauth::mojom::blink::RelyingPartyAccount;
30 using webauth::mojom::blink::RelyingPartyAccountPtr;
31 using webauth::mojom::blink::AuthenticatorStatus; 32 using webauth::mojom::blink::AuthenticatorStatus;
32 using webauth::mojom::blink::ScopedCredentialDescriptor; 33 using webauth::mojom::blink::MakeCredentialOptionsPtr;
33 using webauth::mojom::blink::ScopedCredentialOptions; 34 using webauth::mojom::blink::PublicKeyCredentialEntityPtr;
34 using webauth::mojom::blink::ScopedCredentialOptionsPtr; 35 using webauth::mojom::blink::PublicKeyCredentialParametersPtr;
35 using webauth::mojom::blink::ScopedCredentialParameters; 36 using webauth::mojom::blink::PublicKeyCredentialType;
36 using webauth::mojom::blink::ScopedCredentialParametersPtr; 37 using webauth::mojom::blink::AuthenticatorTransport;
37 using webauth::mojom::blink::ScopedCredentialType;
38 using webauth::mojom::blink::Transport;
39 38
40 // TODO(kpaulhamus): Make this a TypeConverter 39 // TODO(kpaulhamus): Make this a TypeConverter
41 Vector<uint8_t> ConvertBufferSource(const blink::BufferSource& buffer) { 40 Vector<uint8_t> ConvertBufferSource(const blink::BufferSource& buffer) {
42 DCHECK(!buffer.isNull()); 41 DCHECK(!buffer.isNull());
43 Vector<uint8_t> vector; 42 Vector<uint8_t> vector;
44 if (buffer.isArrayBuffer()) { 43 if (buffer.isArrayBuffer()) {
45 vector.Append(static_cast<uint8_t*>(buffer.getAsArrayBuffer()->Data()), 44 vector.Append(static_cast<uint8_t*>(buffer.getAsArrayBuffer()->Data()),
46 buffer.getAsArrayBuffer()->ByteLength()); 45 buffer.getAsArrayBuffer()->ByteLength());
47 } else { 46 } else {
47 DCHECK(buffer.isArrayBufferView());
48 vector.Append(static_cast<uint8_t*>( 48 vector.Append(static_cast<uint8_t*>(
49 buffer.getAsArrayBufferView().View()->BaseAddress()), 49 buffer.getAsArrayBufferView().View()->BaseAddress()),
50 buffer.getAsArrayBufferView().View()->byteLength()); 50 buffer.getAsArrayBufferView().View()->byteLength());
51 } 51 }
52 return vector; 52 return vector;
53 } 53 }
54 54
55 // TODO(kpaulhamus): Make this a TypeConverter 55 // TODO(kpaulhamus): Make this a TypeConverter
56 ScopedCredentialType ConvertScopedCredentialType(const String& cred_type) { 56 PublicKeyCredentialType ConvertPublicKeyCredentialType(const String& type) {
57 if (cred_type == "ScopedCred") 57 if (type == "public-key")
58 return ScopedCredentialType::SCOPEDCRED; 58 return PublicKeyCredentialType::PUBLIC_KEY;
59 NOTREACHED(); 59 NOTREACHED();
60 return ScopedCredentialType::SCOPEDCRED; 60 return PublicKeyCredentialType::PUBLIC_KEY;
61 } 61 }
62 62
63 // TODO(kpaulhamus): Make this a TypeConverter 63 // TODO(kpaulhamus): Make this a TypeConverter
64 Transport ConvertTransport(const String& transport) { 64 AuthenticatorTransport ConvertTransport(const String& transport) {
65 if (transport == "usb") 65 if (transport == "usb")
66 return Transport::USB; 66 return AuthenticatorTransport::USB;
67 if (transport == "nfc") 67 if (transport == "nfc")
68 return Transport::NFC; 68 return AuthenticatorTransport::NFC;
69 if (transport == "ble") 69 if (transport == "ble")
70 return Transport::BLE; 70 return AuthenticatorTransport::BLE;
71 NOTREACHED(); 71 NOTREACHED();
72 return Transport::USB; 72 return AuthenticatorTransport::USB;
73 } 73 }
74 74
75 // TODO(kpaulhamus): Make this a TypeConverter 75 // TODO(kpaulhamus): Make this a TypeConverter
76 RelyingPartyAccountPtr ConvertRelyingPartyAccount( 76 PublicKeyCredentialEntityPtr ConvertPublicKeyCredentialUserEntity(
77 const blink::RelyingPartyAccount& account_information, 77 const blink::PublicKeyCredentialUserEntity& user) {
78 blink::ScriptPromiseResolver* resolver) { 78 auto entity = webauth::mojom::blink::PublicKeyCredentialEntity::New();
79 auto mojo_account = RelyingPartyAccount::New(); 79 entity->id = user.id();
80 80 entity->name = user.name();
81 mojo_account->relying_party_display_name = 81 if (user.hasIcon()) {
82 account_information.rpDisplayName(); 82 entity->icon = blink::KURL(blink::KURL(), user.icon());
83 mojo_account->display_name = account_information.displayName(); 83 }
84 mojo_account->id = account_information.id(); 84 entity->display_name = user.displayName();
85 mojo_account->name = account_information.name(); 85 return entity;
86 mojo_account->image_url = account_information.imageURL();
87 return mojo_account;
88 } 86 }
89 87
90 // TODO(kpaulhamus): Make this a TypeConverter 88 // TODO(kpaulhamus): Make this a TypeConverter
91 ScopedCredentialOptionsPtr ConvertScopedCredentialOptions( 89 PublicKeyCredentialEntityPtr ConvertPublicKeyCredentialEntity(
92 const blink::ScopedCredentialOptions options, 90 const blink::PublicKeyCredentialEntity& rp) {
93 blink::ScriptPromiseResolver* resolver) { 91 auto entity = webauth::mojom::blink::PublicKeyCredentialEntity::New();
94 auto mojo_options = ScopedCredentialOptions::New(); 92 entity->id = rp.id();
95 if (options.hasRpId()) { 93 entity->name = rp.name();
96 // if rpID is missing, it will later be set to the origin of the page 94 if (rp.hasIcon()) {
97 // in the secure browser process. 95 entity->icon = blink::KURL(blink::KURL(), rp.icon());
98 mojo_options->relying_party_id = options.rpId(); 96 }
97 return entity;
98 }
99
100 // TODO(kpaulhamus): Make this a TypeConverter
101 PublicKeyCredentialParametersPtr ConvertPublicKeyCredentialParameters(
102 const blink::PublicKeyCredentialParameters parameter) {
103 auto mojo_parameter =
104 webauth::mojom::blink::PublicKeyCredentialParameters::New();
105 mojo_parameter->type = ConvertPublicKeyCredentialType(parameter.type());
106 // TODO(kpaulhamus): add AlgorithmIdentifier
107 return mojo_parameter;
108 }
109
110 // TODO(kpaulhamus): Make this a TypeConverter
111 MakeCredentialOptionsPtr ConvertMakeCredentialOptions(
112 const blink::MakeCredentialOptions options) {
113 auto mojo_options = webauth::mojom::blink::MakeCredentialOptions::New();
114 mojo_options->relying_party = ConvertPublicKeyCredentialEntity(options.rp());
115 mojo_options->user = ConvertPublicKeyCredentialUserEntity(options.user());
116 mojo_options->challenge = ConvertBufferSource(options.challenge());
117
118 Vector<webauth::mojom::blink::PublicKeyCredentialParametersPtr> parameters;
119 for (const auto& parameter : options.parameters()) {
120 parameters.push_back(ConvertPublicKeyCredentialParameters(parameter));
121 }
122 mojo_options->crypto_parameters = std::move(parameters);
123
124 // Step 4 of https://w3c.github.io/webauthn/#createCredential
125 WTF::TimeDelta adjusted_timeout;
126 if (options.hasTimeout()) {
127 adjusted_timeout = WTF::TimeDelta::FromMilliseconds(options.timeout());
128 } else {
129 adjusted_timeout = kAdjustedTimeoutLower;
99 } 130 }
100 131
101 // Step 4 of https://w3c.github.io/webauthn/#createCredential 132 mojo_options->adjusted_timeout = std::max(
102 int predicted_timeout = kAdjustedTimeoutLowerInSeconds; 133 kAdjustedTimeoutLower, std::min(kAdjustedTimeoutUpper, adjusted_timeout));
103 if (options.hasTimeoutSeconds()) {
104 predicted_timeout = static_cast<int>(options.timeoutSeconds());
105 }
106 134
107 mojo_options->adjusted_timeout = static_cast<double>( 135 if (options.hasExcludeCredentials()) {
108 std::max(kAdjustedTimeoutLowerInSeconds, 136 // Adds the excludeCredentials members
109 std::min(kAdjustedTimeoutUpperInSeconds, predicted_timeout))); 137 // (which are PublicKeyCredentialDescriptors)
110 138 for (const auto& descriptor : options.excludeCredentials()) {
111 if (options.hasExcludeList()) { 139 auto mojo_descriptor =
112 // Adds the excludeList members (which are ScopedCredentialDescriptors) 140 webauth::mojom::blink::PublicKeyCredentialDescriptor::New();
113 for (const auto& descriptor : options.excludeList()) { 141 mojo_descriptor->type = ConvertPublicKeyCredentialType(descriptor.type());
114 auto mojo_descriptor = ScopedCredentialDescriptor::New();
115 mojo_descriptor->type = ConvertScopedCredentialType(descriptor.type());
116 mojo_descriptor->id = ConvertBufferSource(descriptor.id()); 142 mojo_descriptor->id = ConvertBufferSource(descriptor.id());
117 for (const auto& transport : descriptor.transports()) 143 for (const auto& transport : descriptor.transports())
118 mojo_descriptor->transports.push_back(ConvertTransport(transport)); 144 mojo_descriptor->transports.push_back(ConvertTransport(transport));
119 mojo_options->exclude_list.push_back(std::move(mojo_descriptor)); 145 mojo_options->exclude_credentials.push_back(std::move(mojo_descriptor));
120 } 146 }
121 } 147 }
122 // TODO(kpaulhamus): add AuthenticationExtensions;
123 return mojo_options; 148 return mojo_options;
124 } 149 }
125 150
126 // TODO(kpaulhamus): Make this a TypeConverter
127 ScopedCredentialParametersPtr ConvertScopedCredentialParameter(
128 const blink::ScopedCredentialParameters parameter,
129 blink::ScriptPromiseResolver* resolver) {
130 auto mojo_parameter = ScopedCredentialParameters::New();
131 mojo_parameter->type = ConvertScopedCredentialType(parameter.type());
132 // TODO(kpaulhamus): add AlgorithmIdentifier
133 return mojo_parameter;
134 }
135
136 blink::DOMException* CreateExceptionFromStatus(AuthenticatorStatus status) { 151 blink::DOMException* CreateExceptionFromStatus(AuthenticatorStatus status) {
137 switch (status) { 152 switch (status) {
138 case AuthenticatorStatus::NOT_IMPLEMENTED: 153 case AuthenticatorStatus::NOT_IMPLEMENTED:
139 return blink::DOMException::Create(blink::kNotSupportedError, 154 return blink::DOMException::Create(blink::kNotSupportedError,
140 "Not implemented."); 155 "Not implemented.");
141 case AuthenticatorStatus::NOT_ALLOWED_ERROR: 156 case AuthenticatorStatus::NOT_ALLOWED_ERROR:
142 return blink::DOMException::Create(blink::kNotAllowedError, 157 return blink::DOMException::Create(blink::kNotAllowedError,
143 "Not allowed."); 158 "Not allowed.");
144 case AuthenticatorStatus::NOT_SUPPORTED_ERROR: 159 case AuthenticatorStatus::NOT_SUPPORTED_ERROR:
145 return blink::DOMException::Create( 160 return blink::DOMException::Create(
146 blink::kNotSupportedError, 161 blink::kNotSupportedError,
147 "Parameters for this operation are not supported."); 162 "Parameters for this operation are not supported.");
148 case AuthenticatorStatus::SECURITY_ERROR: 163 case AuthenticatorStatus::SECURITY_ERROR:
149 return blink::DOMException::Create(blink::kSecurityError, 164 return blink::DOMException::Create(blink::kSecurityError,
150 "The operation was not allowed."); 165 "The operation was not allowed.");
151 case AuthenticatorStatus::UNKNOWN_ERROR: 166 case AuthenticatorStatus::UNKNOWN_ERROR:
152 return blink::DOMException::Create(blink::kUnknownError, 167 return blink::DOMException::Create(blink::kUnknownError,
153 "Request failed."); 168 "Request failed.");
154 case AuthenticatorStatus::CANCELLED: 169 case AuthenticatorStatus::CANCELLED:
155 return blink::DOMException::Create(blink::kNotAllowedError, 170 return blink::DOMException::Create(blink::kNotAllowedError,
156 "User canceled the operation."); 171 "User canceled the operation.");
157 case AuthenticatorStatus::SUCCESS: 172 case AuthenticatorStatus::SUCCESS:
158 return nullptr; 173 return nullptr;
159 default: 174 default:
160 NOTREACHED(); 175 NOTREACHED();
161 return nullptr; 176 return nullptr;
162 } 177 }
163 } 178 }
179
164 } // namespace mojo 180 } // namespace mojo
165 181
166 namespace blink { 182 namespace blink {
167 WebAuthentication::WebAuthentication(LocalFrame& frame) 183
168 : ContextLifecycleObserver(frame.GetDocument()) {} 184 WebAuthentication::WebAuthentication(LocalFrame& frame) {
185 frame.GetInterfaceProvider().GetInterface(mojo::MakeRequest(&authenticator_));
186 authenticator_.set_connection_error_handler(ConvertToBaseCallback(
187 WTF::Bind(&WebAuthentication::OnAuthenticatorConnectionError,
188 WrapWeakPersistent(this))));
189 }
169 190
170 WebAuthentication::~WebAuthentication() { 191 WebAuthentication::~WebAuthentication() {
171 // |authenticator_| may still be valid but there should be no more 192 // |authenticator_| may still be valid but there should be no more
172 // outstanding requests because each holds a persistent handle to this object. 193 // outstanding requests because each holds a persistent handle to this object.
173 DCHECK(authenticator_requests_.IsEmpty()); 194 DCHECK(authenticator_requests_.IsEmpty());
174 } 195 }
175 196
176 ScriptPromise WebAuthentication::makeCredential( 197 ScriptPromise WebAuthentication::makeCredential(
177 ScriptState* script_state, 198 ScriptState* script_state,
178 const RelyingPartyAccount& account_information, 199 const MakeCredentialOptions& publicKey) {
179 const HeapVector<ScopedCredentialParameters> crypto_parameters,
180 const BufferSource& attestation_challenge,
181 ScopedCredentialOptions& options) {
182 ScriptPromise promise = RejectIfNotSupported(script_state); 200 ScriptPromise promise = RejectIfNotSupported(script_state);
183 if (!promise.IsEmpty()) 201 if (!promise.IsEmpty())
184 return promise; 202 return promise;
185 203
186 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); 204 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
187 205
188 Vector<uint8_t> buffer = mojo::ConvertBufferSource(attestation_challenge); 206 auto options = mojo::ConvertMakeCredentialOptions(publicKey);
189 auto opts = mojo::ConvertScopedCredentialOptions(options, resolver);
190 Vector<webauth::mojom::blink::ScopedCredentialParametersPtr> parameters;
191 for (const auto& parameter : crypto_parameters) {
192 if (parameter.hasType()) {
193 parameters.push_back(
194 mojo::ConvertScopedCredentialParameter(parameter, resolver));
195 }
196 }
197 auto account =
198 mojo::ConvertRelyingPartyAccount(account_information, resolver);
199 authenticator_requests_.insert(resolver); 207 authenticator_requests_.insert(resolver);
200 authenticator_->MakeCredential( 208 authenticator_->MakeCredential(
201 std::move(account), std::move(parameters), buffer, std::move(opts), 209 std::move(options), ConvertToBaseCallback(WTF::Bind(
202 ConvertToBaseCallback(WTF::Bind(&WebAuthentication::OnMakeCredential, 210 &WebAuthentication::OnMakeCredential,
203 WrapPersistent(this), 211 WrapPersistent(this), WrapPersistent(resolver))));
204 WrapPersistent(resolver))));
205 return resolver->Promise(); 212 return resolver->Promise();
206 } 213 }
207 214
208 ScriptPromise WebAuthentication::getAssertion( 215 ScriptPromise WebAuthentication::getAssertion(
209 ScriptState* script_state, 216 ScriptState* script_state,
210 const BufferSource& assertion_challenge, 217 const PublicKeyCredentialRequestOptions& publicKey) {
211 const AuthenticationAssertionOptions& options) {
212 NOTREACHED(); 218 NOTREACHED();
213 return ScriptPromise(); 219 return ScriptPromise();
214 } 220 }
215 221
216 void WebAuthentication::ContextDestroyed(ExecutionContext*) {
217 Cleanup();
218 }
219
220 void WebAuthentication::OnMakeCredential( 222 void WebAuthentication::OnMakeCredential(
221 ScriptPromiseResolver* resolver, 223 ScriptPromiseResolver* resolver,
222 webauth::mojom::blink::AuthenticatorStatus status, 224 webauth::mojom::blink::AuthenticatorStatus status,
223 webauth::mojom::blink::ScopedCredentialInfoPtr credential) { 225 webauth::mojom::blink::PublicKeyCredentialInfoPtr credential) {
224 if (!MarkRequestComplete(resolver)) 226 if (!MarkRequestComplete(resolver))
225 return; 227 return;
226 228
227 DOMException* error = mojo::CreateExceptionFromStatus(status); 229 DOMException* error = mojo::CreateExceptionFromStatus(status);
228 if (error) { 230 if (error) {
229 DCHECK(!credential); 231 DCHECK(!credential);
230 resolver->Reject(error); 232 resolver->Reject(error);
231 Cleanup(); 233 Cleanup();
232 return; 234 return;
233 } 235 }
234 236
235 if (credential->client_data.IsEmpty() || credential->attestation.IsEmpty()) { 237 if (credential->client_data_json.IsEmpty() ||
238 credential->response->attestation_object.IsEmpty()) {
236 resolver->Reject( 239 resolver->Reject(
237 DOMException::Create(kNotFoundError, "No credential returned.")); 240 DOMException::Create(kNotFoundError, "No credentials returned."));
238 return;
239 } 241 }
240 242
241 DOMArrayBuffer* clientDataBuffer = DOMArrayBuffer::Create( 243 DOMArrayBuffer* client_data_buffer = DOMArrayBuffer::Create(
242 static_cast<void*>(&credential->client_data.front()), 244 static_cast<void*>(&credential->client_data_json.front()),
243 credential->client_data.size()); 245 credential->client_data_json.size());
244 246
245 DOMArrayBuffer* attestationBuffer = DOMArrayBuffer::Create( 247 // Return AuthenticatorAttestationResponse
246 static_cast<void*>(&credential->attestation.front()), 248 DOMArrayBuffer* attestation_buffer = DOMArrayBuffer::Create(
247 credential->attestation.size()); 249 static_cast<void*>(&credential->response->attestation_object.front()),
250 credential->response->attestation_object.size());
248 251
249 ScopedCredentialInfo* scopedCredential = 252 AuthenticatorAttestationResponse* attestation_response =
250 ScopedCredentialInfo::Create(clientDataBuffer, attestationBuffer); 253 AuthenticatorAttestationResponse::Create(client_data_buffer,
251 resolver->Resolve(scopedCredential); 254 attestation_buffer);
255 resolver->Resolve(attestation_response);
252 } 256 }
253 257
254 ScriptPromise WebAuthentication::RejectIfNotSupported( 258 ScriptPromise WebAuthentication::RejectIfNotSupported(
255 ScriptState* script_state) { 259 ScriptState* script_state) {
260 LocalFrame* frame =
261 ToDocument(ExecutionContext::From(script_state))->GetFrame();
256 if (!authenticator_) { 262 if (!authenticator_) {
257 if (!GetFrame()) { 263 if (!frame) {
258 return ScriptPromise::RejectWithDOMException( 264 return ScriptPromise::RejectWithDOMException(
259 script_state, DOMException::Create(kNotSupportedError)); 265 script_state, DOMException::Create(kNotSupportedError));
260 } 266 }
261 GetFrame()->GetInterfaceProvider().GetInterface( 267 frame->GetInterfaceProvider().GetInterface(
262 mojo::MakeRequest(&authenticator_)); 268 mojo::MakeRequest(&authenticator_));
263 269
264 authenticator_.set_connection_error_handler(ConvertToBaseCallback( 270 authenticator_.set_connection_error_handler(ConvertToBaseCallback(
265 WTF::Bind(&WebAuthentication::OnAuthenticatorConnectionError, 271 WTF::Bind(&WebAuthentication::OnAuthenticatorConnectionError,
266 WrapWeakPersistent(this)))); 272 WrapWeakPersistent(this))));
267 } 273 }
268 return ScriptPromise(); 274 return ScriptPromise();
269 } 275 }
270 276
271 void WebAuthentication::OnAuthenticatorConnectionError() { 277 void WebAuthentication::OnAuthenticatorConnectionError() {
272 for (ScriptPromiseResolver* resolver : authenticator_requests_) { 278 for (ScriptPromiseResolver* resolver : authenticator_requests_) {
273 resolver->Reject( 279 resolver->Reject(
274 DOMException::Create(kNotFoundError, kNoAuthenticatorError)); 280 DOMException::Create(kNotFoundError, kNoAuthenticatorError));
275 } 281 }
276 Cleanup(); 282 Cleanup();
277 } 283 }
278 284
279 bool WebAuthentication::MarkRequestComplete(ScriptPromiseResolver* resolver) { 285 bool WebAuthentication::MarkRequestComplete(ScriptPromiseResolver* resolver) {
280 auto request_entry = authenticator_requests_.find(resolver); 286 auto request_entry = authenticator_requests_.find(resolver);
281 if (request_entry == authenticator_requests_.end()) 287 if (request_entry == authenticator_requests_.end())
282 return false; 288 return false;
283 authenticator_requests_.erase(request_entry); 289 authenticator_requests_.erase(request_entry);
284 return true; 290 return true;
285 } 291 }
286 292
287 DEFINE_TRACE(WebAuthentication) { 293 DEFINE_TRACE(WebAuthentication) {
288 visitor->Trace(authenticator_requests_); 294 visitor->Trace(authenticator_requests_);
289 ContextLifecycleObserver::Trace(visitor);
290 } 295 }
291 296
292 // Clears the promise resolver, timer, and closes the Mojo connection. 297 // Clears the promise resolver, timer, and closes the Mojo connection.
293 void WebAuthentication::Cleanup() { 298 void WebAuthentication::Cleanup() {
294 authenticator_.reset(); 299 authenticator_.reset();
295 authenticator_requests_.clear(); 300 authenticator_requests_.clear();
296 } 301 }
297 302
298 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698