Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 OnFieldTypePredictionsAvailable) | 155 OnFieldTypePredictionsAvailable) |
| 156 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) | 156 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) |
| 157 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) | 157 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) |
| 158 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) | 158 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) |
| 159 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, | 159 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, |
| 160 OnPreviewFieldWithValue) | 160 OnPreviewFieldWithValue) |
| 161 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, | 161 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, |
| 162 OnAcceptDataListSuggestion) | 162 OnAcceptDataListSuggestion) |
| 163 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, | 163 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, |
| 164 OnAcceptPasswordAutofillSuggestion) | 164 OnAcceptPasswordAutofillSuggestion) |
| 165 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordAutofillSuggestion, | |
| 166 OnPreviewPasswordAutofillSuggestion) | |
| 165 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, | 167 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
| 166 OnRequestAutocompleteResult) | 168 OnRequestAutocompleteResult) |
| 167 IPC_MESSAGE_UNHANDLED(handled = false) | 169 IPC_MESSAGE_UNHANDLED(handled = false) |
| 168 IPC_END_MESSAGE_MAP() | 170 IPC_END_MESSAGE_MAP() |
| 169 return handled; | 171 return handled; |
| 170 } | 172 } |
| 171 | 173 |
| 172 void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) { | 174 void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) { |
| 173 // Record timestamp on document load. This is used to record overhead of | 175 // Record timestamp on document load. This is used to record overhead of |
| 174 // Autofill feature. | 176 // Autofill feature. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 | 481 |
| 480 void AutofillAgent::OnClearForm() { | 482 void AutofillAgent::OnClearForm() { |
| 481 form_cache_.ClearFormWithElement(element_); | 483 form_cache_.ClearFormWithElement(element_); |
| 482 } | 484 } |
| 483 | 485 |
| 484 void AutofillAgent::OnClearPreviewedForm() { | 486 void AutofillAgent::OnClearPreviewedForm() { |
| 485 if (!element_.isNull()) { | 487 if (!element_.isNull()) { |
| 486 if (password_autofill_agent_->DidClearAutofillSelection(element_)) | 488 if (password_autofill_agent_->DidClearAutofillSelection(element_)) |
| 487 return; | 489 return; |
| 488 | 490 |
| 489 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); | 491 ClearPreviewedFormWithElement( |
| 492 element_, | |
| 493 was_query_node_autofilled_, | |
| 494 password_autofill_agent_->WasPasswordAutofilled()); | |
|
Ilya Sherman
2014/05/13 00:44:05
This call site should not need to change as a resu
ziran.sun
2014/05/14 15:35:12
Done.
| |
| 490 } else { | 495 } else { |
| 491 // TODO(isherman): There seem to be rare cases where this code *is* | 496 // TODO(isherman): There seem to be rare cases where this code *is* |
| 492 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would | 497 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would |
| 493 // understand those cases and fix the code to avoid them. However, so far I | 498 // understand those cases and fix the code to avoid them. However, so far I |
| 494 // have been unable to reproduce such a case locally. If you hit this | 499 // have been unable to reproduce such a case locally. If you hit this |
| 495 // NOTREACHED(), please file a bug against me. | 500 // NOTREACHED(), please file a bug against me. |
| 496 NOTREACHED(); | 501 NOTREACHED(); |
| 497 } | 502 } |
| 498 } | 503 } |
| 499 | 504 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 516 void AutofillAgent::OnAcceptPasswordAutofillSuggestion( | 521 void AutofillAgent::OnAcceptPasswordAutofillSuggestion( |
| 517 const base::string16& username, | 522 const base::string16& username, |
| 518 const base::string16& password) { | 523 const base::string16& password) { |
| 519 bool handled = password_autofill_agent_->AcceptSuggestion( | 524 bool handled = password_autofill_agent_->AcceptSuggestion( |
| 520 element_, | 525 element_, |
| 521 username, | 526 username, |
| 522 password); | 527 password); |
| 523 DCHECK(handled); | 528 DCHECK(handled); |
| 524 } | 529 } |
| 525 | 530 |
| 531 void AutofillAgent::OnPreviewPasswordAutofillSuggestion( | |
| 532 const base::string16& username, | |
| 533 const base::string16& password) { | |
| 534 was_query_node_autofilled_ = element_.isAutofilled(); | |
|
Ilya Sherman
2014/05/13 00:44:05
This should be tracked internally to the PasswordA
ziran.sun
2014/05/14 15:35:12
Done.
| |
| 535 bool handled = password_autofill_agent_->SelectSuggestion( | |
| 536 element_, | |
| 537 username, | |
| 538 password); | |
| 539 DCHECK(handled); | |
| 540 } | |
| 541 | |
| 526 void AutofillAgent::OnRequestAutocompleteResult( | 542 void AutofillAgent::OnRequestAutocompleteResult( |
| 527 WebFormElement::AutocompleteResult result, | 543 WebFormElement::AutocompleteResult result, |
| 528 const base::string16& message, | 544 const base::string16& message, |
| 529 const FormData& form_data) { | 545 const FormData& form_data) { |
| 530 if (in_flight_request_form_.isNull()) | 546 if (in_flight_request_form_.isNull()) |
| 531 return; | 547 return; |
| 532 | 548 |
| 533 if (result == WebFormElement::AutocompleteResultSuccess) { | 549 if (result == WebFormElement::AutocompleteResultSuccess) { |
| 534 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); | 550 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); |
| 535 if (!in_flight_request_form_.checkValidity()) | 551 if (!in_flight_request_form_.checkValidity()) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 // Only monitors dynamic forms created in the top frame. Dynamic forms | 716 // Only monitors dynamic forms created in the top frame. Dynamic forms |
| 701 // inserted in iframes are not captured yet. | 717 // inserted in iframes are not captured yet. |
| 702 if (frame && !frame->parent()) { | 718 if (frame && !frame->parent()) { |
| 703 password_autofill_agent_->OnDynamicFormsSeen(frame); | 719 password_autofill_agent_->OnDynamicFormsSeen(frame); |
| 704 return; | 720 return; |
| 705 } | 721 } |
| 706 } | 722 } |
| 707 } | 723 } |
| 708 | 724 |
| 709 } // namespace autofill | 725 } // namespace autofill |
| OLD | NEW |