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..a34990c1151406d5650e00b8946d3c96f2e71f96 100644 |
--- a/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
+++ b/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp |
@@ -7,6 +7,7 @@ |
#include <memory> |
#include <utility> |
#include "bindings/core/v8/Dictionary.h" |
+#include "bindings/core/v8/ExceptionState.h" |
#include "bindings/core/v8/ScriptPromise.h" |
#include "bindings/core/v8/ScriptPromiseResolver.h" |
#include "core/dom/DOMException.h" |
@@ -17,6 +18,7 @@ |
#include "core/frame/UseCounter.h" |
#include "core/page/FrameTree.h" |
#include "modules/credentialmanager/Credential.h" |
+#include "modules/credentialmanager/CredentialCreationOptions.h" |
#include "modules/credentialmanager/CredentialManagerClient.h" |
#include "modules/credentialmanager/CredentialRequestOptions.h" |
#include "modules/credentialmanager/FederatedCredential.h" |
@@ -202,6 +204,40 @@ ScriptPromise CredentialsContainer::store(ScriptState* script_state, |
return promise; |
} |
+ScriptPromise CredentialsContainer::create( |
+ ScriptState* script_state, |
+ const CredentialCreationOptions& options) { |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
+ ScriptPromise promise = resolver->Promise(); |
+ if (!CheckBoilerplate(resolver)) |
+ return promise; |
+ |
+ if (!(options.hasPassword() ^ options.hasFederated())) { |
Mike West
2017/05/16 09:21:00
XOR works today, as we only have two entities. Whe
jdoerrie
2017/05/16 13:29:56
Done.
|
+ resolver->Reject(DOMException::Create( |
+ kNotSupportedError, |
+ "Exactly one of password or federated must be provided.")); |
Mike West
2017/05/16 09:21:00
I'd rephrase this to something like, "Only 'passwo
jdoerrie
2017/05/16 13:29:56
Done.
|
+ return promise; |
+ } |
+ |
+ ExceptionState exception_state(script_state->GetIsolate(), |
+ ExceptionState::kConstructionContext, |
Mike West
2017/05/16 09:21:00
Nit: This isn't actually a constructor, it's just
jdoerrie
2017/05/16 13:29:56
Done.
|
+ "navigator.credentials", "create"); |
jdoerrie
2017/05/16 06:34:27
Here I was the most unsure about, I just looked fo
Mike West
2017/05/16 09:21:00
Nit: Please replace "navigator.credentials" with "
jdoerrie
2017/05/16 13:29:56
Done.
|
+ if (options.hasPassword()) { |
+ if (options.password().isPasswordCredentialData()) { |
+ resolver->Resolve(PasswordCredential::Create( |
+ options.password().getAsPasswordCredentialData(), exception_state)); |
+ } else { |
+ resolver->Resolve(PasswordCredential::Create( |
Mike West
2017/05/16 09:21:00
When you write tests, can you verify that passing
jdoerrie
2017/05/16 13:29:56
Done.
|
+ options.password().getAsHTMLFormElement(), exception_state)); |
+ } |
+ } else { |
+ resolver->Resolve( |
+ FederatedCredential::Create(options.federated(), exception_state)); |
Mike West
2017/05/16 09:20:59
When you write tests, can you verify that passing
jdoerrie
2017/05/16 13:29:56
Done.
|
+ } |
+ |
+ return promise; |
+} |
+ |
ScriptPromise CredentialsContainer::requireUserMediation( |
ScriptState* script_state) { |
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |