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/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/autofill/autofill_metrics.h" | 32 #include "chrome/browser/autofill/autofill_metrics.h" |
33 #include "chrome/browser/autofill/autofill_profile.h" | 33 #include "chrome/browser/autofill/autofill_profile.h" |
34 #include "chrome/browser/autofill/autofill_type.h" | 34 #include "chrome/browser/autofill/autofill_type.h" |
35 #include "chrome/browser/autofill/credit_card.h" | 35 #include "chrome/browser/autofill/credit_card.h" |
36 #include "chrome/browser/autofill/form_structure.h" | 36 #include "chrome/browser/autofill/form_structure.h" |
37 #include "chrome/browser/autofill/password_generator.h" | 37 #include "chrome/browser/autofill/password_generator.h" |
38 #include "chrome/browser/autofill/personal_data_manager.h" | 38 #include "chrome/browser/autofill/personal_data_manager.h" |
39 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 39 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
40 #include "chrome/browser/autofill/phone_number.h" | 40 #include "chrome/browser/autofill/phone_number.h" |
41 #include "chrome/browser/autofill/phone_number_i18n.h" | 41 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 42 #include "chrome/browser/autofill/wallet_infobar_delegate.h" |
42 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 43 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
43 #include "chrome/common/autofill_messages.h" | 44 #include "chrome/common/autofill_messages.h" |
44 #include "chrome/common/chrome_notification_types.h" | 45 #include "chrome/common/chrome_notification_types.h" |
45 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
46 #include "chrome/common/form_data.h" | 47 #include "chrome/common/form_data.h" |
47 #include "chrome/common/form_data_predictions.h" | 48 #include "chrome/common/form_data_predictions.h" |
48 #include "chrome/common/form_field_data.h" | 49 #include "chrome/common/form_field_data.h" |
49 #include "chrome/common/password_form_fill_data.h" | 50 #include "chrome/common/password_form_fill_data.h" |
50 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
51 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 // The first time we show suggestions on this page, log the number of | 569 // The first time we show suggestions on this page, log the number of |
569 // suggestions shown. | 570 // suggestions shown. |
570 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { | 571 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { |
571 metric_logger_->LogAddressSuggestionsCount(values.size()); | 572 metric_logger_->LogAddressSuggestionsCount(values.size()); |
572 has_logged_address_suggestions_count_ = true; | 573 has_logged_address_suggestions_count_ = true; |
573 } | 574 } |
574 } | 575 } |
575 } | 576 } |
576 } | 577 } |
577 | 578 |
| 579 // If form is known to be at the start of the autofillable flow (i.e, when |
| 580 // Autofill server said so), then trigger payments UI while also returning |
| 581 // standard autofill suggestions to renderer process. |
| 582 if (form_structure->IsStartOfAutofillableFlow()) { |
| 583 InfoBarService* infobar_service = manager_delegate_->GetInfoBarService(); |
| 584 infobar_service->AddInfoBar( |
| 585 new WalletInfoBarDelegate(infobar_service, this, metric_logger_.get(), |
| 586 form.origin, form.ssl_status)); |
| 587 } |
| 588 |
578 // Add the results from AutoComplete. They come back asynchronously, so we | 589 // Add the results from AutoComplete. They come back asynchronously, so we |
579 // hand off what we generated and they will send the results back to the | 590 // hand off what we generated and they will send the results back to the |
580 // renderer. | 591 // renderer. |
581 autocomplete_history_manager_.OnGetAutocompleteSuggestions( | 592 autocomplete_history_manager_.OnGetAutocompleteSuggestions( |
582 query_id, field.name, field.value, values, labels, icons, unique_ids); | 593 query_id, field.name, field.value, values, labels, icons, unique_ids); |
583 } | 594 } |
584 | 595 |
585 void AutofillManager::OnFillAutofillFormData(int query_id, | 596 void AutofillManager::OnFillAutofillFormData(int query_id, |
586 const FormData& form, | 597 const FormData& form, |
587 const FormFieldData& field, | 598 const FormFieldData& field, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 return; | 751 return; |
741 | 752 |
742 personal_data_->RemoveByGUID(form_group->GetGUID()); | 753 personal_data_->RemoveByGUID(form_group->GetGUID()); |
743 } | 754 } |
744 | 755 |
745 void AutofillManager::RemoveAutocompleteEntry(const string16& name, | 756 void AutofillManager::RemoveAutocompleteEntry(const string16& name, |
746 const string16& value) { | 757 const string16& value) { |
747 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); | 758 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); |
748 } | 759 } |
749 | 760 |
| 761 void AutofillManager::ShowWalletDialog(const FormData& form, |
| 762 const GURL& frame_url, |
| 763 const content::SSLStatus& ssl_status) { |
| 764 base::Callback<void(const FormStructure*)> callback = |
| 765 base::Bind(&AutofillManager::ReturnWalletAutofillData, this); |
| 766 autofill::AutofillDialogController* controller = |
| 767 new autofill::AutofillDialogController(web_contents(), form, |
| 768 frame_url, ssl_status, |
| 769 callback); |
| 770 controller->Show(); |
| 771 } |
| 772 |
750 void AutofillManager::OnAddPasswordFormMapping( | 773 void AutofillManager::OnAddPasswordFormMapping( |
751 const FormFieldData& form, | 774 const FormFieldData& form, |
752 const PasswordFormFillData& fill_data) { | 775 const PasswordFormFillData& fill_data) { |
753 if (external_delegate_) | 776 if (external_delegate_) |
754 external_delegate_->AddPasswordFormMapping(form, fill_data); | 777 external_delegate_->AddPasswordFormMapping(form, fill_data); |
755 } | 778 } |
756 | 779 |
757 void AutofillManager::OnShowPasswordSuggestions( | 780 void AutofillManager::OnShowPasswordSuggestions( |
758 const FormFieldData& field, | 781 const FormFieldData& field, |
759 const gfx::Rect& bounds, | 782 const gfx::Rect& bounds, |
(...skipping 30 matching lines...) Expand all Loading... |
790 } | 813 } |
791 | 814 |
792 void AutofillManager::ReturnAutocompleteError() { | 815 void AutofillManager::ReturnAutocompleteError() { |
793 RenderViewHost* host = web_contents()->GetRenderViewHost(); | 816 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
794 if (!host) | 817 if (!host) |
795 return; | 818 return; |
796 | 819 |
797 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); | 820 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); |
798 } | 821 } |
799 | 822 |
| 823 void AutofillManager::ReturnWalletAutofillData(const FormStructure* result) { |
| 824 // TODO(ramankk): Parse the response FormStructure. |
| 825 } |
| 826 |
800 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { | 827 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { |
801 // web_contents() will be NULL when the interactive autocomplete is closed due | 828 // web_contents() will be NULL when the interactive autocomplete is closed due |
802 // to a tab or browser window closing. | 829 // to a tab or browser window closing. |
803 if (!web_contents()) | 830 if (!web_contents()) |
804 return; | 831 return; |
805 | 832 |
806 RenderViewHost* host = web_contents()->GetRenderViewHost(); | 833 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
807 if (!host) | 834 if (!host) |
808 return; | 835 return; |
809 | 836 |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 *profile_guid = IDToGUID(profile_id); | 1365 *profile_guid = IDToGUID(profile_id); |
1339 } | 1366 } |
1340 | 1367 |
1341 void AutofillManager::UpdateInitialInteractionTimestamp( | 1368 void AutofillManager::UpdateInitialInteractionTimestamp( |
1342 const TimeTicks& interaction_timestamp) { | 1369 const TimeTicks& interaction_timestamp) { |
1343 if (initial_interaction_timestamp_.is_null() || | 1370 if (initial_interaction_timestamp_.is_null() || |
1344 interaction_timestamp < initial_interaction_timestamp_) { | 1371 interaction_timestamp < initial_interaction_timestamp_) { |
1345 initial_interaction_timestamp_ = interaction_timestamp; | 1372 initial_interaction_timestamp_ = interaction_timestamp; |
1346 } | 1373 } |
1347 } | 1374 } |
OLD | NEW |