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 <ostream> | 5 #include <ostream> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/autofill/core/common/password_form.h" | 13 #include "components/autofill/core/common/password_form.h" |
14 | 14 |
15 namespace autofill { | 15 namespace autofill { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Serializes a PasswordForm to a JSON object. Used only for logging in tests. | 19 // Serializes a PasswordForm to a JSON object. Used only for logging in tests. |
20 void PasswordFormToJSON(const PasswordForm& form, | 20 void PasswordFormToJSON(const PasswordForm& form, |
21 base::DictionaryValue* target) { | 21 base::DictionaryValue* target) { |
22 target->SetInteger("scheme", form.scheme); | 22 target->SetInteger("scheme", form.scheme); |
23 target->SetString("signon_realm", form.signon_realm); | 23 target->SetString("signon_realm", form.signon_realm); |
24 target->SetBoolean("is_public_suffix_match", form.is_public_suffix_match); | 24 target->SetBoolean("is_public_suffix_match", form.is_public_suffix_match); |
| 25 target->SetBoolean("is_affiliation_based_match", |
| 26 form.is_affiliation_based_match); |
25 target->SetString("origin", form.origin.possibly_invalid_spec()); | 27 target->SetString("origin", form.origin.possibly_invalid_spec()); |
26 target->SetString("action", form.action.possibly_invalid_spec()); | 28 target->SetString("action", form.action.possibly_invalid_spec()); |
27 target->SetString("submit_element", form.submit_element); | 29 target->SetString("submit_element", form.submit_element); |
28 target->SetString("username_elem", form.username_element); | 30 target->SetString("username_elem", form.username_element); |
29 target->SetBoolean("username_marked_by_site", form.username_marked_by_site); | 31 target->SetBoolean("username_marked_by_site", form.username_marked_by_site); |
30 target->SetString("username_value", form.username_value); | 32 target->SetString("username_value", form.username_value); |
31 target->SetString("password_elem", form.password_element); | 33 target->SetString("password_elem", form.password_element); |
32 target->SetString("password_value", form.password_value); | 34 target->SetString("password_value", form.password_value); |
33 target->SetBoolean("password_value_is_default", | 35 target->SetBoolean("password_value_is_default", |
34 form.password_value_is_default); | 36 form.password_value_is_default); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 preferred(false), | 78 preferred(false), |
77 blacklisted_by_user(false), | 79 blacklisted_by_user(false), |
78 type(TYPE_MANUAL), | 80 type(TYPE_MANUAL), |
79 times_used(0), | 81 times_used(0), |
80 generation_upload_status(NO_SIGNAL_SENT), | 82 generation_upload_status(NO_SIGNAL_SENT), |
81 skip_zero_click(false), | 83 skip_zero_click(false), |
82 layout(Layout::LAYOUT_OTHER), | 84 layout(Layout::LAYOUT_OTHER), |
83 was_parsed_using_autofill_predictions(false), | 85 was_parsed_using_autofill_predictions(false), |
84 is_alive(true), | 86 is_alive(true), |
85 is_public_suffix_match(false), | 87 is_public_suffix_match(false), |
86 is_affiliated(false) {} | 88 is_affiliation_based_match(false) {} |
87 | 89 |
88 PasswordForm::~PasswordForm() { | 90 PasswordForm::~PasswordForm() { |
89 CHECK(is_alive); | 91 CHECK(is_alive); |
90 is_alive = false; | 92 is_alive = false; |
91 } | 93 } |
92 | 94 |
93 bool PasswordForm::IsPossibleChangePasswordForm() const { | 95 bool PasswordForm::IsPossibleChangePasswordForm() const { |
94 return !new_password_element.empty() && | 96 return !new_password_element.empty() && |
95 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; | 97 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; |
96 } | 98 } |
(...skipping 19 matching lines...) Expand all Loading... |
116 date_created == form.date_created && date_synced == form.date_synced && | 118 date_created == form.date_created && date_synced == form.date_synced && |
117 blacklisted_by_user == form.blacklisted_by_user && type == form.type && | 119 blacklisted_by_user == form.blacklisted_by_user && type == form.type && |
118 times_used == form.times_used && | 120 times_used == form.times_used && |
119 form_data.SameFormAs(form.form_data) && | 121 form_data.SameFormAs(form.form_data) && |
120 generation_upload_status == form.generation_upload_status && | 122 generation_upload_status == form.generation_upload_status && |
121 display_name == form.display_name && icon_url == form.icon_url && | 123 display_name == form.display_name && icon_url == form.icon_url && |
122 federation_url == form.federation_url && | 124 federation_url == form.federation_url && |
123 skip_zero_click == form.skip_zero_click && layout == form.layout && | 125 skip_zero_click == form.skip_zero_click && layout == form.layout && |
124 was_parsed_using_autofill_predictions == | 126 was_parsed_using_autofill_predictions == |
125 form.was_parsed_using_autofill_predictions && | 127 form.was_parsed_using_autofill_predictions && |
126 is_public_suffix_match == form.is_public_suffix_match; | 128 is_public_suffix_match == form.is_public_suffix_match && |
| 129 is_affiliation_based_match == form.is_affiliation_based_match; |
127 } | 130 } |
128 | 131 |
129 bool PasswordForm::operator!=(const PasswordForm& form) const { | 132 bool PasswordForm::operator!=(const PasswordForm& form) const { |
130 return !operator==(form); | 133 return !operator==(form); |
131 } | 134 } |
132 | 135 |
133 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, | 136 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, |
134 const PasswordForm& right) { | 137 const PasswordForm& right) { |
135 return (left.signon_realm == right.signon_realm && | 138 return (left.signon_realm == right.signon_realm && |
136 left.origin == right.origin && | 139 left.origin == right.origin && |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); | 197 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); |
195 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); | 198 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); |
196 return os << "PasswordForm(" << form_as_string << ")"; | 199 return os << "PasswordForm(" << form_as_string << ")"; |
197 } | 200 } |
198 | 201 |
199 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { | 202 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { |
200 return os << "&" << *form; | 203 return os << "&" << *form; |
201 } | 204 } |
202 | 205 |
203 } // namespace autofill | 206 } // namespace autofill |
OLD | NEW |