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

Unified Diff: components/autofill/core/common/form_data.cc

Issue 980583002: Serialize form_data in Gnome keyring password store service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: components/autofill/core/common/form_data.cc
diff --git a/components/autofill/core/common/form_data.cc b/components/autofill/core/common/form_data.cc
index 2edd5ecc526009dc32eea6108436e514e0720a69..db441f9a07c7fb22174ef0e9dd73b33e66bf4d82 100644
--- a/components/autofill/core/common/form_data.cc
+++ b/components/autofill/core/common/form_data.cc
@@ -4,6 +4,7 @@
#include "components/autofill/core/common/form_data.h"
+#include "base/base64.h"
#include "base/pickle.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -124,6 +125,14 @@ void SerializeFormData(const FormData& form_data, Pickle* pickle) {
pickle->WriteBool(form_data.is_form_tag);
}
+void SerializeFormData(const FormData& form_data, std::string* output) {
+ Pickle pickle;
+ SerializeFormData(form_data, &pickle);
+ Base64Encode(
+ base::StringPiece(static_cast<const char*>(pickle.data()), pickle.size()),
+ output);
+}
+
bool DeserializeFormData(PickleIterator* iter, FormData* form_data) {
int version;
if (!iter->ReadInt(&version)) {
@@ -169,4 +178,14 @@ bool DeserializeFormData(PickleIterator* iter, FormData* form_data) {
return true;
}
+bool DeserializeFormData(const char* input, FormData* form_data) {
Garrett Casto 2015/03/04 18:05:31 I would just take a StringPiece in the function in
dvadym 2015/03/05 10:38:19 Done.
+ if (input == nullptr || input[0] == '\0')
+ return false;
+ std::string pickle_data;
+ Base64Decode(base::StringPiece(input), &pickle_data);
+ Pickle pickle(pickle_data.data(), pickle_data.size());
+ PickleIterator iter(pickle);
+ return DeserializeFormData(&iter, form_data);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698