OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content/renderer/autofill_agent.h" | 5 #include "components/autofill/content/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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 OnFieldTypePredictionsAvailable) | 150 OnFieldTypePredictionsAvailable) |
151 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) | 151 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) |
152 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) | 152 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) |
153 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) | 153 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) |
154 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, | 154 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, |
155 OnPreviewFieldWithValue) | 155 OnPreviewFieldWithValue) |
156 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, | 156 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, |
157 OnAcceptDataListSuggestion) | 157 OnAcceptDataListSuggestion) |
158 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, | 158 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, |
159 OnAcceptPasswordAutofillSuggestion) | 159 OnAcceptPasswordAutofillSuggestion) |
| 160 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPassword, OnPreviewPassword) |
160 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, | 161 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
161 OnRequestAutocompleteResult) | 162 OnRequestAutocompleteResult) |
162 IPC_MESSAGE_UNHANDLED(handled = false) | 163 IPC_MESSAGE_UNHANDLED(handled = false) |
163 IPC_END_MESSAGE_MAP() | 164 IPC_END_MESSAGE_MAP() |
164 return handled; | 165 return handled; |
165 } | 166 } |
166 | 167 |
167 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 168 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { |
168 // Record timestamp on document load. This is used to record overhead of | 169 // Record timestamp on document load. This is used to record overhead of |
169 // Autofill feature. | 170 // Autofill feature. |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 PreviewForm(form, element_); | 430 PreviewForm(form, element_); |
430 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); | 431 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); |
431 } | 432 } |
432 | 433 |
433 void AutofillAgent::OnClearForm() { | 434 void AutofillAgent::OnClearForm() { |
434 form_cache_.ClearFormWithElement(element_); | 435 form_cache_.ClearFormWithElement(element_); |
435 } | 436 } |
436 | 437 |
437 void AutofillAgent::OnClearPreviewedForm() { | 438 void AutofillAgent::OnClearPreviewedForm() { |
438 if (!element_.isNull()) { | 439 if (!element_.isNull()) { |
439 if (password_autofill_agent_->DidClearAutofillSelection(element_)) | 440 if (password_autofill_agent_->DidClearAutofillSelection(element_) && |
| 441 !is_password_previewed_) |
440 return; | 442 return; |
441 | 443 |
442 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); | 444 if(is_password_previewed_) { |
| 445 ClearPreviewedFormWithElement( |
| 446 element_, |
| 447 REQUIRE_NONE, |
| 448 was_query_node_autofilled_, |
| 449 password_autofill_agent_->WasPasswordAutofilled()); |
| 450 } else { |
| 451 ClearPreviewedFormWithElement(element_, |
| 452 REQUIRE_AUTOCOMPLETE, |
| 453 was_query_node_autofilled_, |
| 454 false); |
| 455 } |
443 } else { | 456 } else { |
444 // TODO(isherman): There seem to be rare cases where this code *is* | 457 // TODO(isherman): There seem to be rare cases where this code *is* |
445 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would | 458 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would |
446 // understand those cases and fix the code to avoid them. However, so far I | 459 // understand those cases and fix the code to avoid them. However, so far I |
447 // have been unable to reproduce such a case locally. If you hit this | 460 // have been unable to reproduce such a case locally. If you hit this |
448 // NOTREACHED(), please file a bug against me. | 461 // NOTREACHED(), please file a bug against me. |
449 NOTREACHED(); | 462 NOTREACHED(); |
450 } | 463 } |
451 } | 464 } |
452 | 465 |
(...skipping 13 matching lines...) Expand all Loading... |
466 const base::string16& username) { | 479 const base::string16& username) { |
467 // We need to make sure this is handled here because the browser process | 480 // We need to make sure this is handled here because the browser process |
468 // skipped it handling because it believed it would be handled here. If it | 481 // skipped it handling because it believed it would be handled here. If it |
469 // isn't handled here then the browser logic needs to be updated. | 482 // isn't handled here then the browser logic needs to be updated. |
470 bool handled = password_autofill_agent_->DidAcceptAutofillSuggestion( | 483 bool handled = password_autofill_agent_->DidAcceptAutofillSuggestion( |
471 element_, | 484 element_, |
472 username); | 485 username); |
473 DCHECK(handled); | 486 DCHECK(handled); |
474 } | 487 } |
475 | 488 |
| 489 void AutofillAgent::OnPreviewPassword(const base::string16& username) { |
| 490 was_query_node_autofilled_ = element_.isAutofilled(); |
| 491 bool handled = password_autofill_agent_->DidSelectAutofillSuggestion( |
| 492 element_, |
| 493 username); |
| 494 is_password_previewed_ = handled; |
| 495 DCHECK(handled); |
| 496 } |
| 497 |
476 void AutofillAgent::OnRequestAutocompleteResult( | 498 void AutofillAgent::OnRequestAutocompleteResult( |
477 WebFormElement::AutocompleteResult result, | 499 WebFormElement::AutocompleteResult result, |
478 const FormData& form_data) { | 500 const FormData& form_data) { |
479 if (in_flight_request_form_.isNull()) | 501 if (in_flight_request_form_.isNull()) |
480 return; | 502 return; |
481 | 503 |
482 if (result == WebFormElement::AutocompleteResultSuccess) { | 504 if (result == WebFormElement::AutocompleteResultSuccess) { |
483 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); | 505 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); |
484 if (!in_flight_request_form_.checkValidityWithoutDispatchingEvents()) | 506 if (!in_flight_request_form_.checkValidityWithoutDispatchingEvents()) |
485 result = WebFormElement::AutocompleteResultErrorInvalid; | 507 result = WebFormElement::AutocompleteResultErrorInvalid; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 // Only monitors dynamic forms created in the top frame. Dynamic forms | 643 // Only monitors dynamic forms created in the top frame. Dynamic forms |
622 // inserted in iframes are not captured yet. | 644 // inserted in iframes are not captured yet. |
623 if (frame && !frame->parent()) { | 645 if (frame && !frame->parent()) { |
624 password_autofill_agent_->OnDynamicFormsSeen(frame); | 646 password_autofill_agent_->OnDynamicFormsSeen(frame); |
625 return; | 647 return; |
626 } | 648 } |
627 } | 649 } |
628 } | 650 } |
629 | 651 |
630 } // namespace autofill | 652 } // namespace autofill |
OLD | NEW |