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
3 // found in the LICENSE file.
7 #include "base/strings/string16.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/common/password_form.h"
14 PasswordForm::PasswordForm()
15 : scheme(SCHEME_HTML
),
16 username_marked_by_site(false),
17 password_autocomplete_set(true),
20 blacklisted_by_user(false),
23 generation_upload_status(NO_SIGNAL_SENT
),
24 skip_zero_click(false) {
27 PasswordForm::~PasswordForm() {
30 bool PasswordForm::IsPublicSuffixMatch() const {
31 return !original_signon_realm
.empty();
34 bool PasswordForm::operator==(const PasswordForm
& form
) const {
35 return signon_realm
== form
.signon_realm
&&
36 origin
== form
.origin
&&
37 action
== form
.action
&&
38 submit_element
== form
.submit_element
&&
39 username_element
== form
.username_element
&&
40 username_marked_by_site
== form
.username_marked_by_site
&&
41 username_value
== form
.username_value
&&
42 other_possible_usernames
== form
.other_possible_usernames
&&
43 password_element
== form
.password_element
&&
44 password_value
== form
.password_value
&&
45 password_autocomplete_set
== form
.password_autocomplete_set
&&
46 new_password_element
== form
.new_password_element
&&
47 new_password_value
== form
.new_password_value
&&
48 ssl_valid
== form
.ssl_valid
&&
49 preferred
== form
.preferred
&&
50 date_created
== form
.date_created
&&
51 date_synced
== form
.date_synced
&&
52 blacklisted_by_user
== form
.blacklisted_by_user
&&
54 times_used
== form
.times_used
&&
55 form_data
.SameFormAs(form
.form_data
) &&
56 generation_upload_status
== form
.generation_upload_status
&&
57 display_name
== form
.display_name
&&
58 avatar_url
== form
.avatar_url
&&
59 federation_url
== form
.federation_url
&&
60 skip_zero_click
== form
.skip_zero_click
;
63 bool PasswordForm::operator!=(const PasswordForm
& form
) const {
64 return !operator==(form
);
67 std::ostream
& operator<<(std::ostream
& os
, const PasswordForm
& form
) {
68 return os
<< "scheme: " << form
.scheme
69 << " signon_realm: " << form
.signon_realm
70 << " origin: " << form
.origin
71 << " action: " << form
.action
72 << " submit_element: " << base::UTF16ToUTF8(form
.submit_element
)
73 << " username_elem: " << base::UTF16ToUTF8(form
.username_element
)
74 << " username_marked_by_site: " << form
.username_marked_by_site
75 << " username_value: " << base::UTF16ToUTF8(form
.username_value
)
76 << " password_elem: " << base::UTF16ToUTF8(form
.password_element
)
77 << " password_value: " << base::UTF16ToUTF8(form
.password_value
)
78 << " new_password_element: "
79 << base::UTF16ToUTF8(form
.new_password_element
)
80 << " new_password_value: "
81 << base::UTF16ToUTF8(form
.new_password_value
)
82 << " other_possible_usernames: "
83 << JoinString(form
.other_possible_usernames
, '|')
84 << " autocomplete_set:" << form
.password_autocomplete_set
85 << " blacklisted: " << form
.blacklisted_by_user
86 << " preferred: " << form
.preferred
87 << " ssl_valid: " << form
.ssl_valid
88 << " date_created: " << form
.date_created
.ToDoubleT()
89 << " date_synced: " << form
.date_synced
.ToDoubleT()
90 << " type: " << form
.type
91 << " times_used: " << form
.times_used
92 << " form_data: " << form
.form_data
93 << " generation_upload_status: " << form
.generation_upload_status
94 << " display_name: " << base::UTF16ToUTF8(form
.display_name
)
95 << " avatar_url: " << form
.avatar_url
96 << " federation_url: " << form
.federation_url
97 << " skip_next_zero_click: " << form
.skip_zero_click
;
100 } // namespace autofill