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->SetString("signon_realm", form.signon_realm); | |
25 target->SetString("original_signon_realm", form.original_signon_realm); | |
26 target->SetString("origin", form.origin.possibly_invalid_spec()); | 24 target->SetString("origin", form.origin.possibly_invalid_spec()); |
27 target->SetString("action", form.action.possibly_invalid_spec()); | 25 target->SetString("action", form.action.possibly_invalid_spec()); |
28 target->SetString("submit_element", form.submit_element); | 26 target->SetString("submit_element", form.submit_element); |
29 target->SetString("username_elem", form.username_element); | 27 target->SetString("username_elem", form.username_element); |
30 target->SetBoolean("username_marked_by_site", form.username_marked_by_site); | 28 target->SetBoolean("username_marked_by_site", form.username_marked_by_site); |
31 target->SetString("username_value", form.username_value); | 29 target->SetString("username_value", form.username_value); |
32 target->SetString("password_elem", form.password_element); | 30 target->SetString("password_elem", form.password_element); |
33 target->SetString("password_value", form.password_value); | 31 target->SetString("password_value", form.password_value); |
34 target->SetBoolean("password_value_is_default", | 32 target->SetBoolean("password_value_is_default", |
35 form.password_value_is_default); | 33 form.password_value_is_default); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 new_password_marked_by_site(false), | 73 new_password_marked_by_site(false), |
76 ssl_valid(false), | 74 ssl_valid(false), |
77 preferred(false), | 75 preferred(false), |
78 blacklisted_by_user(false), | 76 blacklisted_by_user(false), |
79 type(TYPE_MANUAL), | 77 type(TYPE_MANUAL), |
80 times_used(0), | 78 times_used(0), |
81 generation_upload_status(NO_SIGNAL_SENT), | 79 generation_upload_status(NO_SIGNAL_SENT), |
82 skip_zero_click(false), | 80 skip_zero_click(false), |
83 layout(Layout::LAYOUT_OTHER), | 81 layout(Layout::LAYOUT_OTHER), |
84 was_parsed_using_autofill_predictions(false), | 82 was_parsed_using_autofill_predictions(false), |
85 is_alive(true) { | 83 is_alive(true), |
86 } | 84 is_public_suffix_match(false) {} |
87 | 85 |
88 PasswordForm::~PasswordForm() { | 86 PasswordForm::~PasswordForm() { |
89 CHECK(is_alive); | 87 CHECK(is_alive); |
90 is_alive = false; | 88 is_alive = false; |
91 } | 89 } |
92 | 90 |
93 bool PasswordForm::IsPublicSuffixMatch() const { | 91 bool PasswordForm::IsPublicSuffixMatch() const { |
vabr (Chromium)
2015/09/24 15:17:33
We should get rid of this method completely and re
dvadym
2015/09/25 10:19:52
Done.
| |
94 CHECK(is_alive); | 92 CHECK(is_alive); |
95 return !original_signon_realm.empty(); | 93 return is_public_suffix_match; |
96 } | 94 } |
97 | 95 |
98 bool PasswordForm::IsPossibleChangePasswordForm() const { | 96 bool PasswordForm::IsPossibleChangePasswordForm() const { |
99 return !new_password_element.empty() && | 97 return !new_password_element.empty() && |
100 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; | 98 layout != PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP; |
101 } | 99 } |
102 | 100 |
103 bool PasswordForm::IsPossibleChangePasswordFormWithoutUsername() const { | 101 bool PasswordForm::IsPossibleChangePasswordFormWithoutUsername() const { |
104 return IsPossibleChangePasswordForm() && username_element.empty(); | 102 return IsPossibleChangePasswordForm() && username_element.empty(); |
105 } | 103 } |
106 | 104 |
107 bool PasswordForm::operator==(const PasswordForm& form) const { | 105 bool PasswordForm::operator==(const PasswordForm& form) const { |
108 return scheme == form.scheme && | 106 return scheme == form.scheme && signon_realm == form.signon_realm && |
109 signon_realm == form.signon_realm && | 107 origin == form.origin && action == form.action && |
110 original_signon_realm == form.original_signon_realm && | 108 submit_element == form.submit_element && |
111 origin == form.origin && | 109 username_element == form.username_element && |
112 action == form.action && | 110 username_marked_by_site == form.username_marked_by_site && |
113 submit_element == form.submit_element && | 111 username_value == form.username_value && |
114 username_element == form.username_element && | 112 other_possible_usernames == form.other_possible_usernames && |
115 username_marked_by_site == form.username_marked_by_site && | 113 password_element == form.password_element && |
116 username_value == form.username_value && | 114 password_value == form.password_value && |
117 other_possible_usernames == form.other_possible_usernames && | 115 new_password_element == form.new_password_element && |
118 password_element == form.password_element && | 116 new_password_marked_by_site == form.new_password_marked_by_site && |
119 password_value == form.password_value && | 117 new_password_value == form.new_password_value && |
120 new_password_element == form.new_password_element && | 118 ssl_valid == form.ssl_valid && preferred == form.preferred && |
121 new_password_marked_by_site == form.new_password_marked_by_site && | 119 date_created == form.date_created && date_synced == form.date_synced && |
122 new_password_value == form.new_password_value && | 120 blacklisted_by_user == form.blacklisted_by_user && type == form.type && |
123 ssl_valid == form.ssl_valid && | 121 times_used == form.times_used && |
124 preferred == form.preferred && | 122 form_data.SameFormAs(form.form_data) && |
125 date_created == form.date_created && | 123 generation_upload_status == form.generation_upload_status && |
126 date_synced == form.date_synced && | 124 display_name == form.display_name && icon_url == form.icon_url && |
127 blacklisted_by_user == form.blacklisted_by_user && | 125 federation_url == form.federation_url && |
128 type == form.type && | 126 skip_zero_click == form.skip_zero_click && layout == form.layout && |
129 times_used == form.times_used && | 127 was_parsed_using_autofill_predictions == |
130 form_data.SameFormAs(form.form_data) && | 128 form.was_parsed_using_autofill_predictions && |
131 generation_upload_status == form.generation_upload_status && | 129 is_public_suffix_match == form.is_public_suffix_match; |
132 display_name == form.display_name && | |
133 icon_url == form.icon_url && | |
134 federation_url == form.federation_url && | |
135 skip_zero_click == form.skip_zero_click && | |
136 layout == form.layout && | |
137 was_parsed_using_autofill_predictions == | |
138 form.was_parsed_using_autofill_predictions; | |
139 } | 130 } |
140 | 131 |
141 bool PasswordForm::operator!=(const PasswordForm& form) const { | 132 bool PasswordForm::operator!=(const PasswordForm& form) const { |
142 return !operator==(form); | 133 return !operator==(form); |
143 } | 134 } |
144 | 135 |
145 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, | 136 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, |
146 const PasswordForm& right) { | 137 const PasswordForm& right) { |
147 return (left.signon_realm == right.signon_realm && | 138 return (left.signon_realm == right.signon_realm && |
148 left.origin == right.origin && | 139 left.origin == right.origin && |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); | 197 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); |
207 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); | 198 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); |
208 return os << "PasswordForm(" << form_as_string << ")"; | 199 return os << "PasswordForm(" << form_as_string << ")"; |
209 } | 200 } |
210 | 201 |
211 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { | 202 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { |
212 return os << "&" << *form; | 203 return os << "&" << *form; |
213 } | 204 } |
214 | 205 |
215 } // namespace autofill | 206 } // namespace autofill |
OLD | NEW |