| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/password_manager/native_backend_gnome_x.h" | 5 #include "chrome/browser/password_manager/native_backend_gnome_x.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 24 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 25 #include "components/password_manager/core/browser/password_manager_util.h" | 25 #include "components/password_manager/core/browser/password_manager_util.h" |
| 26 #include "components/password_manager/core/browser/psl_matching_helper.h" | 26 #include "components/password_manager/core/browser/psl_matching_helper.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 | 28 |
| 29 using autofill::PasswordForm; | 29 using autofill::PasswordForm; |
| 30 using base::UTF8ToUTF16; | 30 using base::UTF8ToUTF16; |
| 31 using base::UTF16ToUTF8; | 31 using base::UTF16ToUTF8; |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 using namespace password_manager::metrics_util; | 33 using namespace password_manager::metrics_util; |
| 34 using password_manager::MatchResult; |
| 34 using password_manager::PasswordStore; | 35 using password_manager::PasswordStore; |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 const int kMaxPossibleTimeTValue = std::numeric_limits<int>::max(); | 38 const int kMaxPossibleTimeTValue = std::numeric_limits<int>::max(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 const char kGnomeKeyringAppString[] = "chrome"; | 43 const char kGnomeKeyringAppString[] = "chrome"; |
| 43 | 44 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // realms passing the PSL matching against |lookup_form->signon_realm| will be | 115 // realms passing the PSL matching against |lookup_form->signon_realm| will be |
| 115 // kept. PSL matched results get their signon_realm, origin, and action | 116 // kept. PSL matched results get their signon_realm, origin, and action |
| 116 // rewritten to those of |lookup_form_|, with the original signon_realm saved | 117 // rewritten to those of |lookup_form_|, with the original signon_realm saved |
| 117 // into the result's original_signon_realm data member. | 118 // into the result's original_signon_realm data member. |
| 118 std::vector<std::unique_ptr<PasswordForm>> ConvertFormList( | 119 std::vector<std::unique_ptr<PasswordForm>> ConvertFormList( |
| 119 GList* found, | 120 GList* found, |
| 120 const PasswordStore::FormDigest* lookup_form) { | 121 const PasswordStore::FormDigest* lookup_form) { |
| 121 std::vector<std::unique_ptr<PasswordForm>> forms; | 122 std::vector<std::unique_ptr<PasswordForm>> forms; |
| 122 password_manager::PSLDomainMatchMetric psl_domain_match_metric = | 123 password_manager::PSLDomainMatchMetric psl_domain_match_metric = |
| 123 password_manager::PSL_DOMAIN_MATCH_NONE; | 124 password_manager::PSL_DOMAIN_MATCH_NONE; |
| 124 const bool allow_psl_match = | |
| 125 lookup_form && password_manager::ShouldPSLDomainMatchingApply( | |
| 126 password_manager::GetRegistryControlledDomain( | |
| 127 GURL(lookup_form->signon_realm))); | |
| 128 for (GList* element = g_list_first(found); element; | 125 for (GList* element = g_list_first(found); element; |
| 129 element = g_list_next(element)) { | 126 element = g_list_next(element)) { |
| 130 GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data); | 127 GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data); |
| 131 GnomeKeyringAttributeList* attrs = data->attributes; | 128 GnomeKeyringAttributeList* attrs = data->attributes; |
| 132 | 129 |
| 133 std::unique_ptr<PasswordForm> form(FormFromAttributes(attrs)); | 130 std::unique_ptr<PasswordForm> form(FormFromAttributes(attrs)); |
| 134 if (form) { | 131 if (!form) { |
| 135 if (lookup_form && form->signon_realm != lookup_form->signon_realm) { | 132 LOG(WARNING) << "Could not initialize PasswordForm from attributes!"; |
| 136 if (lookup_form->scheme != PasswordForm::SCHEME_HTML || | 133 continue; |
| 137 form->scheme != PasswordForm::SCHEME_HTML) | 134 } |
| 138 continue; // Ignore non-HTML matches. | 135 |
| 139 // This is not an exact match, we try PSL matching and federated match. | 136 if (lookup_form) { |
| 140 if (allow_psl_match && | 137 switch (GetMatchResult(*form, *lookup_form)) { |
| 141 password_manager::IsPublicSuffixDomainMatch( | 138 case MatchResult::NO_MATCH: |
| 142 form->signon_realm, lookup_form->signon_realm)) { | 139 continue; |
| 140 case MatchResult::EXACT_MATCH: |
| 141 break; |
| 142 case MatchResult::PSL_MATCH: |
| 143 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; | 143 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; |
| 144 form->is_public_suffix_match = true; | 144 form->is_public_suffix_match = true; |
| 145 } else if (!form->federation_origin.unique() && | 145 break; |
| 146 password_manager::IsFederatedMatch(form->signon_realm, | 146 case MatchResult::FEDERATED_MATCH: |
| 147 lookup_form->origin)) { | 147 break; |
| 148 } else { | 148 case MatchResult::FEDERATED_PSL_MATCH: |
| 149 continue; | 149 psl_domain_match_metric = |
| 150 } | 150 password_manager::PSL_DOMAIN_MATCH_FOUND_FEDERATED; |
| 151 form->is_public_suffix_match = true; |
| 152 break; |
| 151 } | 153 } |
| 152 if (data->secret) { | 154 } |
| 153 form->password_value = UTF8ToUTF16(data->secret); | 155 |
| 154 } else { | 156 if (data->secret) { |
| 155 LOG(WARNING) << "Unable to access password from list element!"; | 157 form->password_value = UTF8ToUTF16(data->secret); |
| 156 } | |
| 157 forms.push_back(std::move(form)); | |
| 158 } else { | 158 } else { |
| 159 LOG(WARNING) << "Could not initialize PasswordForm from attributes!"; | 159 LOG(WARNING) << "Unable to access password from list element!"; |
| 160 } | 160 } |
| 161 forms.push_back(std::move(form)); |
| 161 } | 162 } |
| 162 if (lookup_form) { | 163 if (lookup_form) { |
| 164 const bool allow_psl_match = password_manager::ShouldPSLDomainMatchingApply( |
| 165 password_manager::GetRegistryControlledDomain( |
| 166 GURL(lookup_form->signon_realm))); |
| 163 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", | 167 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", |
| 164 allow_psl_match | 168 allow_psl_match |
| 165 ? psl_domain_match_metric | 169 ? psl_domain_match_metric |
| 166 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, | 170 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, |
| 167 password_manager::PSL_DOMAIN_MATCH_COUNT); | 171 password_manager::PSL_DOMAIN_MATCH_COUNT); |
| 168 } | 172 } |
| 169 return forms; | 173 return forms; |
| 170 } | 174 } |
| 171 | 175 |
| 172 // Schema is analogous to the fields in PasswordForm. | 176 // Schema is analogous to the fields in PasswordForm. |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 std::vector<std::unique_ptr<PasswordForm>> forms; | 779 std::vector<std::unique_ptr<PasswordForm>> forms; |
| 776 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) | 780 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) |
| 777 return false; | 781 return false; |
| 778 | 782 |
| 779 for (size_t i = 0; i < forms.size(); ++i) { | 783 for (size_t i = 0; i < forms.size(); ++i) { |
| 780 if (!RemoveLogin(*forms[i], changes)) | 784 if (!RemoveLogin(*forms[i], changes)) |
| 781 return false; | 785 return false; |
| 782 } | 786 } |
| 783 return true; | 787 return true; |
| 784 } | 788 } |
| OLD | NEW |