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 serve said so), then trigger payments UI while also returning | |
Ilya Sherman
2012/12/13 02:29:23
nit: "serve" -> "server"
Raman Kakilate
2012/12/13 21:34:34
Done.
| |
581 // standard autofill suggestions to renderer process. | |
582 if (form_structure->is_start_autofillable_flow()) { | |
583 InfoBarService* infobar_service = manager_delegate_->GetInfoBarService(); | |
584 infobar_service->AddInfoBar( | |
585 new WalletInfoBarDelegate(infobar_service, personal_data_, this, | |
586 metric_logger_.get(), form.origin, | |
587 form.ssl_status)); | |
588 } | |
589 | |
578 // Add the results from AutoComplete. They come back asynchronously, so we | 590 // 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 | 591 // hand off what we generated and they will send the results back to the |
580 // renderer. | 592 // renderer. |
581 autocomplete_history_manager_.OnGetAutocompleteSuggestions( | 593 autocomplete_history_manager_.OnGetAutocompleteSuggestions( |
582 query_id, field.name, field.value, values, labels, icons, unique_ids); | 594 query_id, field.name, field.value, values, labels, icons, unique_ids); |
583 } | 595 } |
584 | 596 |
585 void AutofillManager::OnFillAutofillFormData(int query_id, | 597 void AutofillManager::OnFillAutofillFormData(int query_id, |
586 const FormData& form, | 598 const FormData& form, |
587 const FormFieldData& field, | 599 const FormFieldData& field, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 return; | 752 return; |
741 | 753 |
742 personal_data_->RemoveByGUID(form_group->GetGUID()); | 754 personal_data_->RemoveByGUID(form_group->GetGUID()); |
743 } | 755 } |
744 | 756 |
745 void AutofillManager::RemoveAutocompleteEntry(const string16& name, | 757 void AutofillManager::RemoveAutocompleteEntry(const string16& name, |
746 const string16& value) { | 758 const string16& value) { |
747 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); | 759 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); |
748 } | 760 } |
749 | 761 |
762 void AutofillManager::ShowWalletDialog(const FormData& form, | |
763 const GURL& frame_url, | |
764 const content::SSLStatus& ssl_status) { | |
765 base::Callback<void(const FormStructure*)> callback = | |
766 base::Bind(&AutofillManager::ReturnWalletAutofillData, this); | |
767 autofill::AutofillDialogController* controller = | |
768 new autofill::AutofillDialogController(web_contents(), form, | |
769 frame_url, ssl_status, | |
770 callback); | |
771 controller->Show(); | |
772 } | |
773 | |
750 void AutofillManager::OnAddPasswordFormMapping( | 774 void AutofillManager::OnAddPasswordFormMapping( |
751 const FormFieldData& form, | 775 const FormFieldData& form, |
752 const PasswordFormFillData& fill_data) { | 776 const PasswordFormFillData& fill_data) { |
753 if (external_delegate_) | 777 if (external_delegate_) |
754 external_delegate_->AddPasswordFormMapping(form, fill_data); | 778 external_delegate_->AddPasswordFormMapping(form, fill_data); |
755 } | 779 } |
756 | 780 |
757 void AutofillManager::OnShowPasswordSuggestions( | 781 void AutofillManager::OnShowPasswordSuggestions( |
758 const FormFieldData& field, | 782 const FormFieldData& field, |
759 const gfx::Rect& bounds, | 783 const gfx::Rect& bounds, |
(...skipping 30 matching lines...) Expand all Loading... | |
790 } | 814 } |
791 | 815 |
792 void AutofillManager::ReturnAutocompleteError() { | 816 void AutofillManager::ReturnAutocompleteError() { |
793 RenderViewHost* host = web_contents()->GetRenderViewHost(); | 817 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
794 if (!host) | 818 if (!host) |
795 return; | 819 return; |
796 | 820 |
797 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); | 821 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); |
798 } | 822 } |
799 | 823 |
824 void AutofillManager::ReturnWalletAutofillData(const FormStructure* result) { | |
825 // TODO(ramankk): Parse the response FormStructure. | |
826 } | |
827 | |
800 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { | 828 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { |
801 // web_contents() will be NULL when the interactive autocomplete is closed due | 829 // web_contents() will be NULL when the interactive autocomplete is closed due |
802 // to a tab or browser window closing. | 830 // to a tab or browser window closing. |
803 if (!web_contents()) | 831 if (!web_contents()) |
804 return; | 832 return; |
805 | 833 |
806 RenderViewHost* host = web_contents()->GetRenderViewHost(); | 834 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
807 if (!host) | 835 if (!host) |
808 return; | 836 return; |
809 | 837 |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1338 *profile_guid = IDToGUID(profile_id); | 1366 *profile_guid = IDToGUID(profile_id); |
1339 } | 1367 } |
1340 | 1368 |
1341 void AutofillManager::UpdateInitialInteractionTimestamp( | 1369 void AutofillManager::UpdateInitialInteractionTimestamp( |
1342 const TimeTicks& interaction_timestamp) { | 1370 const TimeTicks& interaction_timestamp) { |
1343 if (initial_interaction_timestamp_.is_null() || | 1371 if (initial_interaction_timestamp_.is_null() || |
1344 interaction_timestamp < initial_interaction_timestamp_) { | 1372 interaction_timestamp < initial_interaction_timestamp_) { |
1345 initial_interaction_timestamp_ = interaction_timestamp; | 1373 initial_interaction_timestamp_ = interaction_timestamp; |
1346 } | 1374 } |
1347 } | 1375 } |
OLD | NEW |