Chromium Code Reviews| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // Always communicate to browser process for topmost frame. | 215 // Always communicate to browser process for topmost frame. |
| 216 if (!forms.empty() || !frame->parent()) { | 216 if (!forms.empty() || !frame->parent()) { |
| 217 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 217 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
| 218 forms_seen_timestamp_, | 218 forms_seen_timestamp_, |
| 219 has_more_forms)); | 219 has_more_forms, |
|
ahutter
2013/03/29 19:48:31
Might be good to collapse these bools into an enum
Dane Wallinga
2013/03/29 21:41:12
Bitwise stuff? You mean like in the enum define PA
ahutter
2013/03/29 21:53:08
Yes.
| |
| 220 false /* is_post_document_load */)); | |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { | 224 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { |
| 224 if (!frame->parent()) { | 225 if (!frame->parent()) { |
| 225 topmost_frame_ = NULL; | 226 topmost_frame_ = NULL; |
| 226 WebKit::WebURL provisional_url = | 227 WebKit::WebURL provisional_url = |
| 227 frame->provisionalDataSource()->request().url(); | 228 frame->provisionalDataSource()->request().url(); |
| 228 WebKit::WebURL current_url = frame->dataSource()->request().url(); | 229 WebKit::WebURL current_url = frame->dataSource()->request().url(); |
| 229 // If the URL of the topmost frame is changing and the current page is part | 230 // If the URL of the topmost frame is changing and the current page is part |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 std::vector<FormData> forms; | 725 std::vector<FormData> forms; |
| 725 form_cache_.ExtractFormsAndFormElements( | 726 form_cache_.ExtractFormsAndFormElements( |
| 726 *topmost_frame_, 0, &forms, &form_elements_); | 727 *topmost_frame_, 0, &forms, &form_elements_); |
| 727 | 728 |
| 728 // OnGetAllForms should only be called if AutofillAgent reported to | 729 // OnGetAllForms should only be called if AutofillAgent reported to |
| 729 // AutofillManager that there are more forms | 730 // AutofillManager that there are more forms |
| 730 DCHECK(!forms.empty()); | 731 DCHECK(!forms.empty()); |
| 731 | 732 |
| 732 // Report to AutofillManager that all forms are being sent. | 733 // Report to AutofillManager that all forms are being sent. |
| 733 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 734 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
| 734 forms_seen_timestamp_, false)); | 735 forms_seen_timestamp_, false, false)); |
|
ahutter
2013/03/29 19:48:31
same comment?
| |
| 735 } | 736 } |
| 736 | 737 |
| 737 void AutofillAgent::OnRequestAutocompleteResult( | 738 void AutofillAgent::OnRequestAutocompleteResult( |
| 738 WebFormElement::AutocompleteResult result, const FormData& form_data) { | 739 WebFormElement::AutocompleteResult result, const FormData& form_data) { |
| 739 if (in_flight_request_form_.isNull()) | 740 if (in_flight_request_form_.isNull()) |
| 740 return; | 741 return; |
| 741 | 742 |
| 742 if (result == WebFormElement::AutocompleteResultSuccess) | 743 if (result == WebFormElement::AutocompleteResultSuccess) |
| 743 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); | 744 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); |
| 744 | 745 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 768 if (!ClickElement(topmost_frame_->document(), | 769 if (!ClickElement(topmost_frame_->document(), |
| 769 click_element_descriptor)) { | 770 click_element_descriptor)) { |
| 770 click_timer_.Stop(); | 771 click_timer_.Stop(); |
| 771 Send(new AutofillHostMsg_ClickFailed(routing_id(), | 772 Send(new AutofillHostMsg_ClickFailed(routing_id(), |
| 772 MISSING_ADVANCE)); | 773 MISSING_ADVANCE)); |
| 773 } | 774 } |
| 774 } | 775 } |
| 775 | 776 |
| 776 void AutofillAgent::OnWhitelistedForAutocheckout() { | 777 void AutofillAgent::OnWhitelistedForAutocheckout() { |
| 777 is_whitelisted_for_autocheckout_ = true; | 778 is_whitelisted_for_autocheckout_ = true; |
| 779 if (forms_have_changed_since_load_) { | |
| 780 forms_have_changed_since_load_ = false; | |
| 781 bool has_more_forms = false; | |
| 782 std::vector<FormData> forms; | |
| 783 form_elements_.clear(); | |
| 784 has_more_forms = form_cache_.ExtractFormsAndFormElements( | |
| 785 *topmost_frame_, kRequiredAutofillFields, &forms, &form_elements_); | |
| 786 if (!forms.empty()) { | |
| 787 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | |
| 788 base::TimeTicks::Now(), | |
| 789 has_more_forms, | |
| 790 true /* is_post_document_load */)); | |
| 791 } | |
| 792 } | |
| 778 } | 793 } |
| 779 | 794 |
| 780 void AutofillAgent::ClickFailed() { | 795 void AutofillAgent::ClickFailed() { |
| 781 Send(new AutofillHostMsg_ClickFailed(routing_id(), | 796 Send(new AutofillHostMsg_ClickFailed(routing_id(), |
| 782 CANNOT_PROCEED)); | 797 CANNOT_PROCEED)); |
| 783 } | 798 } |
| 784 | 799 |
| 785 void AutofillAgent::ShowSuggestions(const WebInputElement& element, | 800 void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
| 786 bool autofill_on_empty_values, | 801 bool autofill_on_empty_values, |
| 787 bool requires_caret_at_end, | 802 bool requires_caret_at_end, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 if (web_view) | 940 if (web_view) |
| 926 web_view->hidePopups(); | 941 web_view->hidePopups(); |
| 927 | 942 |
| 928 HideHostAutofillUi(); | 943 HideHostAutofillUi(); |
| 929 } | 944 } |
| 930 | 945 |
| 931 void AutofillAgent::HideHostAutofillUi() { | 946 void AutofillAgent::HideHostAutofillUi() { |
| 932 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); | 947 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); |
| 933 } | 948 } |
| 934 | 949 |
| 950 void AutofillAgent::didAssociateFormControls(const WebKit::WebVector<WebKit::Web Node>& nodes) { | |
| 951 for (size_t i = 0; i < nodes.size(); ++i) { | |
|
ahutter
2013/03/29 19:48:31
Can't use an iterator?
Dane Wallinga
2013/03/29 21:41:12
Well at least in WebKit, it's preferred that index
| |
| 952 WebKit::WebNode node = nodes[i]; | |
| 953 if (node.document().frame() == topmost_frame_) { | |
| 954 forms_have_changed_since_load_ = true; | |
|
ahutter
2013/03/29 19:48:31
I think you only want to do this once if any of ht
Dane Wallinga
2013/03/29 21:41:12
I have a return further down.
ahutter
2013/03/29 21:53:08
I get that this works but it's more fragile to fut
Dane Wallinga
2013/04/02 19:50:53
Done.
| |
| 955 if (is_whitelisted_for_autocheckout_) { | |
| 956 forms_have_changed_since_load_ = false; | |
| 957 bool has_more_forms = false; | |
| 958 std::vector<FormData> forms; | |
| 959 form_elements_.clear(); | |
| 960 has_more_forms = form_cache_.ExtractFormsAndFormElements( | |
| 961 *topmost_frame_, kRequiredAutofillFields, &forms, &form_elements_); | |
| 962 if (!forms.empty()) { | |
| 963 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | |
| 964 base::TimeTicks::Now(), | |
| 965 has_more_forms, | |
| 966 true /* is_post_document_load */)); | |
| 967 } | |
| 968 } | |
| 969 return; | |
|
ahutter
2013/03/29 19:48:31
Oh. There's a return. That's why this does the r
Dane Wallinga
2013/03/29 21:41:12
Yeah, this one.
| |
| 970 } | |
| 971 } | |
| 972 } | |
| 973 | |
| 935 } // namespace autofill | 974 } // namespace autofill |
| OLD | NEW |