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/renderer/autofill_agent.h" | 5 #include "components/autofill/renderer/autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 if (!frame->parent()) { | 205 if (!frame->parent()) { |
206 topmost_frame_ = frame; | 206 topmost_frame_ = frame; |
207 form_elements_.clear(); | 207 form_elements_.clear(); |
208 has_more_forms = form_cache_.ExtractFormsAndFormElements( | 208 has_more_forms = form_cache_.ExtractFormsAndFormElements( |
209 *frame, kRequiredAutofillFields, &forms, &form_elements_); | 209 *frame, kRequiredAutofillFields, &forms, &form_elements_); |
210 is_whitelisted_for_autocheckout_ = false; | 210 is_whitelisted_for_autocheckout_ = false; |
211 } else { | 211 } else { |
212 form_cache_.ExtractForms(*frame, &forms); | 212 form_cache_.ExtractForms(*frame, &forms); |
213 } | 213 } |
214 | 214 |
215 autofill::FormsSeenParam param = has_more_forms ? | |
216 autofill::PARTIAL_FORMS_SEEN : autofill::NO_SPECIAL_FORMS_SEEN; | |
217 | |
215 // Always communicate to browser process for topmost frame. | 218 // Always communicate to browser process for topmost frame. |
216 if (!forms.empty() || !frame->parent()) { | 219 if (!forms.empty() || !frame->parent()) { |
217 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 220 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
218 forms_seen_timestamp_, | 221 forms_seen_timestamp_, |
219 has_more_forms)); | 222 param)); |
220 } | 223 } |
221 } | 224 } |
222 | 225 |
223 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { | 226 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { |
224 if (!frame->parent()) { | 227 if (!frame->parent()) { |
225 topmost_frame_ = NULL; | 228 topmost_frame_ = NULL; |
226 if (click_timer_.IsRunning()) { | 229 if (click_timer_.IsRunning()) { |
227 click_timer_.Stop(); | 230 click_timer_.Stop(); |
228 autocheckout_click_in_progress_ = true; | 231 autocheckout_click_in_progress_ = true; |
229 } | 232 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 std::vector<FormData> forms; | 722 std::vector<FormData> forms; |
720 form_cache_.ExtractFormsAndFormElements( | 723 form_cache_.ExtractFormsAndFormElements( |
721 *topmost_frame_, 0, &forms, &form_elements_); | 724 *topmost_frame_, 0, &forms, &form_elements_); |
722 | 725 |
723 // OnGetAllForms should only be called if AutofillAgent reported to | 726 // OnGetAllForms should only be called if AutofillAgent reported to |
724 // AutofillManager that there are more forms | 727 // AutofillManager that there are more forms |
725 DCHECK(!forms.empty()); | 728 DCHECK(!forms.empty()); |
726 | 729 |
727 // Report to AutofillManager that all forms are being sent. | 730 // Report to AutofillManager that all forms are being sent. |
728 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 731 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
729 forms_seen_timestamp_, false)); | 732 forms_seen_timestamp_, |
733 NO_SPECIAL_FORMS_SEEN)); | |
730 } | 734 } |
731 | 735 |
732 void AutofillAgent::OnRequestAutocompleteResult( | 736 void AutofillAgent::OnRequestAutocompleteResult( |
733 WebFormElement::AutocompleteResult result, const FormData& form_data) { | 737 WebFormElement::AutocompleteResult result, const FormData& form_data) { |
734 if (in_flight_request_form_.isNull()) | 738 if (in_flight_request_form_.isNull()) |
735 return; | 739 return; |
736 | 740 |
737 if (result == WebFormElement::AutocompleteResultSuccess) | 741 if (result == WebFormElement::AutocompleteResultSuccess) |
738 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); | 742 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); |
739 | 743 |
(...skipping 27 matching lines...) Expand all Loading... | |
767 if (!ClickElement(topmost_frame_->document(), | 771 if (!ClickElement(topmost_frame_->document(), |
768 click_element_descriptor)) { | 772 click_element_descriptor)) { |
769 click_timer_.Stop(); | 773 click_timer_.Stop(); |
770 Send(new AutofillHostMsg_ClickFailed(routing_id(), | 774 Send(new AutofillHostMsg_ClickFailed(routing_id(), |
771 MISSING_ADVANCE)); | 775 MISSING_ADVANCE)); |
772 } | 776 } |
773 } | 777 } |
774 | 778 |
775 void AutofillAgent::OnWhitelistedForAutocheckout() { | 779 void AutofillAgent::OnWhitelistedForAutocheckout() { |
776 is_whitelisted_for_autocheckout_ = true; | 780 is_whitelisted_for_autocheckout_ = true; |
781 if (forms_have_changed_since_load_) { | |
ahutter
2013/04/02 21:34:53
no curlies
Dane Wallinga
2013/04/03 00:40:41
Done.
| |
782 SendDynamicFormsSeen(forms_seen_timestamp_); | |
783 } | |
777 } | 784 } |
778 | 785 |
779 void AutofillAgent::ClickFailed() { | 786 void AutofillAgent::ClickFailed() { |
780 Send(new AutofillHostMsg_ClickFailed(routing_id(), | 787 Send(new AutofillHostMsg_ClickFailed(routing_id(), |
781 CANNOT_PROCEED)); | 788 CANNOT_PROCEED)); |
782 } | 789 } |
783 | 790 |
784 void AutofillAgent::ShowSuggestions(const WebInputElement& element, | 791 void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
785 bool autofill_on_empty_values, | 792 bool autofill_on_empty_values, |
786 bool requires_caret_at_end, | 793 bool requires_caret_at_end, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 if (web_view) | 931 if (web_view) |
925 web_view->hidePopups(); | 932 web_view->hidePopups(); |
926 | 933 |
927 HideHostAutofillUi(); | 934 HideHostAutofillUi(); |
928 } | 935 } |
929 | 936 |
930 void AutofillAgent::HideHostAutofillUi() { | 937 void AutofillAgent::HideHostAutofillUi() { |
931 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); | 938 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); |
932 } | 939 } |
933 | 940 |
941 void AutofillAgent::didAssociateFormControls( | |
942 const WebKit::WebVector<WebKit::WebNode>& nodes) { | |
943 for (size_t i = 0; i < nodes.size(); ++i) { | |
944 WebKit::WebNode node = nodes[i]; | |
945 if (node.document().frame() == topmost_frame_) { | |
946 forms_seen_timestamp_ = base::TimeTicks::Now(); | |
947 forms_have_changed_since_load_ = true; | |
948 break; | |
949 } | |
950 } | |
951 | |
952 if (forms_have_changed_since_load_ && is_whitelisted_for_autocheckout_) { | |
ahutter
2013/04/02 21:34:53
no curlies.
ahutter
2013/04/02 21:34:53
no curlies
Dane Wallinga
2013/04/03 00:40:41
Done.
| |
953 SendDynamicFormsSeen(forms_seen_timestamp_); | |
954 } | |
955 } | |
956 | |
957 void AutofillAgent::SendDynamicFormsSeen(base::TimeTicks forms_seen_timestamp) { | |
Raman Kakilate
2013/04/02 21:39:46
forms_seen_timestamp is always a member variable f
Dane Wallinga
2013/04/03 00:40:41
works for me
| |
958 forms_have_changed_since_load_ = false; | |
959 bool has_more_forms = false; | |
960 std::vector<FormData> forms; | |
961 form_elements_.clear(); | |
962 has_more_forms = form_cache_.ExtractFormsAndFormElements( | |
963 *topmost_frame_, kRequiredAutofillFields, &forms, &form_elements_); | |
964 autofill::FormsSeenParam param = has_more_forms ? | |
965 autofill::PARTIAL_AND_DYNAMIC_FORMS_SEEN : autofill::DYNAMIC_FORMS_SEEN; | |
966 | |
967 if (!forms.empty()) { | |
968 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | |
969 forms_seen_timestamp, | |
970 param)); | |
971 } | |
972 } | |
973 | |
934 } // namespace autofill | 974 } // namespace autofill |
OLD | NEW |