| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_helper.h" | 5 #include "chrome/renderer/autofill_helper.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 void AutoFillHelper::QueryAutoFillSuggestions( | 321 void AutoFillHelper::QueryAutoFillSuggestions( |
| 322 const WebNode& node, bool display_warning_if_disabled) { | 322 const WebNode& node, bool display_warning_if_disabled) { |
| 323 static int query_counter = 0; | 323 static int query_counter = 0; |
| 324 autofill_query_id_ = query_counter++; | 324 autofill_query_id_ = query_counter++; |
| 325 autofill_query_node_ = node; | 325 autofill_query_node_ = node; |
| 326 display_warning_if_disabled_ = display_warning_if_disabled; | 326 display_warning_if_disabled_ = display_warning_if_disabled; |
| 327 | 327 |
| 328 webkit_glue::FormData form; | 328 webkit_glue::FormData form; |
| 329 webkit_glue::FormField field; | 329 webkit_glue::FormField field; |
| 330 if (!FindFormAndFieldForNode(node, &form, &field)) | 330 if (!FindFormAndFieldForNode(node, &form, &field)) { |
| 331 return; | 331 // If we didn't find the cached form, at least let autocomplete have a shot |
| 332 // at providing suggestions. |
| 333 FormManager::WebFormControlElementToFormField( |
| 334 node.toConst<WebFormControlElement>(), FormManager::EXTRACT_VALUE, |
| 335 &field); |
| 336 } |
| 332 | 337 |
| 333 Send(new ViewHostMsg_QueryFormFieldAutoFill( | 338 Send(new ViewHostMsg_QueryFormFieldAutoFill( |
| 334 routing_id(), autofill_query_id_, form, field)); | 339 routing_id(), autofill_query_id_, form, field)); |
| 335 } | 340 } |
| 336 | 341 |
| 337 void AutoFillHelper::FillAutoFillFormData(const WebNode& node, | 342 void AutoFillHelper::FillAutoFillFormData(const WebNode& node, |
| 338 int unique_id, | 343 int unique_id, |
| 339 AutoFillAction action) { | 344 AutoFillAction action) { |
| 340 static int query_counter = 0; | 345 static int query_counter = 0; |
| 341 autofill_query_id_ = query_counter++; | 346 autofill_query_id_ = query_counter++; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 field); | 392 field); |
| 388 | 393 |
| 389 // WebFormControlElementToFormField does not scrape the DOM for the field | 394 // WebFormControlElementToFormField does not scrape the DOM for the field |
| 390 // label, so find the label here. | 395 // label, so find the label here. |
| 391 // TODO(jhawkins): Add form and field identities so we can use the cached form | 396 // TODO(jhawkins): Add form and field identities so we can use the cached form |
| 392 // data in FormManager. | 397 // data in FormManager. |
| 393 field->set_label(FormManager::LabelForElement(element)); | 398 field->set_label(FormManager::LabelForElement(element)); |
| 394 | 399 |
| 395 return true; | 400 return true; |
| 396 } | 401 } |
| OLD | NEW |