| 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/autofill/browser/autofill_manager.h" | 5 #include "components/autofill/browser/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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 } | 765 } |
| 766 | 766 |
| 767 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() { | 767 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() { |
| 768 return form_structures_.get(); | 768 return form_structures_.get(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 void AutofillManager::ShowRequestAutocompleteDialog( | 771 void AutofillManager::ShowRequestAutocompleteDialog( |
| 772 const FormData& form, | 772 const FormData& form, |
| 773 const GURL& source_url, | 773 const GURL& source_url, |
| 774 autofill::DialogType dialog_type, | 774 autofill::DialogType dialog_type, |
| 775 const base::Callback<void(const FormStructure*)>& callback) { | 775 const base::Callback<void(const FormStructure*, |
| 776 const std::string&)>& callback) { |
| 776 manager_delegate_->ShowRequestAutocompleteDialog( | 777 manager_delegate_->ShowRequestAutocompleteDialog( |
| 777 form, source_url, *metric_logger_, dialog_type, callback); | 778 form, source_url, *metric_logger_, dialog_type, callback); |
| 778 } | 779 } |
| 779 | 780 |
| 780 void AutofillManager::RequestAutocompleteDialogClosed() { | 781 void AutofillManager::RequestAutocompleteDialogClosed() { |
| 781 manager_delegate_->RequestAutocompleteDialogClosed(); | 782 manager_delegate_->RequestAutocompleteDialogClosed(); |
| 782 } | 783 } |
| 783 | 784 |
| 784 void AutofillManager::SetTestDelegate( | 785 void AutofillManager::SetTestDelegate( |
| 785 autofill::AutofillManagerTestDelegate* delegate) { | 786 autofill::AutofillManagerTestDelegate* delegate) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 821 |
| 821 void AutofillManager::OnRequestAutocomplete( | 822 void AutofillManager::OnRequestAutocomplete( |
| 822 const FormData& form, | 823 const FormData& form, |
| 823 const GURL& frame_url) { | 824 const GURL& frame_url) { |
| 824 if (!IsAutofillEnabled()) { | 825 if (!IsAutofillEnabled()) { |
| 825 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorDisabled, | 826 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorDisabled, |
| 826 FormData()); | 827 FormData()); |
| 827 return; | 828 return; |
| 828 } | 829 } |
| 829 | 830 |
| 830 base::Callback<void(const FormStructure*)> callback = | 831 base::Callback<void(const FormStructure*, const std::string&)> callback = |
| 831 base::Bind(&AutofillManager::ReturnAutocompleteData, | 832 base::Bind(&AutofillManager::ReturnAutocompleteData, |
| 832 weak_ptr_factory_.GetWeakPtr()); | 833 weak_ptr_factory_.GetWeakPtr()); |
| 833 ShowRequestAutocompleteDialog( | 834 ShowRequestAutocompleteDialog( |
| 834 form, frame_url, autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE, callback); | 835 form, frame_url, autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE, callback); |
| 835 } | 836 } |
| 836 | 837 |
| 837 void AutofillManager::ReturnAutocompleteResult( | 838 void AutofillManager::ReturnAutocompleteResult( |
| 838 WebFormElement::AutocompleteResult result, const FormData& form_data) { | 839 WebFormElement::AutocompleteResult result, const FormData& form_data) { |
| 839 // web_contents() will be NULL when the interactive autocomplete is closed due | 840 // web_contents() will be NULL when the interactive autocomplete is closed due |
| 840 // to a tab or browser window closing. | 841 // to a tab or browser window closing. |
| 841 if (!web_contents()) | 842 if (!web_contents()) |
| 842 return; | 843 return; |
| 843 | 844 |
| 844 RenderViewHost* host = web_contents()->GetRenderViewHost(); | 845 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 845 if (!host) | 846 if (!host) |
| 846 return; | 847 return; |
| 847 | 848 |
| 848 host->Send(new AutofillMsg_RequestAutocompleteResult(host->GetRoutingID(), | 849 host->Send(new AutofillMsg_RequestAutocompleteResult(host->GetRoutingID(), |
| 849 result, | 850 result, |
| 850 form_data)); | 851 form_data)); |
| 851 } | 852 } |
| 852 | 853 |
| 853 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { | 854 void AutofillManager::ReturnAutocompleteData( |
| 855 const FormStructure* result, |
| 856 const std::string& unused_transaction_id) { |
| 854 RequestAutocompleteDialogClosed(); | 857 RequestAutocompleteDialogClosed(); |
| 855 if (!result) { | 858 if (!result) { |
| 856 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorCancel, | 859 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorCancel, |
| 857 FormData()); | 860 FormData()); |
| 858 } else { | 861 } else { |
| 859 ReturnAutocompleteResult(WebFormElement::AutocompleteResultSuccess, | 862 ReturnAutocompleteResult(WebFormElement::AutocompleteResultSuccess, |
| 860 result->ToFormData()); | 863 result->ToFormData()); |
| 861 } | 864 } |
| 862 } | 865 } |
| 863 | 866 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 877 // If the corresponding flag is set, annotate forms with the predicted types. | 880 // If the corresponding flag is set, annotate forms with the predicted types. |
| 878 SendAutofillTypePredictions(form_structures_.get()); | 881 SendAutofillTypePredictions(form_structures_.get()); |
| 879 } | 882 } |
| 880 | 883 |
| 881 void AutofillManager::OnDidEndTextFieldEditing() { | 884 void AutofillManager::OnDidEndTextFieldEditing() { |
| 882 if (external_delegate_) | 885 if (external_delegate_) |
| 883 external_delegate_->DidEndTextFieldEditing(); | 886 external_delegate_->DidEndTextFieldEditing(); |
| 884 } | 887 } |
| 885 | 888 |
| 886 void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) { | 889 void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) { |
| 887 // TODO(ahutter): Plug into WalletClient. | 890 autocheckout_manager_.OnClickFailed(status); |
| 888 } | 891 } |
| 889 | 892 |
| 890 void AutofillManager::OnMaybeShowAutocheckoutBubble( | 893 void AutofillManager::OnMaybeShowAutocheckoutBubble( |
| 891 const GURL& source_url, | 894 const GURL& source_url, |
| 892 const content::SSLStatus& ssl_status, | 895 const content::SSLStatus& ssl_status, |
| 893 const gfx::RectF& bounding_box) { | 896 const gfx::RectF& bounding_box) { |
| 894 if (!IsAutofillEnabled()) | 897 if (!IsAutofillEnabled()) |
| 895 return; | 898 return; |
| 896 | 899 |
| 897 autocheckout_manager_.MaybeShowAutocheckoutBubble( | 900 autocheckout_manager_.MaybeShowAutocheckoutBubble( |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 *profile_guid = IDToGUID(profile_id); | 1337 *profile_guid = IDToGUID(profile_id); |
| 1335 } | 1338 } |
| 1336 | 1339 |
| 1337 void AutofillManager::UpdateInitialInteractionTimestamp( | 1340 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1338 const TimeTicks& interaction_timestamp) { | 1341 const TimeTicks& interaction_timestamp) { |
| 1339 if (initial_interaction_timestamp_.is_null() || | 1342 if (initial_interaction_timestamp_.is_null() || |
| 1340 interaction_timestamp < initial_interaction_timestamp_) { | 1343 interaction_timestamp < initial_interaction_timestamp_) { |
| 1341 initial_interaction_timestamp_ = interaction_timestamp; | 1344 initial_interaction_timestamp_ = interaction_timestamp; |
| 1342 } | 1345 } |
| 1343 } | 1346 } |
| OLD | NEW |