| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/autofill_messages.h" | 8 #include "chrome/common/autofill_messages.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/renderer/autofill/password_autofill_manager.h" | 10 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 AutoFillAction action) { | 344 AutoFillAction action) { |
| 345 static int query_counter = 0; | 345 static int query_counter = 0; |
| 346 autofill_query_id_ = query_counter++; | 346 autofill_query_id_ = query_counter++; |
| 347 | 347 |
| 348 webkit_glue::FormData form; | 348 webkit_glue::FormData form; |
| 349 webkit_glue::FormField field; | 349 webkit_glue::FormField field; |
| 350 if (!FindFormAndFieldForNode(node, &form, &field)) | 350 if (!FindFormAndFieldForNode(node, &form, &field)) |
| 351 return; | 351 return; |
| 352 | 352 |
| 353 autofill_action_ = action; | 353 autofill_action_ = action; |
| 354 was_query_node_autofilled_ = field.is_autofilled(); | 354 was_query_node_autofilled_ = field.is_autofilled; |
| 355 Send(new AutoFillHostMsg_FillAutoFillFormData( | 355 Send(new AutoFillHostMsg_FillAutoFillFormData( |
| 356 routing_id(), autofill_query_id_, form, field, unique_id)); | 356 routing_id(), autofill_query_id_, form, field, unique_id)); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void AutoFillAgent::SendForms(WebFrame* frame) { | 359 void AutoFillAgent::SendForms(WebFrame* frame) { |
| 360 std::vector<webkit_glue::FormData> forms; | 360 std::vector<webkit_glue::FormData> forms; |
| 361 form_manager_.GetFormsInFrame(frame, FormManager::REQUIRE_NONE, &forms); | 361 form_manager_.GetFormsInFrame(frame, FormManager::REQUIRE_NONE, &forms); |
| 362 | 362 |
| 363 if (!forms.empty()) | 363 if (!forms.empty()) |
| 364 Send(new AutoFillHostMsg_FormsSeen(routing_id(), forms)); | 364 Send(new AutoFillHostMsg_FormsSeen(routing_id(), forms)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool AutoFillAgent::FindFormAndFieldForNode(const WebNode& node, | 367 bool AutoFillAgent::FindFormAndFieldForNode(const WebNode& node, |
| 368 webkit_glue::FormData* form, | 368 webkit_glue::FormData* form, |
| 369 webkit_glue::FormField* field) { | 369 webkit_glue::FormField* field) { |
| 370 const WebInputElement& element = node.toConst<WebInputElement>(); | 370 const WebInputElement& element = node.toConst<WebInputElement>(); |
| 371 if (!form_manager_.FindFormWithFormControlElement(element, | 371 if (!form_manager_.FindFormWithFormControlElement(element, |
| 372 FormManager::REQUIRE_NONE, | 372 FormManager::REQUIRE_NONE, |
| 373 form)) | 373 form)) |
| 374 return false; | 374 return false; |
| 375 | 375 |
| 376 FormManager::WebFormControlElementToFormField(element, | 376 FormManager::WebFormControlElementToFormField(element, |
| 377 FormManager::EXTRACT_VALUE, | 377 FormManager::EXTRACT_VALUE, |
| 378 field); | 378 field); |
| 379 | 379 |
| 380 // WebFormControlElementToFormField does not scrape the DOM for the field | 380 // WebFormControlElementToFormField does not scrape the DOM for the field |
| 381 // label, so find the label here. | 381 // label, so find the label here. |
| 382 // TODO(jhawkins): Add form and field identities so we can use the cached form | 382 // TODO(jhawkins): Add form and field identities so we can use the cached form |
| 383 // data in FormManager. | 383 // data in FormManager. |
| 384 field->set_label(FormManager::LabelForElement(element)); | 384 field->label = FormManager::LabelForElement(element); |
| 385 | 385 |
| 386 return true; | 386 return true; |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace autofill | 389 } // namespace autofill |
| OLD | NEW |