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 "components/password_manager/core/browser/psl_matching_helper.h" | 5 #include "components/password_manager/core/browser/psl_matching_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (form.signon_realm == form_digest.signon_realm) | 59 if (form.signon_realm == form_digest.signon_realm) |
60 return MatchResult::EXACT_MATCH; | 60 return MatchResult::EXACT_MATCH; |
61 | 61 |
62 // PSL and federated matches only apply to HTML forms. | 62 // PSL and federated matches only apply to HTML forms. |
63 if (form_digest.scheme != PasswordForm::SCHEME_HTML || | 63 if (form_digest.scheme != PasswordForm::SCHEME_HTML || |
64 form.scheme != PasswordForm::SCHEME_HTML) | 64 form.scheme != PasswordForm::SCHEME_HTML) |
65 return MatchResult::NO_MATCH; | 65 return MatchResult::NO_MATCH; |
66 | 66 |
67 const bool allow_psl_match = ShouldPSLDomainMatchingApply( | 67 const bool allow_psl_match = ShouldPSLDomainMatchingApply( |
68 GetRegistryControlledDomain(GURL(form_digest.signon_realm))); | 68 GetRegistryControlledDomain(GURL(form_digest.signon_realm))); |
69 const bool allow_federated_match = !form.federation_origin.unique(); | 69 const bool allow_federated_match = !form.federation_origin.opaque(); |
70 | 70 |
71 if (allow_psl_match && | 71 if (allow_psl_match && |
72 IsPublicSuffixDomainMatch(form.signon_realm, form_digest.signon_realm)) | 72 IsPublicSuffixDomainMatch(form.signon_realm, form_digest.signon_realm)) |
73 return MatchResult::PSL_MATCH; | 73 return MatchResult::PSL_MATCH; |
74 | 74 |
75 if (allow_federated_match && | 75 if (allow_federated_match && |
76 IsFederatedRealm(form.signon_realm, form_digest.origin) && | 76 IsFederatedRealm(form.signon_realm, form_digest.origin) && |
77 form.origin.GetOrigin() == form_digest.origin.GetOrigin()) | 77 form.origin.GetOrigin() == form_digest.origin.GetOrigin()) |
78 return MatchResult::FEDERATED_MATCH; | 78 return MatchResult::FEDERATED_MATCH; |
79 | 79 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return std::string(); | 134 return std::string(); |
135 } | 135 } |
136 | 136 |
137 // No CHECK, std::string::substr gracefully handles an underflow there. | 137 // No CHECK, std::string::substr gracefully handles an underflow there. |
138 DCHECK_LT(registrar_length, organization_and_registrar.size()); | 138 DCHECK_LT(registrar_length, organization_and_registrar.size()); |
139 return organization_and_registrar.substr( | 139 return organization_and_registrar.substr( |
140 0, organization_and_registrar.size() - registrar_length - 1); | 140 0, organization_and_registrar.size() - registrar_length - 1); |
141 } | 141 } |
142 | 142 |
143 } // namespace password_manager | 143 } // namespace password_manager |
OLD | NEW |