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

Unified Diff: third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp

Issue 2864493003: Deprecate CredentialRequestOptions.unmediated in favor mediation enum (Closed)
Patch Set: kOptional, no RuntimeEnabled and Test Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
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..778c0f7b82becf360c1bad609e6521fd4285b993 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,21 @@ ScriptPromise CredentialsContainer::get(
if (!CheckBoilerplate(resolver))
return promise;
+ // Set the default mediation option if none is provided. Also checks that at
+ // most one of 'unmediated' and 'mediation' is provided and sets 'mediation'
+ // appropriately when only 'unmediated' is set.
+ // TODO(http://crbug.com/715077): Remove this when 'unmediated' is removed.
+ if (!options.hasUnmediated() && !options.hasMediation()) {
+ options.mediation() = "optional";
Mike West 2017/05/19 09:42:35 Nit: Assigning to `mediation()` doesn't seem like
jdoerrie 2017/05/19 09:59:51 Yeah, this needs to be `setMediation`. It might be
+ } 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."));
Mike West 2017/05/19 09:42:35 I don't think this is what we agreed on. I thought
jdoerrie 2017/05/19 09:59:51 Agreed, fair point. Should we just silently ignore
+ return promise;
+ }
+
Vector<KURL> providers;
if (options.hasFederated() && options.federated().hasProviders()) {
for (const auto& string : options.federated().providers()) {
@@ -177,13 +193,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;
}

Powered by Google App Engine
This is Rietveld 408576698