OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <ostream> | 6 #include <ostream> |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 target->SetString("federation_origin", form.federation_origin.Serialize()); | 59 target->SetString("federation_origin", form.federation_origin.Serialize()); |
60 target->SetBoolean("skip_next_zero_click", form.skip_zero_click); | 60 target->SetBoolean("skip_next_zero_click", form.skip_zero_click); |
61 std::ostringstream layout_string_stream; | 61 std::ostringstream layout_string_stream; |
62 layout_string_stream << form.layout; | 62 layout_string_stream << form.layout; |
63 target->SetString("layout", layout_string_stream.str()); | 63 target->SetString("layout", layout_string_stream.str()); |
64 target->SetBoolean("was_parsed_using_autofill_predictions", | 64 target->SetBoolean("was_parsed_using_autofill_predictions", |
65 form.was_parsed_using_autofill_predictions); | 65 form.was_parsed_using_autofill_predictions); |
66 target->SetString("affiliated_web_realm", form.affiliated_web_realm); | 66 target->SetString("affiliated_web_realm", form.affiliated_web_realm); |
67 target->SetBoolean("does_look_like_signup_form", | 67 target->SetBoolean("does_look_like_signup_form", |
68 form.does_look_like_signup_form); | 68 form.does_look_like_signup_form); |
| 69 std::ostringstream submission_event_string_stream; |
| 70 submission_event_string_stream << form.submission_event; |
| 71 target->SetString("submission_event", submission_event_string_stream.str()); |
69 } | 72 } |
70 | 73 |
71 } // namespace | 74 } // namespace |
72 | 75 |
73 PasswordForm::PasswordForm() | 76 PasswordForm::PasswordForm() |
74 : scheme(SCHEME_HTML), | 77 : scheme(SCHEME_HTML), |
75 username_marked_by_site(false), | 78 username_marked_by_site(false), |
76 password_value_is_default(false), | 79 password_value_is_default(false), |
77 new_password_value_is_default(false), | 80 new_password_value_is_default(false), |
78 new_password_marked_by_site(false), | 81 new_password_marked_by_site(false), |
79 preferred(false), | 82 preferred(false), |
80 blacklisted_by_user(false), | 83 blacklisted_by_user(false), |
81 type(TYPE_MANUAL), | 84 type(TYPE_MANUAL), |
82 times_used(0), | 85 times_used(0), |
83 generation_upload_status(NO_SIGNAL_SENT), | 86 generation_upload_status(NO_SIGNAL_SENT), |
84 skip_zero_click(false), | 87 skip_zero_click(false), |
85 layout(Layout::LAYOUT_OTHER), | 88 layout(Layout::LAYOUT_OTHER), |
86 was_parsed_using_autofill_predictions(false), | 89 was_parsed_using_autofill_predictions(false), |
87 is_public_suffix_match(false), | 90 is_public_suffix_match(false), |
88 is_affiliation_based_match(false), | 91 is_affiliation_based_match(false), |
89 does_look_like_signup_form(false) {} | 92 does_look_like_signup_form(false), |
| 93 submission_event(SubmissionIndicatorEvent::NONE) {} |
90 | 94 |
91 PasswordForm::PasswordForm(const PasswordForm& other) = default; | 95 PasswordForm::PasswordForm(const PasswordForm& other) = default; |
92 | 96 |
93 PasswordForm::~PasswordForm() = default; | 97 PasswordForm::~PasswordForm() = default; |
94 | 98 |
95 bool PasswordForm::IsPossibleChangePasswordForm() const { | 99 bool PasswordForm::IsPossibleChangePasswordForm() const { |
96 return !new_password_element.empty() && | 100 return !new_password_element.empty() && |
97 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; | 101 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; |
98 } | 102 } |
99 | 103 |
(...skipping 23 matching lines...) Expand all Loading... |
123 display_name == form.display_name && icon_url == form.icon_url && | 127 display_name == form.display_name && icon_url == form.icon_url && |
124 // We compare the serialization of the origins here, as we want unique | 128 // We compare the serialization of the origins here, as we want unique |
125 // origins to compare as '=='. | 129 // origins to compare as '=='. |
126 federation_origin.Serialize() == form.federation_origin.Serialize() && | 130 federation_origin.Serialize() == form.federation_origin.Serialize() && |
127 skip_zero_click == form.skip_zero_click && layout == form.layout && | 131 skip_zero_click == form.skip_zero_click && layout == form.layout && |
128 was_parsed_using_autofill_predictions == | 132 was_parsed_using_autofill_predictions == |
129 form.was_parsed_using_autofill_predictions && | 133 form.was_parsed_using_autofill_predictions && |
130 is_public_suffix_match == form.is_public_suffix_match && | 134 is_public_suffix_match == form.is_public_suffix_match && |
131 is_affiliation_based_match == form.is_affiliation_based_match && | 135 is_affiliation_based_match == form.is_affiliation_based_match && |
132 affiliated_web_realm == form.affiliated_web_realm && | 136 affiliated_web_realm == form.affiliated_web_realm && |
133 does_look_like_signup_form == form.does_look_like_signup_form; | 137 does_look_like_signup_form == form.does_look_like_signup_form && |
| 138 submission_event == form.submission_event; |
134 } | 139 } |
135 | 140 |
136 bool PasswordForm::operator!=(const PasswordForm& form) const { | 141 bool PasswordForm::operator!=(const PasswordForm& form) const { |
137 return !operator==(form); | 142 return !operator==(form); |
138 } | 143 } |
139 | 144 |
140 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, | 145 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, |
141 const PasswordForm& right) { | 146 const PasswordForm& right) { |
142 return (left.signon_realm == right.signon_realm && | 147 return (left.signon_realm == right.signon_realm && |
143 left.origin == right.origin && | 148 left.origin == right.origin && |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 base::JSONWriter::WriteWithOptions( | 216 base::JSONWriter::WriteWithOptions( |
212 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); | 217 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); |
213 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); | 218 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); |
214 return os << "PasswordForm(" << form_as_string << ")"; | 219 return os << "PasswordForm(" << form_as_string << ")"; |
215 } | 220 } |
216 | 221 |
217 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { | 222 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { |
218 return os << "&" << *form; | 223 return os << "&" << *form; |
219 } | 224 } |
220 | 225 |
| 226 std::ostream& operator<<( |
| 227 std::ostream& os, |
| 228 PasswordForm::SubmissionIndicatorEvent submission_event) { |
| 229 switch (submission_event) { |
| 230 case PasswordForm::SubmissionIndicatorEvent::HTML_FORM_SUBMISSION: |
| 231 os << "HTML_FORM_SUBMISSION"; |
| 232 break; |
| 233 case PasswordForm::SubmissionIndicatorEvent::SAME_DOCUMENT_NAVIGATION: |
| 234 os << "SAME_DOCUMENT_NAVIGATION"; |
| 235 break; |
| 236 case PasswordForm::SubmissionIndicatorEvent::XHR_SUCCEEDED: |
| 237 os << "XHR_SUCCEEDED"; |
| 238 break; |
| 239 case PasswordForm::SubmissionIndicatorEvent::FRAME_DETACHED: |
| 240 os << "FRAME_DETACHED"; |
| 241 break; |
| 242 case PasswordForm::SubmissionIndicatorEvent::MANUAL_SAVE: |
| 243 os << "MANUAL_SAVE"; |
| 244 break; |
| 245 default: |
| 246 os << "NO_SUBMISSION"; |
| 247 break; |
| 248 } |
| 249 return os; |
| 250 } |
| 251 |
221 } // namespace autofill | 252 } // namespace autofill |
OLD | NEW |