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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 11198048: [Autofill] Update the autocomplete types implementation to match the current HTML spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update AutofillFieldTest expectations Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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/browser/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 labels->swap(labels_copy); 112 labels->swap(labels_copy);
113 icons->swap(icons_copy); 113 icons->swap(icons_copy);
114 unique_ids->swap(unique_ids_copy); 114 unique_ids->swap(unique_ids_copy);
115 } 115 }
116 116
117 // Precondition: |form_structure| and |form| should correspond to the same 117 // Precondition: |form_structure| and |form| should correspond to the same
118 // logical form. Returns true if any field in the given |section| within |form| 118 // logical form. Returns true if any field in the given |section| within |form|
119 // is auto-filled. 119 // is auto-filled.
120 bool SectionIsAutofilled(const FormStructure& form_structure, 120 bool SectionIsAutofilled(const FormStructure& form_structure,
121 const FormData& form, 121 const FormData& form,
122 const string16& section) { 122 const std::string& section) {
123 DCHECK_EQ(form_structure.field_count(), form.fields.size()); 123 DCHECK_EQ(form_structure.field_count(), form.fields.size());
124 for (size_t i = 0; i < form_structure.field_count(); ++i) { 124 for (size_t i = 0; i < form_structure.field_count(); ++i) {
125 if (form_structure.field(i)->section() == section && 125 if (form_structure.field(i)->section() == section &&
126 form.fields[i].is_autofilled) { 126 form.fields[i].is_autofilled) {
127 return true; 127 return true;
128 } 128 }
129 } 129 }
130 130
131 return false; 131 return false;
132 } 132 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 } 1240 }
1241 } 1241 }
1242 } 1242 }
1243 1243
1244 void AutofillManager::FillCreditCardFormField(const CreditCard& credit_card, 1244 void AutofillManager::FillCreditCardFormField(const CreditCard& credit_card,
1245 AutofillFieldType type, 1245 AutofillFieldType type,
1246 FormFieldData* field) { 1246 FormFieldData* field) {
1247 DCHECK_EQ(AutofillType::CREDIT_CARD, AutofillType(type).group()); 1247 DCHECK_EQ(AutofillType::CREDIT_CARD, AutofillType(type).group());
1248 DCHECK(field); 1248 DCHECK(field);
1249 1249
1250 if (field->form_control_type == ASCIIToUTF16("select-one")) { 1250 if (field->form_control_type == "select-one") {
1251 autofill::FillSelectControl(credit_card, type, field); 1251 autofill::FillSelectControl(credit_card, type, field);
1252 } else if (field->form_control_type == ASCIIToUTF16("month")) { 1252 } else if (field->form_control_type == "month") {
1253 // HTML5 input="month" consists of year-month. 1253 // HTML5 input="month" consists of year-month.
1254 string16 year = 1254 string16 year =
1255 credit_card.GetCanonicalizedInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR); 1255 credit_card.GetCanonicalizedInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR);
1256 string16 month = credit_card.GetCanonicalizedInfo(CREDIT_CARD_EXP_MONTH); 1256 string16 month = credit_card.GetCanonicalizedInfo(CREDIT_CARD_EXP_MONTH);
1257 if (!year.empty() && !month.empty()) { 1257 if (!year.empty() && !month.empty()) {
1258 // Fill the value only if |credit_card| includes both year and month 1258 // Fill the value only if |credit_card| includes both year and month
1259 // information. 1259 // information.
1260 field->value = year + ASCIIToUTF16("-") + month; 1260 field->value = year + ASCIIToUTF16("-") + month;
1261 } 1261 }
1262 } else { 1262 } else {
1263 field->value = credit_card.GetCanonicalizedInfo(type); 1263 field->value = credit_card.GetCanonicalizedInfo(type);
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 void AutofillManager::FillFormField(const AutofillProfile& profile, 1267 void AutofillManager::FillFormField(const AutofillProfile& profile,
1268 const AutofillField& cached_field, 1268 const AutofillField& cached_field,
1269 size_t variant, 1269 size_t variant,
1270 FormFieldData* field) { 1270 FormFieldData* field) {
1271 AutofillFieldType type = cached_field.type(); 1271 AutofillFieldType type = cached_field.type();
1272 DCHECK_NE(AutofillType::CREDIT_CARD, AutofillType(type).group()); 1272 DCHECK_NE(AutofillType::CREDIT_CARD, AutofillType(type).group());
1273 DCHECK(field); 1273 DCHECK(field);
1274 1274
1275 if (type == PHONE_HOME_NUMBER) { 1275 if (type == PHONE_HOME_NUMBER) {
1276 FillPhoneNumberField(profile, cached_field, variant, field); 1276 FillPhoneNumberField(profile, cached_field, variant, field);
1277 } else { 1277 } else {
1278 if (field->form_control_type == ASCIIToUTF16("select-one")) { 1278 if (field->form_control_type == "select-one") {
1279 autofill::FillSelectControl(profile, type, field); 1279 autofill::FillSelectControl(profile, type, field);
1280 } else { 1280 } else {
1281 std::vector<string16> values; 1281 std::vector<string16> values;
1282 profile.GetCanonicalizedMultiInfo(type, &values); 1282 profile.GetCanonicalizedMultiInfo(type, &values);
1283 if (variant >= values.size()) { 1283 if (variant >= values.size()) {
1284 // If the variant is unavailable, bail. This case is reachable, for 1284 // If the variant is unavailable, bail. This case is reachable, for
1285 // example if Sync updates a profile during the filling process. 1285 // example if Sync updates a profile during the filling process.
1286 return; 1286 return;
1287 } 1287 }
1288 1288
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 *profile_guid = IDToGUID(profile_id); 1413 *profile_guid = IDToGUID(profile_id);
1414 } 1414 }
1415 1415
1416 void AutofillManager::UpdateInitialInteractionTimestamp( 1416 void AutofillManager::UpdateInitialInteractionTimestamp(
1417 const TimeTicks& interaction_timestamp) { 1417 const TimeTicks& interaction_timestamp) {
1418 if (initial_interaction_timestamp_.is_null() || 1418 if (initial_interaction_timestamp_.is_null() ||
1419 interaction_timestamp < initial_interaction_timestamp_) { 1419 interaction_timestamp < initial_interaction_timestamp_) {
1420 initial_interaction_timestamp_ = interaction_timestamp; 1420 initial_interaction_timestamp_ = interaction_timestamp;
1421 } 1421 }
1422 } 1422 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_field_unittest.cc ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698