Index: third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
diff --git a/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp b/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
index ff35965185a0314d8dca14c145930f627e48eadc..0b19e558bd958c65f2a2a34b57076899a4017ff9 100644 |
--- a/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
+++ b/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
@@ -28,6 +28,7 @@ |
#include "public/platform/WebCredential.h" |
#include "public/platform/WebCredentialManagerClient.h" |
#include "public/platform/WebCredentialManagerError.h" |
+#include "public/platform/WebCredentialMediationRequirement.h" |
#include "public/platform/WebFederatedCredential.h" |
#include "public/platform/WebPasswordCredential.h" |
@@ -168,6 +169,18 @@ ScriptPromise CredentialsContainer::get( |
if (!CheckBoilerplate(resolver)) |
return promise; |
+ // Set the default mediation option if none is provided. |
vasilii
2017/05/18 16:16:12
I think it does more. Copying one to another.
jdoerrie
2017/05/19 09:03:18
Done.
|
+ if (!options.hasUnmediated() && !options.hasMediation()) { |
+ options.mediation() = "optional"; |
+ } else if (options.hasUnmediated() && !options.hasMediation()) { |
+ options.mediation() = options.unmediated() ? "silent" : "optional"; |
+ } else if (options.hasUnmediated() && options.hasMediation()) { |
+ resolver->Reject(DOMException::Create( |
+ kNotSupportedError, |
+ "At most one of 'unmediated' and 'mediation' can be specified.")); |
+ return promise; |
+ } |
+ |
Vector<KURL> providers; |
if (options.hasFederated() && options.federated().hasProviders()) { |
for (const auto& string : options.federated().providers()) { |
@@ -177,13 +190,25 @@ ScriptPromise CredentialsContainer::get( |
} |
} |
- UseCounter::Count(ExecutionContext::From(script_state), |
- options.unmediated() |
- ? UseCounter::kCredentialManagerGetWithoutUI |
- : UseCounter::kCredentialManagerGetWithUI); |
+ UseCounter::Feature feature; |
+ WebCredentialMediationRequirement mediation; |
+ |
+ if (options.mediation() == "silent") { |
+ feature = UseCounter::kCredentialManagerGetMediationSilent; |
+ mediation = WebCredentialMediationRequirement::kSilent; |
+ } else if (options.mediation() == "optional") { |
+ feature = UseCounter::kCredentialManagerGetMediationOptional; |
+ mediation = WebCredentialMediationRequirement::kOptional; |
+ } else { |
+ DCHECK_EQ("required", options.mediation()); |
+ feature = UseCounter::kCredentialManagerGetMediationRequired; |
+ mediation = WebCredentialMediationRequirement::kRequired; |
+ } |
+ |
+ UseCounter::Count(ExecutionContext::From(script_state), feature); |
CredentialManagerClient::From(ExecutionContext::From(script_state)) |
- ->DispatchGet(options.unmediated(), options.password(), providers, |
+ ->DispatchGet(mediation, options.password(), providers, |
new RequestCallbacks(resolver)); |
return promise; |
} |