Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/credentialmanager/CredentialsContainer.h" | 5 #include "modules/credentialmanager/CredentialsContainer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/Dictionary.h" | 9 #include "bindings/core/v8/Dictionary.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "modules/credentialmanager/CredentialRequestOptions.h" | 21 #include "modules/credentialmanager/CredentialRequestOptions.h" |
| 22 #include "modules/credentialmanager/FederatedCredential.h" | 22 #include "modules/credentialmanager/FederatedCredential.h" |
| 23 #include "modules/credentialmanager/FederatedCredentialRequestOptions.h" | 23 #include "modules/credentialmanager/FederatedCredentialRequestOptions.h" |
| 24 #include "modules/credentialmanager/PasswordCredential.h" | 24 #include "modules/credentialmanager/PasswordCredential.h" |
| 25 #include "platform/weborigin/SecurityOrigin.h" | 25 #include "platform/weborigin/SecurityOrigin.h" |
| 26 #include "platform/wtf/PtrUtil.h" | 26 #include "platform/wtf/PtrUtil.h" |
| 27 #include "public/platform/Platform.h" | 27 #include "public/platform/Platform.h" |
| 28 #include "public/platform/WebCredential.h" | 28 #include "public/platform/WebCredential.h" |
| 29 #include "public/platform/WebCredentialManagerClient.h" | 29 #include "public/platform/WebCredentialManagerClient.h" |
| 30 #include "public/platform/WebCredentialManagerError.h" | 30 #include "public/platform/WebCredentialManagerError.h" |
| 31 #include "public/platform/WebCredentialMediationRequirement.h" | |
| 31 #include "public/platform/WebFederatedCredential.h" | 32 #include "public/platform/WebFederatedCredential.h" |
| 32 #include "public/platform/WebPasswordCredential.h" | 33 #include "public/platform/WebPasswordCredential.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 static void RejectDueToCredentialManagerError( | 37 static void RejectDueToCredentialManagerError( |
| 37 ScriptPromiseResolver* resolver, | 38 ScriptPromiseResolver* resolver, |
| 38 WebCredentialManagerError reason) { | 39 WebCredentialManagerError reason) { |
| 39 switch (reason) { | 40 switch (reason) { |
| 40 case kWebCredentialManagerDisabledError: | 41 case kWebCredentialManagerDisabledError: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 171 |
| 171 Vector<KURL> providers; | 172 Vector<KURL> providers; |
| 172 if (options.hasFederated() && options.federated().hasProviders()) { | 173 if (options.hasFederated() && options.federated().hasProviders()) { |
| 173 for (const auto& string : options.federated().providers()) { | 174 for (const auto& string : options.federated().providers()) { |
| 174 KURL url = KURL(KURL(), string); | 175 KURL url = KURL(KURL(), string); |
| 175 if (url.IsValid()) | 176 if (url.IsValid()) |
| 176 providers.push_back(std::move(url)); | 177 providers.push_back(std::move(url)); |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 | 180 |
| 180 UseCounter::Count(ExecutionContext::From(script_state), | 181 // Set the default mediation option if none is provided. |
| 181 options.unmediated() | 182 if (!options.hasUnmediated() && !options.hasMediation()) { |
| 182 ? UseCounter::kCredentialManagerGetWithoutUI | 183 options.mediation() = "optional"; |
| 183 : UseCounter::kCredentialManagerGetWithUI); | 184 } else if (options.hasUnmediated() && !options.hasMediation()) { |
| 185 options.mediation() = options.unmediated() ? "silent" : "optional"; | |
| 186 } else if (options.hasUnmediated() && options.hasMediation()) { | |
| 187 // Show a warning that unmediated will be ignored? | |
|
vasilii
2017/05/18 12:34:03
Should be an exception I think.
jdoerrie
2017/05/18 14:57:25
Done.
| |
| 188 } | |
| 189 | |
| 190 UseCounter::Feature feature; | |
| 191 WebCredentialMediationRequirement mediation; | |
| 192 | |
| 193 if (options.mediation() == "silent") { | |
| 194 feature = UseCounter::kCredentialManagerGetMediationSilent; | |
| 195 mediation = kWebCredentialManagerMediationRequirementSilent; | |
| 196 } else if (options.mediation() == "optional") { | |
| 197 feature = UseCounter::kCredentialManagerGetMediationOptional; | |
| 198 mediation = kWebCredentialManagerMediationRequirementOptional; | |
| 199 } else { | |
|
vasilii
2017/05/18 12:34:03
What about an exception in case of random trash st
jdoerrie
2017/05/18 14:57:25
The generated code already includes a call to IsVa
| |
| 200 feature = UseCounter::kCredentialManagerGetMediationRequired; | |
| 201 mediation = kWebCredentialManagerMediationRequirementRequired; | |
| 202 } | |
| 203 | |
| 204 UseCounter::Count(ExecutionContext::From(script_state), feature); | |
| 184 | 205 |
| 185 CredentialManagerClient::From(ExecutionContext::From(script_state)) | 206 CredentialManagerClient::From(ExecutionContext::From(script_state)) |
| 186 ->DispatchGet(options.unmediated(), options.password(), providers, | 207 ->DispatchGet(mediation, options.password(), providers, |
| 187 new RequestCallbacks(resolver)); | 208 new RequestCallbacks(resolver)); |
| 188 return promise; | 209 return promise; |
| 189 } | 210 } |
| 190 | 211 |
| 191 ScriptPromise CredentialsContainer::store(ScriptState* script_state, | 212 ScriptPromise CredentialsContainer::store(ScriptState* script_state, |
| 192 Credential* credential) { | 213 Credential* credential) { |
| 193 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 214 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 194 ScriptPromise promise = resolver->Promise(); | 215 ScriptPromise promise = resolver->Promise(); |
| 195 if (!CheckBoilerplate(resolver)) | 216 if (!CheckBoilerplate(resolver)) |
| 196 return promise; | 217 return promise; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 208 ScriptPromise promise = resolver->Promise(); | 229 ScriptPromise promise = resolver->Promise(); |
| 209 if (!CheckBoilerplate(resolver)) | 230 if (!CheckBoilerplate(resolver)) |
| 210 return promise; | 231 return promise; |
| 211 | 232 |
| 212 CredentialManagerClient::From(ExecutionContext::From(script_state)) | 233 CredentialManagerClient::From(ExecutionContext::From(script_state)) |
| 213 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); | 234 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); |
| 214 return promise; | 235 return promise; |
| 215 } | 236 } |
| 216 | 237 |
| 217 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |