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 "components/password_manager/core/browser/password_manager.h" | 5 #include "components/password_manager/core/browser/password_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "components/autofill/core/browser/autofill_field.h" |
| 15 #include "components/autofill/core/browser/form_structure.h" |
| 16 #include "components/autofill/core/common/form_data_predictions.h" |
14 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 17 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
15 #include "components/password_manager/core/browser/password_autofill_manager.h" | 18 #include "components/password_manager/core/browser/password_autofill_manager.h" |
16 #include "components/password_manager/core/browser/password_form_manager.h" | 19 #include "components/password_manager/core/browser/password_form_manager.h" |
17 #include "components/password_manager/core/browser/password_manager_client.h" | 20 #include "components/password_manager/core/browser/password_manager_client.h" |
18 #include "components/password_manager/core/browser/password_manager_driver.h" | 21 #include "components/password_manager/core/browser/password_manager_driver.h" |
19 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 22 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
20 #include "components/password_manager/core/common/password_manager_pref_names.h" | 23 #include "components/password_manager/core/common/password_manager_pref_names.h" |
21 #include "components/password_manager/core/common/password_manager_switches.h" | 24 #include "components/password_manager/core/common/password_manager_switches.h" |
22 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 LoginModelObserver, | 714 LoginModelObserver, |
712 observers_, | 715 observers_, |
713 OnAutofillDataAvailable(preferred_match.username_value, | 716 OnAutofillDataAvailable(preferred_match.username_value, |
714 preferred_match.password_value)); | 717 preferred_match.password_value)); |
715 break; | 718 break; |
716 } | 719 } |
717 | 720 |
718 client_->PasswordWasAutofilled(best_matches); | 721 client_->PasswordWasAutofilled(best_matches); |
719 } | 722 } |
720 | 723 |
| 724 void PasswordManager::ProcessAutofillPredictions( |
| 725 password_manager::PasswordManagerDriver* driver, |
| 726 const std::vector<autofill::FormStructure*>& forms) { |
| 727 // Leave only forms that contain fields that are useful for password manager. |
| 728 std::map<autofill::FormData, autofill::FormFieldData> predictions; |
| 729 for (autofill::FormStructure* form : forms) { |
| 730 for (std::vector<autofill::AutofillField*>::const_iterator field = |
| 731 form->begin(); |
| 732 field != form->end(); ++field) { |
| 733 if ((*field)->server_type() == autofill::USERNAME || |
| 734 (*field)->server_type() == autofill::USERNAME_AND_EMAIL_ADDRESS) { |
| 735 predictions[form->ToFormData()] = *(*field); |
| 736 } |
| 737 } |
| 738 } |
| 739 if (predictions.empty()) |
| 740 return; |
| 741 driver->AutofillDataReceived(predictions); |
| 742 } |
| 743 |
721 } // namespace password_manager | 744 } // namespace password_manager |
OLD | NEW |