Chromium Code Reviews| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 const bool allow_psl_match = | 125 const bool allow_psl_match = |
| 125 lookup_form && password_manager::ShouldPSLDomainMatchingApply( | 126 lookup_form && password_manager::ShouldPSLDomainMatchingApply( |
| 126 password_manager::GetRegistryControlledDomain( | 127 password_manager::GetRegistryControlledDomain( |
| 127 GURL(lookup_form->signon_realm))); | 128 GURL(lookup_form->signon_realm))); |
| 128 for (GList* element = g_list_first(found); element; | 129 for (GList* element = g_list_first(found); element; |
| 129 element = g_list_next(element)) { | 130 element = g_list_next(element)) { |
| 130 GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data); | 131 GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data); |
| 131 GnomeKeyringAttributeList* attrs = data->attributes; | 132 GnomeKeyringAttributeList* attrs = data->attributes; |
| 132 | 133 |
| 133 std::unique_ptr<PasswordForm> form(FormFromAttributes(attrs)); | 134 std::unique_ptr<PasswordForm> form(FormFromAttributes(attrs)); |
| 134 if (form) { | 135 if (!form) { |
| 135 if (lookup_form && form->signon_realm != lookup_form->signon_realm) { | 136 LOG(WARNING) << "Could not initialize PasswordForm from attributes!"; |
| 136 if (lookup_form->scheme != PasswordForm::SCHEME_HTML || | 137 continue; |
| 137 form->scheme != PasswordForm::SCHEME_HTML) | 138 } |
| 138 continue; // Ignore non-HTML matches. | 139 |
| 139 // This is not an exact match, we try PSL matching and federated match. | 140 if (lookup_form) { |
| 140 if (allow_psl_match && | 141 switch (GetMatchResult(*form, *lookup_form)) { |
| 141 password_manager::IsPublicSuffixDomainMatch( | 142 case MatchResult::NO_MATCH: |
| 142 form->signon_realm, lookup_form->signon_realm)) { | 143 continue; |
| 144 case MatchResult::EXACT_MATCH: | |
| 145 break; | |
| 146 case MatchResult::PSL_MATCH: | |
|
vasilii
2017/01/26 13:35:17
|allow_psl_match| isn't used anymore. Deliberately
jdoerrie
2017/01/26 14:47:56
Yeah, it's now part of |GetMatchResult|. It's stil
| |
| 143 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; | 147 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; |
| 144 form->is_public_suffix_match = true; | 148 form->is_public_suffix_match = true; |
| 145 } else if (!form->federation_origin.unique() && | 149 break; |
| 146 password_manager::IsFederatedMatch(form->signon_realm, | 150 case MatchResult::FEDERATED_MATCH: |
| 147 lookup_form->origin)) { | 151 break; |
| 148 } else { | 152 case MatchResult::FEDERATED_PSL_MATCH: |
| 149 continue; | 153 psl_domain_match_metric = |
| 150 } | 154 password_manager::PSL_DOMAIN_MATCH_FOUND_FEDERATED; |
| 155 form->is_public_suffix_match = true; | |
| 156 break; | |
| 151 } | 157 } |
| 152 if (data->secret) { | 158 } |
| 153 form->password_value = UTF8ToUTF16(data->secret); | 159 |
| 154 } else { | 160 if (data->secret) { |
| 155 LOG(WARNING) << "Unable to access password from list element!"; | 161 form->password_value = UTF8ToUTF16(data->secret); |
| 156 } | |
| 157 forms.push_back(std::move(form)); | |
| 158 } else { | 162 } else { |
| 159 LOG(WARNING) << "Could not initialize PasswordForm from attributes!"; | 163 LOG(WARNING) << "Unable to access password from list element!"; |
| 160 } | 164 } |
| 165 forms.push_back(std::move(form)); | |
| 161 } | 166 } |
| 162 if (lookup_form) { | 167 if (lookup_form) { |
| 163 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", | 168 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", |
| 164 allow_psl_match | 169 allow_psl_match |
| 165 ? psl_domain_match_metric | 170 ? psl_domain_match_metric |
| 166 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, | 171 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, |
| 167 password_manager::PSL_DOMAIN_MATCH_COUNT); | 172 password_manager::PSL_DOMAIN_MATCH_COUNT); |
| 168 } | 173 } |
| 169 return forms; | 174 return forms; |
| 170 } | 175 } |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 std::vector<std::unique_ptr<PasswordForm>> forms; | 780 std::vector<std::unique_ptr<PasswordForm>> forms; |
| 776 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) | 781 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) |
| 777 return false; | 782 return false; |
| 778 | 783 |
| 779 for (size_t i = 0; i < forms.size(); ++i) { | 784 for (size_t i = 0; i < forms.size(); ++i) { |
| 780 if (!RemoveLogin(*forms[i], changes)) | 785 if (!RemoveLogin(*forms[i], changes)) |
| 781 return false; | 786 return false; |
| 782 } | 787 } |
| 783 return true; | 788 return true; |
| 784 } | 789 } |
| OLD | NEW |