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

Side by Side Diff: components/autofill/core/common/form_data.cc

Issue 365783002: Autofill: don't require POST method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove method_ member Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/common/form_data.h" 5 #include "components/autofill/core/common/form_data.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/common/form_field_data.h" 10 #include "components/autofill/core/common/form_field_data.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 FormData::FormData() 53 FormData::FormData()
54 : user_submitted(false) { 54 : user_submitted(false) {
55 } 55 }
56 56
57 FormData::FormData(const FormData& data) 57 FormData::FormData(const FormData& data)
58 : name(data.name), 58 : name(data.name),
59 method(data.method),
60 origin(data.origin), 59 origin(data.origin),
61 action(data.action), 60 action(data.action),
62 user_submitted(data.user_submitted), 61 user_submitted(data.user_submitted),
63 fields(data.fields) { 62 fields(data.fields) {
64 } 63 }
65 64
66 FormData::~FormData() { 65 FormData::~FormData() {
67 } 66 }
68 67
69 bool FormData::operator==(const FormData& form) const { 68 bool FormData::operator==(const FormData& form) const {
70 return name == form.name && 69 return name == form.name &&
71 StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
72 origin == form.origin && 70 origin == form.origin &&
73 action == form.action && 71 action == form.action &&
74 user_submitted == form.user_submitted && 72 user_submitted == form.user_submitted &&
75 fields == form.fields; 73 fields == form.fields;
76 } 74 }
77 75
78 bool FormData::operator!=(const FormData& form) const { 76 bool FormData::operator!=(const FormData& form) const {
79 return !operator==(form); 77 return !operator==(form);
80 } 78 }
81 79
82 bool FormData::operator<(const FormData& form) const { 80 bool FormData::operator<(const FormData& form) const {
83 if (name != form.name) 81 if (name != form.name)
84 return name < form.name; 82 return name < form.name;
85 if (StringToLowerASCII(method) != StringToLowerASCII(form.method))
86 return StringToLowerASCII(method) < StringToLowerASCII(form.method);
87 if (origin != form.origin) 83 if (origin != form.origin)
88 return origin < form.origin; 84 return origin < form.origin;
89 if (action != form.action) 85 if (action != form.action)
90 return action < form.action; 86 return action < form.action;
91 if (user_submitted != form.user_submitted) 87 if (user_submitted != form.user_submitted)
92 return user_submitted < form.user_submitted; 88 return user_submitted < form.user_submitted;
93 return fields < form.fields; 89 return fields < form.fields;
94 } 90 }
95 91
96 std::ostream& operator<<(std::ostream& os, const FormData& form) { 92 std::ostream& operator<<(std::ostream& os, const FormData& form) {
97 os << base::UTF16ToUTF8(form.name) << " " 93 os << base::UTF16ToUTF8(form.name) << " "
98 << base::UTF16ToUTF8(form.method) << " "
99 << form.origin << " " 94 << form.origin << " "
100 << form.action << " " 95 << form.action << " "
101 << form.user_submitted << " " 96 << form.user_submitted << " "
102 << "Fields:"; 97 << "Fields:";
103 for (size_t i = 0; i < form.fields.size(); ++i) { 98 for (size_t i = 0; i < form.fields.size(); ++i) {
104 os << form.fields[i] << ","; 99 os << form.fields[i] << ",";
105 } 100 }
106 return os; 101 return os;
107 } 102 }
108 103
109 void SerializeFormData(const FormData& form_data, Pickle* pickle) { 104 void SerializeFormData(const FormData& form_data, Pickle* pickle) {
110 pickle->WriteInt(kPickleVersion); 105 pickle->WriteInt(kPickleVersion);
111 pickle->WriteString16(form_data.name); 106 pickle->WriteString16(form_data.name);
112 pickle->WriteString16(form_data.method);
113 pickle->WriteString(form_data.origin.spec()); 107 pickle->WriteString(form_data.origin.spec());
114 pickle->WriteString(form_data.action.spec()); 108 pickle->WriteString(form_data.action.spec());
115 pickle->WriteBool(form_data.user_submitted); 109 pickle->WriteBool(form_data.user_submitted);
116 SerializeFormFieldDataVector(form_data.fields, pickle); 110 SerializeFormFieldDataVector(form_data.fields, pickle);
117 } 111 }
118 112
119 bool DeserializeFormData(PickleIterator* iter, FormData* form_data) { 113 bool DeserializeFormData(PickleIterator* iter, FormData* form_data) {
120 int version; 114 int version;
121 if (!iter->ReadInt(&version)) { 115 if (!iter->ReadInt(&version)) {
122 LOG(ERROR) << "Bad pickle of FormData, no version present"; 116 LOG(ERROR) << "Bad pickle of FormData, no version present";
123 return false; 117 return false;
124 } 118 }
125 119
126 switch (version) { 120 switch (version) {
127 case 1: { 121 case 1: {
128 if (!iter->ReadString16(&form_data->name) || 122 if (!iter->ReadString16(&form_data->name) ||
129 !iter->ReadString16(&form_data->method) ||
130 !ReadGURL(iter, &form_data->origin) || 123 !ReadGURL(iter, &form_data->origin) ||
131 !ReadGURL(iter, &form_data->action) || 124 !ReadGURL(iter, &form_data->action) ||
132 !iter->ReadBool(&form_data->user_submitted) || 125 !iter->ReadBool(&form_data->user_submitted) ||
133 !DeserializeFormFieldDataVector(iter, &form_data->fields)) { 126 !DeserializeFormFieldDataVector(iter, &form_data->fields)) {
134 LOG(ERROR) << "Could not deserialize FormData from pickle"; 127 LOG(ERROR) << "Could not deserialize FormData from pickle";
135 return false; 128 return false;
136 } 129 }
137 break; 130 break;
138 } 131 }
139 default: { 132 default: {
140 LOG(ERROR) << "Unknown FormData pickle version " << version; 133 LOG(ERROR) << "Unknown FormData pickle version " << version;
141 return false; 134 return false;
142 } 135 }
143 } 136 }
144 return true; 137 return true;
145 } 138 }
146 139
147 } // namespace autofill 140 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/common/form_data.h ('k') | components/autofill/core/common/form_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698