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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 | 69 |
70 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { | 70 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
71 bool handled = true; | 71 bool handled = true; |
72 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) | 72 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) |
73 IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned) | 73 IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned) |
74 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) | 74 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) |
75 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, | 75 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, |
76 OnFieldTypePredictionsAvailable) | 76 OnFieldTypePredictionsAvailable) |
77 IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex, | 77 IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex, |
78 OnSelectAutofillSuggestionAtIndex) | 78 OnSelectAutofillSuggestionAtIndex) |
79 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, | |
80 OnSetAutofillActionFill) | |
81 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, | |
82 OnSetAutofillActionPreview) | |
83 IPC_MESSAGE_HANDLER(AutofillMsg_ClearAutofillSelection, | |
84 OnClearAutofillSelection) | |
85 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, | |
86 OnClearForm) | |
87 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, | |
88 OnSetNodeText) | |
79 IPC_MESSAGE_UNHANDLED(handled = false) | 89 IPC_MESSAGE_UNHANDLED(handled = false) |
80 IPC_END_MESSAGE_MAP() | 90 IPC_END_MESSAGE_MAP() |
81 return handled; | 91 return handled; |
82 } | 92 } |
83 | 93 |
84 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 94 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { |
85 // The document has now been fully loaded. Scan for forms to be sent up to | 95 // The document has now been fully loaded. Scan for forms to be sent up to |
86 // the browser. | 96 // the browser. |
87 std::vector<webkit::forms::FormData> forms; | 97 std::vector<webkit::forms::FormData> forms; |
88 form_cache_.ExtractForms(*frame, &forms); | 98 form_cache_.ExtractForms(*frame, &forms); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 form_cache_.ShowPredictions(forms[i]); | 369 form_cache_.ShowPredictions(forms[i]); |
360 } | 370 } |
361 } | 371 } |
362 | 372 |
363 void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) { | 373 void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) { |
364 NOTIMPLEMENTED(); | 374 NOTIMPLEMENTED(); |
365 // TODO(jrg): enable once changes land in WebKit | 375 // TODO(jrg): enable once changes land in WebKit |
366 // render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex); | 376 // render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex); |
367 } | 377 } |
368 | 378 |
379 void AutofillAgent::OnSetAutofillActionFill() { | |
380 autofill_action_ = AUTOFILL_FILL; | |
381 was_query_node_autofilled_ = autofill_query_element_.isAutofilled(); | |
Ilya Sherman
2012/02/04 04:10:52
Hmm, can we move this into AutofillAgent::OnFormDa
csharp
2012/02/07 22:30:58
I don't think this can cause any trouble. The only
| |
382 } | |
383 | |
384 void AutofillAgent::OnSetAutofillActionPreview() { | |
385 didClearAutofillSelection(autofill_query_element_); | |
Ilya Sherman
2012/02/04 04:10:52
Likewise, I think we could move this into the AUTO
csharp
2012/02/07 22:30:58
Seems like a good idea. Done.
| |
386 | |
387 autofill_action_ = AUTOFILL_PREVIEW; | |
388 was_query_node_autofilled_ = autofill_query_element_.isAutofilled(); | |
389 } | |
390 | |
391 void AutofillAgent::OnClearForm() { | |
392 form_cache_.ClearFormWithElement(autofill_query_element_); | |
393 } | |
394 | |
395 void AutofillAgent::OnClearAutofillSelection() { | |
396 didClearAutofillSelection(autofill_query_element_); | |
397 } | |
398 | |
399 void AutofillAgent::OnSetNodeText(string16 value) { | |
400 // TODO add a check that we are setting the correct element | |
Ilya Sherman
2012/02/04 04:10:52
nit: "TODO" -> "TODO(csharp):"
Ilya Sherman
2012/02/04 04:10:52
What sort of check are you thinking of?
csharp
2012/02/07 22:30:58
I had been thinking of making sure that autofill_q
| |
401 string16 substring = value; | |
402 substring = substring.substr(0, autofill_query_element_.maxLength()); | |
403 | |
404 autofill_query_element_.setValue(value, true); | |
405 } | |
406 | |
369 void AutofillAgent::ShowSuggestions(const WebInputElement& element, | 407 void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
370 bool autofill_on_empty_values, | 408 bool autofill_on_empty_values, |
371 bool requires_caret_at_end, | 409 bool requires_caret_at_end, |
372 bool display_warning_if_disabled) { | 410 bool display_warning_if_disabled) { |
373 // If autocomplete is disabled at the form level, then we might want to show | 411 // If autocomplete is disabled at the form level, then we might want to show |
374 // a warning in place of suggestions. However, if autocomplete is disabled | 412 // a warning in place of suggestions. However, if autocomplete is disabled |
375 // specifically for this field, we never want to show a warning. Otherwise, | 413 // specifically for this field, we never want to show a warning. Otherwise, |
376 // we might interfere with custom popups (e.g. search suggestions) used by | 414 // we might interfere with custom popups (e.g. search suggestions) used by |
377 // the website. | 415 // the website. |
378 const WebFormElement form = element.form(); | 416 const WebFormElement form = element.form(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 return; | 479 return; |
442 } | 480 } |
443 | 481 |
444 autofill_action_ = action; | 482 autofill_action_ = action; |
445 was_query_node_autofilled_ = field.is_autofilled; | 483 was_query_node_autofilled_ = field.is_autofilled; |
446 Send(new AutofillHostMsg_FillAutofillFormData( | 484 Send(new AutofillHostMsg_FillAutofillFormData( |
447 routing_id(), autofill_query_id_, form, field, unique_id)); | 485 routing_id(), autofill_query_id_, form, field, unique_id)); |
448 } | 486 } |
449 | 487 |
450 } // namespace autofill | 488 } // namespace autofill |
OLD | NEW |