Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 357653003: Mark the single autofilled field when the relevant section is autofilled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 base::string16 profile_full_name; 552 base::string16 profile_full_name;
553 if (!is_credit_card) { 553 if (!is_credit_card) {
554 profile_full_name = data_model->GetInfo( 554 profile_full_name = data_model->GetInfo(
555 AutofillType(NAME_FULL), app_locale_); 555 AutofillType(NAME_FULL), app_locale_);
556 } 556 }
557 557
558 // If the relevant section is auto-filled, we should fill |field| but not the 558 // If the relevant section is auto-filled, we should fill |field| but not the
559 // rest of the form. 559 // rest of the form.
560 if (SectionIsAutofilled(*form_structure, form, autofill_field->section())) { 560 if (SectionIsAutofilled(*form_structure, form, autofill_field->section())) {
561 size_t i = 0;
561 for (std::vector<FormFieldData>::iterator iter = result.fields.begin(); 562 for (std::vector<FormFieldData>::iterator iter = result.fields.begin();
562 iter != result.fields.end(); ++iter) { 563 iter != result.fields.end(); ++iter) {
563 if ((*iter) == field) { 564 if ((*iter) == field) {
564 base::string16 value = data_model->GetInfoForVariant( 565 base::string16 value = data_model->GetInfoForVariant(
565 autofill_field->Type(), variant, app_locale_); 566 autofill_field->Type(), variant, app_locale_);
566 if (AutofillField::FillFormField( 567 if (AutofillField::FillFormField(
567 *autofill_field, value, app_locale_, &(*iter))) { 568 *autofill_field, value, app_locale_, &(*iter))) {
568 // Mark the cached field as autofilled, so that we can detect when a 569 // Mark the cached field as autofilled, so that we can detect when a
569 // user edits an autofilled field (for metrics). 570 // user edits an autofilled field (for metrics).
570 autofill_field->is_autofilled = true; 571 autofill_field->is_autofilled = true;
571 572
573 // Mark the field as autofilled when a non-empty value is assigned to
574 // it. This allows the renderer to distinguish autofilled fields from
575 // fields with non-empty values, such as select-one fields.
576 result.fields[i].is_autofilled = true;
Ilya Sherman 2014/06/25 20:08:29 Can you use (*iter) here, rather than adding an ex
577
572 if (!is_credit_card && !value.empty()) 578 if (!is_credit_card && !value.empty())
573 client_->DidFillOrPreviewField(value, profile_full_name); 579 client_->DidFillOrPreviewField(value, profile_full_name);
574 } 580 }
575 break; 581 break;
576 } 582 }
583 ++i;
577 } 584 }
578 585
579 driver_->SendFormDataToRenderer(query_id, action, result); 586 driver_->SendFormDataToRenderer(query_id, action, result);
580 return; 587 return;
581 } 588 }
582 589
583 // Cache the field type for the field from which the user initiated autofill. 590 // Cache the field type for the field from which the user initiated autofill.
584 FieldTypeGroup initiating_group_type = autofill_field->Type().group(); 591 FieldTypeGroup initiating_group_type = autofill_field->Type().group();
585 DCHECK_EQ(form_structure->field_count(), form.fields.size()); 592 DCHECK_EQ(form_structure->field_count(), form.fields.size());
586 for (size_t i = 0; i < form_structure->field_count(); ++i) { 593 for (size_t i = 0; i < form_structure->field_count(); ++i) {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 return false; 1213 return false;
1207 1214
1208 // Disregard forms that we wouldn't ever autofill in the first place. 1215 // Disregard forms that we wouldn't ever autofill in the first place.
1209 if (!form.ShouldBeParsed(true)) 1216 if (!form.ShouldBeParsed(true))
1210 return false; 1217 return false;
1211 1218
1212 return true; 1219 return true;
1213 } 1220 }
1214 1221
1215 } // namespace autofill 1222 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698