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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 AutofillAgent::~AutofillAgent() {} | 151 AutofillAgent::~AutofillAgent() {} |
| 152 | 152 |
| 153 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { | 153 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| 154 bool handled = true; | 154 bool handled = true; |
| 155 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) | 155 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) |
| 156 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) | 156 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) |
| 157 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, | 157 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, |
| 158 OnFieldTypePredictionsAvailable) | 158 OnFieldTypePredictionsAvailable) |
| 159 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, | 159 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, |
| 160 OnSetAutofillActionFill) | 160 OnSetAutofillActionFill) |
| 161 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, | 161 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) |
| 162 OnClearForm) | |
| 163 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, | 162 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, |
| 164 OnSetAutofillActionPreview) | 163 OnSetAutofillActionPreview) |
| 165 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, | 164 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) |
| 166 OnClearPreviewedForm) | 165 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, OnSetNodeText) |
| 167 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, | |
| 168 OnSetNodeText) | |
| 169 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, | 166 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, |
| 170 OnAcceptDataListSuggestion) | 167 OnAcceptDataListSuggestion) |
| 171 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, | 168 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, |
| 172 OnAcceptPasswordAutofillSuggestion) | 169 OnAcceptPasswordAutofillSuggestion) |
| 173 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, | 170 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
| 174 OnRequestAutocompleteResult) | 171 OnRequestAutocompleteResult) |
| 175 IPC_MESSAGE_HANDLER(AutofillMsg_PageShown, | 172 IPC_MESSAGE_HANDLER(AutofillMsg_PageShown, OnPageShown) |
| 176 OnPageShown) | |
| 177 IPC_MESSAGE_UNHANDLED(handled = false) | 173 IPC_MESSAGE_UNHANDLED(handled = false) |
| 178 IPC_END_MESSAGE_MAP() | 174 IPC_END_MESSAGE_MAP() |
| 179 return handled; | 175 return handled; |
| 180 } | 176 } |
| 181 | 177 |
| 182 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 178 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { |
| 183 // Record timestamp on document load. This is used to record overhead of | 179 // Record timestamp on document load. This is used to record overhead of |
| 184 // Autofill feature. | 180 // Autofill feature. |
| 185 forms_seen_timestamp_ = base::TimeTicks::Now(); | 181 forms_seen_timestamp_ = base::TimeTicks::Now(); |
| 186 | 182 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 bool was_focused, | 303 bool was_focused, |
| 308 bool is_focused) { | 304 bool is_focused) { |
| 309 if (was_focused) | 305 if (was_focused) |
| 310 ShowSuggestions(element, true, false, true, false); | 306 ShowSuggestions(element, true, false, true, false); |
| 311 } | 307 } |
| 312 | 308 |
| 313 void AutofillAgent::InputElementLostFocus() { | 309 void AutofillAgent::InputElementLostFocus() { |
| 314 HideAutofillUI(); | 310 HideAutofillUI(); |
| 315 } | 311 } |
| 316 | 312 |
| 317 void AutofillAgent::didClearAutofillSelection(const WebNode& node) { | |
| 318 if (password_autofill_agent_->DidClearAutofillSelection(node)) | |
| 319 return; | |
| 320 | |
| 321 if (!element_.isNull() && node == element_) { | |
| 322 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); | |
| 323 } else { | |
| 324 // TODO(isherman): There seem to be rare cases where this code *is* | |
| 325 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would | |
| 326 // understand those cases and fix the code to avoid them. However, so far I | |
| 327 // have been unable to reproduce such a case locally. If you hit this | |
| 328 // NOTREACHED(), please file a bug against me. | |
| 329 NOTREACHED(); | |
| 330 } | |
| 331 } | |
| 332 | |
| 333 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 313 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 334 password_autofill_agent_->TextFieldDidEndEditing(element); | 314 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 335 has_shown_autofill_popup_for_current_edit_ = false; | 315 has_shown_autofill_popup_for_current_edit_ = false; |
| 336 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 316 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 337 } | 317 } |
| 338 | 318 |
| 339 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { | 319 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { |
| 340 if (ignore_text_changes_) | 320 if (ignore_text_changes_) |
| 341 return; | 321 return; |
| 342 | 322 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 | 438 |
| 459 void AutofillAgent::OnClearForm() { | 439 void AutofillAgent::OnClearForm() { |
| 460 form_cache_.ClearFormWithElement(element_); | 440 form_cache_.ClearFormWithElement(element_); |
| 461 } | 441 } |
| 462 | 442 |
| 463 void AutofillAgent::OnSetAutofillActionPreview() { | 443 void AutofillAgent::OnSetAutofillActionPreview() { |
| 464 autofill_action_ = AUTOFILL_PREVIEW; | 444 autofill_action_ = AUTOFILL_PREVIEW; |
| 465 } | 445 } |
| 466 | 446 |
| 467 void AutofillAgent::OnClearPreviewedForm() { | 447 void AutofillAgent::OnClearPreviewedForm() { |
| 468 didClearAutofillSelection(element_); | 448 if (password_autofill_agent_->DidClearAutofillSelection(element_)) |
| 449 return; | |
| 450 | |
| 451 if (!element_.isNull()) { | |
|
Dan Beam
2013/12/20 03:52:34
why'd you remove the && node == element_ ?
Ilya Sherman
2013/12/20 03:54:37
Because |node| doesn't exist anymore, or rather is
Dan Beam
2013/12/20 03:55:13
oh, duh, sorry
| |
| 452 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); | |
| 453 } else { | |
| 454 // TODO(isherman): There seem to be rare cases where this code *is* | |
| 455 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would | |
| 456 // understand those cases and fix the code to avoid them. However, so far I | |
| 457 // have been unable to reproduce such a case locally. If you hit this | |
| 458 // NOTREACHED(), please file a bug against me. | |
| 459 NOTREACHED(); | |
| 460 } | |
| 469 } | 461 } |
| 470 | 462 |
| 471 void AutofillAgent::OnSetNodeText(const base::string16& value) { | 463 void AutofillAgent::OnSetNodeText(const base::string16& value) { |
| 472 SetNodeText(value, &element_); | 464 SetNodeText(value, &element_); |
| 473 } | 465 } |
| 474 | 466 |
| 475 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { | 467 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { |
| 476 AcceptDataListSuggestion(value); | 468 AcceptDataListSuggestion(value); |
| 477 } | 469 } |
| 478 | 470 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 // Only monitors dynamic forms created in the top frame. Dynamic forms | 635 // Only monitors dynamic forms created in the top frame. Dynamic forms |
| 644 // inserted in iframes are not captured yet. | 636 // inserted in iframes are not captured yet. |
| 645 if (!frame->parent()) { | 637 if (!frame->parent()) { |
| 646 password_autofill_agent_->OnDynamicFormsSeen(frame); | 638 password_autofill_agent_->OnDynamicFormsSeen(frame); |
| 647 return; | 639 return; |
| 648 } | 640 } |
| 649 } | 641 } |
| 650 } | 642 } |
| 651 | 643 |
| 652 } // namespace autofill | 644 } // namespace autofill |
| OLD | NEW |