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

Unified Diff: Source/modules/credentialmanager/PasswordCredential.cpp

Issue 1317043003: CREDENTIAL: Add 'PasswordCredential::toFormData()' (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@opaque-formdata
Patch Set: webexposed Created 5 years, 3 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: Source/modules/credentialmanager/PasswordCredential.cpp
diff --git a/Source/modules/credentialmanager/PasswordCredential.cpp b/Source/modules/credentialmanager/PasswordCredential.cpp
index 002d973529b62b1d1cb3247b245837439dadc53b..68bc40a079ca1bf4c45199434bd7955dcddf042a 100644
--- a/Source/modules/credentialmanager/PasswordCredential.cpp
+++ b/Source/modules/credentialmanager/PasswordCredential.cpp
@@ -5,9 +5,13 @@
#include "config.h"
#include "modules/credentialmanager/PasswordCredential.h"
+#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/ExecutionContext.h"
#include "core/html/DOMFormData.h"
+#include "modules/credentialmanager/FormDataOptions.h"
#include "platform/credentialmanager/PlatformPasswordCredential.h"
+#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/WebCredential.h"
#include "public/platform/WebPasswordCredential.h"
@@ -33,10 +37,21 @@ PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
PasswordCredential::PasswordCredential(const String& id, const String& password, const String& name, const KURL& icon)
: Credential(PlatformPasswordCredential::create(id, password, name, icon))
- , m_formData(DOMFormData::create())
{
- m_formData->append("username", id);
- m_formData->append("password", password);
+}
+
+DOMFormData* PasswordCredential::toFormData(ScriptState* scriptState, const FormDataOptions& options)
+{
+ DOMFormData* fd = DOMFormData::create();
+
+ String errorMessage;
+ if (!scriptState->executionContext()->isPrivilegedContext(errorMessage))
+ return fd;
+
+ fd->append(options.idName(), id());
+ fd->append(options.passwordName(), password());
+ fd->makeOpaque();
+ return fd;
}
const String& PasswordCredential::password() const
@@ -46,7 +61,6 @@ const String& PasswordCredential::password() const
DEFINE_TRACE(PasswordCredential)
{
- visitor->trace(m_formData);
Credential::trace(visitor);
}
« no previous file with comments | « Source/modules/credentialmanager/PasswordCredential.h ('k') | Source/modules/credentialmanager/PasswordCredential.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698