OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 AutofillAgent::~AutofillAgent() {} | 66 AutofillAgent::~AutofillAgent() {} |
67 | 67 |
68 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { | 68 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
69 bool handled = true; | 69 bool handled = true; |
70 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) | 70 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) |
71 IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned) | 71 IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned) |
72 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) | 72 IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) |
73 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, | 73 IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, |
74 OnFieldTypePredictionsAvailable) | 74 OnFieldTypePredictionsAvailable) |
| 75 IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex, |
| 76 OnSelectAutofillSuggestionAtIndex) |
75 IPC_MESSAGE_UNHANDLED(handled = false) | 77 IPC_MESSAGE_UNHANDLED(handled = false) |
76 IPC_END_MESSAGE_MAP() | 78 IPC_END_MESSAGE_MAP() |
77 return handled; | 79 return handled; |
78 } | 80 } |
79 | 81 |
80 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 82 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { |
81 // The document has now been fully loaded. Scan for forms to be sent up to | 83 // The document has now been fully loaded. Scan for forms to be sent up to |
82 // the browser. | 84 // the browser. |
83 std::vector<webkit_glue::FormData> forms; | 85 std::vector<webkit_glue::FormData> forms; |
84 form_cache_.ExtractForms(*frame, &forms); | 86 form_cache_.ExtractForms(*frame, &forms); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 autofill_action_ = AUTOFILL_NONE; | 345 autofill_action_ = AUTOFILL_NONE; |
344 } | 346 } |
345 | 347 |
346 void AutofillAgent::OnFieldTypePredictionsAvailable( | 348 void AutofillAgent::OnFieldTypePredictionsAvailable( |
347 const std::vector<FormDataPredictions>& forms) { | 349 const std::vector<FormDataPredictions>& forms) { |
348 for (size_t i = 0; i < forms.size(); ++i) { | 350 for (size_t i = 0; i < forms.size(); ++i) { |
349 form_cache_.ShowPredictions(forms[i]); | 351 form_cache_.ShowPredictions(forms[i]); |
350 } | 352 } |
351 } | 353 } |
352 | 354 |
| 355 void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) { |
| 356 NOTIMPLEMENTED(); |
| 357 // TODO(jrg): enable once changes land in WebKit |
| 358 // render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex); |
| 359 } |
| 360 |
353 void AutofillAgent::ShowSuggestions(const WebInputElement& element, | 361 void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
354 bool autofill_on_empty_values, | 362 bool autofill_on_empty_values, |
355 bool requires_caret_at_end, | 363 bool requires_caret_at_end, |
356 bool display_warning_if_disabled) { | 364 bool display_warning_if_disabled) { |
357 // If autocomplete is disabled at the form level, then we might want to show | 365 // If autocomplete is disabled at the form level, then we might want to show |
358 // a warning in place of suggestions. However, if autocomplete is disabled | 366 // a warning in place of suggestions. However, if autocomplete is disabled |
359 // specifically for this field, we never want to show a warning. Otherwise, | 367 // specifically for this field, we never want to show a warning. Otherwise, |
360 // we might interfere with custom popups (e.g. search suggestions) used by | 368 // we might interfere with custom popups (e.g. search suggestions) used by |
361 // the website. | 369 // the website. |
362 const WebFormElement form = element.form(); | 370 const WebFormElement form = element.form(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return; | 427 return; |
420 } | 428 } |
421 | 429 |
422 autofill_action_ = action; | 430 autofill_action_ = action; |
423 was_query_node_autofilled_ = field.is_autofilled; | 431 was_query_node_autofilled_ = field.is_autofilled; |
424 Send(new AutofillHostMsg_FillAutofillFormData( | 432 Send(new AutofillHostMsg_FillAutofillFormData( |
425 routing_id(), autofill_query_id_, form, field, unique_id)); | 433 routing_id(), autofill_query_id_, form, field, unique_id)); |
426 } | 434 } |
427 | 435 |
428 } // namespace autofill | 436 } // namespace autofill |
OLD | NEW |