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/password_store_mac.h" | 5 #include "chrome/browser/password_manager/password_store_mac.h" |
6 #include "chrome/browser/password_manager/password_store_mac_internal.h" | 6 #include "chrome/browser/password_manager/password_store_mac_internal.h" |
7 | 7 |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 const PasswordForm& form_b, | 471 const PasswordForm& form_b, |
472 FormMatchStrictness strictness) { | 472 FormMatchStrictness strictness) { |
473 // We never merge blacklist entries between our store and the Keychain, | 473 // We never merge blacklist entries between our store and the Keychain, |
474 // and federated logins should not be stored in the Keychain at all. | 474 // and federated logins should not be stored in the Keychain at all. |
475 if (form_a.blacklisted_by_user || form_b.blacklisted_by_user || | 475 if (form_a.blacklisted_by_user || form_b.blacklisted_by_user || |
476 !form_a.federation_url.is_empty() || !form_b.federation_url.is_empty()) { | 476 !form_a.federation_url.is_empty() || !form_b.federation_url.is_empty()) { |
477 return false; | 477 return false; |
478 } | 478 } |
479 bool equal_realm = form_a.signon_realm == form_b.signon_realm; | 479 bool equal_realm = form_a.signon_realm == form_b.signon_realm; |
480 if (strictness == FUZZY_FORM_MATCH) { | 480 if (strictness == FUZZY_FORM_MATCH) { |
481 equal_realm |= (!form_a.original_signon_realm.empty()) && | 481 equal_realm |= form_a.IsPublicSuffixMatch() && |
482 form_a.original_signon_realm == form_b.signon_realm; | 482 form_a.signon_realm == form_b.signon_realm; |
vabr (Chromium)
2015/09/24 15:17:33
This duplicates the condition from line 479.
I bel
dvadym
2015/09/25 10:19:52
Done.
| |
483 } | 483 } |
484 return form_a.scheme == form_b.scheme && equal_realm && | 484 return form_a.scheme == form_b.scheme && equal_realm && |
485 form_a.username_value == form_b.username_value; | 485 form_a.username_value == form_b.username_value; |
486 } | 486 } |
487 | 487 |
488 // Moves entries from |forms| that represent either blacklisted or federated | 488 // Moves entries from |forms| that represent either blacklisted or federated |
489 // logins into |extracted|. These two types are stored only in the LoginDatabase | 489 // logins into |extracted|. These two types are stored only in the LoginDatabase |
490 // and do not have corresponding Keychain entries. | 490 // and do not have corresponding Keychain entries. |
491 void ExtractNonKeychainForms(ScopedVector<autofill::PasswordForm>* forms, | 491 void ExtractNonKeychainForms(ScopedVector<autofill::PasswordForm>* forms, |
492 ScopedVector<autofill::PasswordForm>* extracted) { | 492 ScopedVector<autofill::PasswordForm>* extracted) { |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1176 } | 1176 } |
1177 | 1177 |
1178 // Let's gather all signon realms we want to match with keychain entries. | 1178 // Let's gather all signon realms we want to match with keychain entries. |
1179 std::set<std::string> realm_set; | 1179 std::set<std::string> realm_set; |
1180 realm_set.insert(form.signon_realm); | 1180 realm_set.insert(form.signon_realm); |
1181 for (const autofill::PasswordForm* db_form : database_forms) { | 1181 for (const autofill::PasswordForm* db_form : database_forms) { |
1182 // TODO(vabr): We should not be getting different schemes here. | 1182 // TODO(vabr): We should not be getting different schemes here. |
1183 // http://crbug.com/340112 | 1183 // http://crbug.com/340112 |
1184 if (form.scheme != db_form->scheme) | 1184 if (form.scheme != db_form->scheme) |
1185 continue; // Forms with different schemes never match. | 1185 continue; // Forms with different schemes never match. |
1186 const std::string& original_singon_realm(db_form->original_signon_realm); | 1186 if (db_form->IsPublicSuffixMatch()) |
1187 if (!original_singon_realm.empty()) | 1187 realm_set.insert(db_form->signon_realm); |
1188 realm_set.insert(original_singon_realm); | |
1189 } | 1188 } |
1190 ScopedVector<autofill::PasswordForm> keychain_forms; | 1189 ScopedVector<autofill::PasswordForm> keychain_forms; |
1191 for (std::set<std::string>::const_iterator realm = realm_set.begin(); | 1190 for (std::set<std::string>::const_iterator realm = realm_set.begin(); |
1192 realm != realm_set.end(); ++realm) { | 1191 realm != realm_set.end(); ++realm) { |
1193 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); | 1192 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); |
1194 ScopedVector<autofill::PasswordForm> temp_keychain_forms = | 1193 ScopedVector<autofill::PasswordForm> temp_keychain_forms = |
1195 keychain_adapter.PasswordsFillingForm(*realm, form.scheme); | 1194 keychain_adapter.PasswordsFillingForm(*realm, form.scheme); |
1196 AppendSecondToFirst(&keychain_forms, &temp_keychain_forms); | 1195 AppendSecondToFirst(&keychain_forms, &temp_keychain_forms); |
1197 } | 1196 } |
1198 | 1197 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1270 } | 1269 } |
1271 | 1270 |
1272 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm( | 1271 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm( |
1273 const autofill::PasswordForm& form) { | 1272 const autofill::PasswordForm& form) { |
1274 DCHECK(login_metadata_db_); | 1273 DCHECK(login_metadata_db_); |
1275 bool has_match = false; | 1274 bool has_match = false; |
1276 ScopedVector<autofill::PasswordForm> database_forms; | 1275 ScopedVector<autofill::PasswordForm> database_forms; |
1277 if (!login_metadata_db_->GetLogins(form, &database_forms)) | 1276 if (!login_metadata_db_->GetLogins(form, &database_forms)) |
1278 return false; | 1277 return false; |
1279 for (const autofill::PasswordForm* db_form : database_forms) { | 1278 for (const autofill::PasswordForm* db_form : database_forms) { |
1280 // Below we filter out forms with non-empty original_signon_realm, because | 1279 // Below we filter out fuzzy matched forms because we are only interested |
1281 // those signal fuzzy matches, and we are only interested in exact ones. | 1280 // in exact ones. |
1282 if (db_form->original_signon_realm.empty() && | 1281 if (!db_form->IsPublicSuffixMatch() && |
1283 internal_keychain_helpers::FormsMatchForMerge( | 1282 internal_keychain_helpers::FormsMatchForMerge( |
1284 form, *db_form, internal_keychain_helpers::STRICT_FORM_MATCH) && | 1283 form, *db_form, internal_keychain_helpers::STRICT_FORM_MATCH) && |
1285 db_form->origin == form.origin) { | 1284 db_form->origin == form.origin) { |
1286 has_match = true; | 1285 has_match = true; |
1287 break; | 1286 break; |
1288 } | 1287 } |
1289 } | 1288 } |
1290 return has_match; | 1289 return has_match; |
1291 } | 1290 } |
1292 | 1291 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1324 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1326 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1325 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1327 &forms_with_keychain_entry); | 1326 &forms_with_keychain_entry); |
1328 | 1327 |
1329 // Clean up any orphaned database entries. | 1328 // Clean up any orphaned database entries. |
1330 RemoveDatabaseForms(&database_forms); | 1329 RemoveDatabaseForms(&database_forms); |
1331 | 1330 |
1332 // Move the orphaned DB forms to the output parameter. | 1331 // Move the orphaned DB forms to the output parameter. |
1333 AppendSecondToFirst(orphaned_forms, &database_forms); | 1332 AppendSecondToFirst(orphaned_forms, &database_forms); |
1334 } | 1333 } |
OLD | NEW |