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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 if (!forms.empty() || !frame->parent()) { | 212 if (!forms.empty() || !frame->parent()) { |
213 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 213 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
214 forms_seen_timestamp_, | 214 forms_seen_timestamp_, |
215 has_more_forms)); | 215 has_more_forms)); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { | 219 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { |
220 if (!frame->parent()) { | 220 if (!frame->parent()) { |
221 topmost_frame_ = NULL; | 221 topmost_frame_ = NULL; |
222 WebKit::WebURL provisional_url = | 222 if (click_timer_.IsRunning()) { |
223 frame->provisionalDataSource()->request().url(); | |
224 WebKit::WebURL current_url = frame->dataSource()->request().url(); | |
225 // If the URL of the topmost frame is changing and the current page is part | |
226 // of an Autocheckout flow, the click was successful as long as the | |
227 // provisional load is committed. | |
228 if (provisional_url != current_url && click_timer_.IsRunning()) { | |
Ilya Sherman
2013/03/27 22:27:21
Hmm, why is this check no longer relevant?
Ilya Sherman
2013/03/27 22:35:09
Per IM discussion, this is now handled on the brow
| |
229 click_timer_.Stop(); | 223 click_timer_.Stop(); |
230 autocheckout_click_in_progress_ = true; | 224 autocheckout_click_in_progress_ = true; |
231 } | 225 } |
232 } | 226 } |
233 } | 227 } |
234 | 228 |
235 void AutofillAgent::DidFailProvisionalLoad(WebFrame* frame, | 229 void AutofillAgent::DidFailProvisionalLoad(WebFrame* frame, |
236 const WebKit::WebURLError& error) { | 230 const WebKit::WebURLError& error) { |
237 if (autocheckout_click_in_progress_) { | 231 if (!frame->parent() && autocheckout_click_in_progress_) { |
Ilya Sherman
2013/03/27 22:27:21
How do you know that all clicks in Autocheckout wi
ahutter
2013/03/27 22:41:45
I guess I don't but so far they have. If/when we
| |
238 autocheckout_click_in_progress_ = false; | 232 autocheckout_click_in_progress_ = false; |
239 ClickFailed(); | 233 ClickFailed(); |
240 } | 234 } |
241 } | 235 } |
242 | 236 |
243 void AutofillAgent::DidCommitProvisionalLoad(WebFrame* frame, | 237 void AutofillAgent::DidCommitProvisionalLoad(WebFrame* frame, |
244 bool is_new_navigation) { | 238 bool is_new_navigation) { |
245 autocheckout_click_in_progress_ = false; | |
246 in_flight_request_form_.reset(); | 239 in_flight_request_form_.reset(); |
240 if (!frame->parent()) | |
241 autocheckout_click_in_progress_ = false; | |
247 } | 242 } |
248 | 243 |
249 void AutofillAgent::FrameDetached(WebFrame* frame) { | 244 void AutofillAgent::FrameDetached(WebFrame* frame) { |
250 form_cache_.ResetFrame(*frame); | 245 form_cache_.ResetFrame(*frame); |
251 if (!frame->parent()) { | 246 if (!frame->parent()) { |
252 // |frame| is about to be destroyed so we need to clear |top_most_frame_|. | 247 // |frame| is about to be destroyed so we need to clear |top_most_frame_|. |
253 topmost_frame_ = NULL; | 248 topmost_frame_ = NULL; |
254 click_timer_.Stop(); | 249 click_timer_.Stop(); |
255 } | 250 } |
256 } | 251 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 | 742 |
748 void AutofillAgent::OnFillFormsAndClick( | 743 void AutofillAgent::OnFillFormsAndClick( |
749 const std::vector<FormData>& forms, | 744 const std::vector<FormData>& forms, |
750 const WebElementDescriptor& click_element_descriptor) { | 745 const WebElementDescriptor& click_element_descriptor) { |
751 DCHECK_EQ(forms.size(), form_elements_.size()); | 746 DCHECK_EQ(forms.size(), form_elements_.size()); |
752 | 747 |
753 // Fill the form. | 748 // Fill the form. |
754 for (size_t i = 0; i < forms.size(); ++i) | 749 for (size_t i = 0; i < forms.size(); ++i) |
755 FillFormIncludingNonFocusableElements(forms[i], form_elements_[i]); | 750 FillFormIncludingNonFocusableElements(forms[i], form_elements_[i]); |
756 | 751 |
752 // Exit early if there is nothing to click. | |
753 if (click_element_descriptor.retrieval_method == WebElementDescriptor::NONE) | |
754 return; | |
755 | |
757 // It's possible that clicking the element to proceed in an Autocheckout | 756 // It's possible that clicking the element to proceed in an Autocheckout |
758 // flow will not actually proceed to the next step in the flow, e.g. there | 757 // flow will not actually proceed to the next step in the flow, e.g. there |
759 // is a new required field that Autocheckout does not know how to fill. In | 758 // is a new required field that Autocheckout does not know how to fill. In |
760 // order to capture this case and present the user with an error a timer is | 759 // order to capture this case and present the user with an error a timer is |
761 // set that informs the browser of the error. |click_timer_| has to be started | 760 // set that informs the browser of the error. |click_timer_| has to be started |
762 // before clicking so it can start before DidStartProvisionalLoad started. | 761 // before clicking so it can start before DidStartProvisionalLoad started. |
763 click_timer_.Start(FROM_HERE, | 762 click_timer_.Start(FROM_HERE, |
764 base::TimeDelta::FromSeconds(kAutocheckoutClickTimeout), | 763 base::TimeDelta::FromSeconds(kAutocheckoutClickTimeout), |
765 this, | 764 this, |
766 &AutofillAgent::ClickFailed); | 765 &AutofillAgent::ClickFailed); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
921 web_view->hidePopups(); | 920 web_view->hidePopups(); |
922 | 921 |
923 HideHostAutofillUi(); | 922 HideHostAutofillUi(); |
924 } | 923 } |
925 | 924 |
926 void AutofillAgent::HideHostAutofillUi() { | 925 void AutofillAgent::HideHostAutofillUi() { |
927 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); | 926 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); |
928 } | 927 } |
929 | 928 |
930 } // namespace autofill | 929 } // namespace autofill |
OLD | NEW |