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 "chrome/renderer/autofill/autofill_agent.h" | 5 #include "chrome/renderer/autofill/autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, | 79 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, |
80 OnSetAutofillActionFill) | 80 OnSetAutofillActionFill) |
81 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, | 81 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, |
82 OnClearForm) | 82 OnClearForm) |
83 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, | 83 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, |
84 OnSetAutofillActionPreview) | 84 OnSetAutofillActionPreview) |
85 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, | 85 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, |
86 OnClearPreviewedForm) | 86 OnClearPreviewedForm) |
87 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, | 87 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, |
88 OnSetNodeText) | 88 OnSetNodeText) |
89 IPC_MESSAGE_HANDLER(AutofillMsg_PasswordAcceptAutofillSuggestion, | |
90 OnPasswordAcceptAutofillSuggestion) | |
89 IPC_MESSAGE_UNHANDLED(handled = false) | 91 IPC_MESSAGE_UNHANDLED(handled = false) |
90 IPC_END_MESSAGE_MAP() | 92 IPC_END_MESSAGE_MAP() |
91 return handled; | 93 return handled; |
92 } | 94 } |
93 | 95 |
94 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 96 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { |
95 // The document has now been fully loaded. Scan for forms to be sent up to | 97 // The document has now been fully loaded. Scan for forms to be sent up to |
96 // the browser. | 98 // the browser. |
97 std::vector<webkit::forms::FormData> forms; | 99 std::vector<webkit::forms::FormData> forms; |
98 form_cache_.ExtractForms(*frame, &forms); | 100 form_cache_.ExtractForms(*frame, &forms); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 } | 393 } |
392 | 394 |
393 void AutofillAgent::OnClearPreviewedForm() { | 395 void AutofillAgent::OnClearPreviewedForm() { |
394 didClearAutofillSelection(autofill_query_element_); | 396 didClearAutofillSelection(autofill_query_element_); |
395 } | 397 } |
396 | 398 |
397 void AutofillAgent::OnSetNodeText(const string16& value) { | 399 void AutofillAgent::OnSetNodeText(const string16& value) { |
398 SetNodeText(value, &autofill_query_element_); | 400 SetNodeText(value, &autofill_query_element_); |
399 } | 401 } |
400 | 402 |
403 void AutofillAgent::OnPasswordAcceptAutofillSuggestion(const string16& value) { | |
404 password_autofill_manager_->DidAcceptAutofillSuggestion( | |
405 autofill_query_element_, | |
406 value); | |
Ilya Sherman
2012/03/15 18:27:41
nit: Can we DCHECK that this returns true? (Commo
csharp
2012/03/16 20:21:12
Done.
| |
407 } | |
408 | |
401 void AutofillAgent::ShowSuggestions(const WebInputElement& element, | 409 void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
402 bool autofill_on_empty_values, | 410 bool autofill_on_empty_values, |
403 bool requires_caret_at_end, | 411 bool requires_caret_at_end, |
404 bool display_warning_if_disabled) { | 412 bool display_warning_if_disabled) { |
405 // If autocomplete is disabled at the form level, then we might want to show | 413 // If autocomplete is disabled at the form level, then we might want to show |
406 // a warning in place of suggestions. However, if autocomplete is disabled | 414 // a warning in place of suggestions. However, if autocomplete is disabled |
407 // specifically for this field, we never want to show a warning. Otherwise, | 415 // specifically for this field, we never want to show a warning. Otherwise, |
408 // we might interfere with custom popups (e.g. search suggestions) used by | 416 // we might interfere with custom popups (e.g. search suggestions) used by |
409 // the website. | 417 // the website. |
410 const WebFormElement form = element.form(); | 418 const WebFormElement form = element.form(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 | 488 |
481 void AutofillAgent::SetNodeText(const string16& value, | 489 void AutofillAgent::SetNodeText(const string16& value, |
482 WebKit::WebInputElement* node) { | 490 WebKit::WebInputElement* node) { |
483 string16 substring = value; | 491 string16 substring = value; |
484 substring = substring.substr(0, node->maxLength()); | 492 substring = substring.substr(0, node->maxLength()); |
485 | 493 |
486 node->setValue(substring, true); | 494 node->setValue(substring, true); |
487 } | 495 } |
488 | 496 |
489 } // namespace autofill | 497 } // namespace autofill |
OLD | NEW |