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

Side by Side Diff: components/autofill/browser/form_group.cc

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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) 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 "components/autofill/browser/form_group.h" 5 #include "components/autofill/browser/form_group.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 bool FormGroup::SetInfo(AutofillFieldType type, 252 bool FormGroup::SetInfo(AutofillFieldType type,
253 const string16& value, 253 const string16& value,
254 const std::string& app_locale) { 254 const std::string& app_locale) {
255 SetRawInfo(type, value); 255 SetRawInfo(type, value);
256 return true; 256 return true;
257 } 257 }
258 258
259 void FormGroup::FillFormField(const AutofillField& field, 259 void FormGroup::FillFormField(const AutofillField& field,
260 size_t variant, 260 size_t variant,
261 const std::string& app_locale,
261 FormFieldData* field_data) const { 262 FormFieldData* field_data) const {
262 NOTREACHED(); 263 NOTREACHED();
263 } 264 }
264 265
265 void FormGroup::FillSelectControl(AutofillFieldType type, 266 void FormGroup::FillSelectControl(AutofillFieldType type,
267 const std::string& app_locale,
266 FormFieldData* field) const { 268 FormFieldData* field) const {
267 DCHECK(field); 269 DCHECK(field);
268 DCHECK_EQ("select-one", field->form_control_type); 270 DCHECK_EQ("select-one", field->form_control_type);
269 DCHECK_EQ(field->option_values.size(), field->option_contents.size()); 271 DCHECK_EQ(field->option_values.size(), field->option_contents.size());
270 272
271 const std::string app_locale = AutofillCountry::ApplicationLocale();
272 string16 field_text = GetInfo(type, app_locale); 273 string16 field_text = GetInfo(type, app_locale);
273 string16 field_text_lower = StringToLowerASCII(field_text); 274 string16 field_text_lower = StringToLowerASCII(field_text);
274 if (field_text.empty()) 275 if (field_text.empty())
275 return; 276 return;
276 277
277 string16 value; 278 string16 value;
278 for (size_t i = 0; i < field->option_values.size(); ++i) { 279 for (size_t i = 0; i < field->option_values.size(); ++i) {
279 if (field_text == field->option_values[i] || 280 if (field_text == field->option_values[i] ||
280 field_text == field->option_contents[i]) { 281 field_text == field->option_contents[i]) {
281 // An exact match, use it. 282 // An exact match, use it.
(...skipping 10 matching lines...) Expand all
292 } 293 }
293 294
294 if (!value.empty()) { 295 if (!value.empty()) {
295 field->value = value; 296 field->value = value;
296 return; 297 return;
297 } 298 }
298 299
299 if (type == ADDRESS_HOME_STATE || type == ADDRESS_BILLING_STATE) { 300 if (type == ADDRESS_HOME_STATE || type == ADDRESS_BILLING_STATE) {
300 FillStateSelectControl(field_text, field); 301 FillStateSelectControl(field_text, field);
301 } else if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) { 302 } else if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) {
302 FillCountrySelectControl(field); 303 FillCountrySelectControl(app_locale, field);
303 } else if (type == CREDIT_CARD_EXP_MONTH) { 304 } else if (type == CREDIT_CARD_EXP_MONTH) {
304 FillExpirationMonthSelectControl(field_text, field); 305 FillExpirationMonthSelectControl(field_text, field);
305 } else if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { 306 } else if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
306 // Attempt to fill the year as a 2-digit year. This compensates for the 307 // Attempt to fill the year as a 2-digit year. This compensates for the
307 // fact that our heuristics do not always correctly detect when a website 308 // fact that our heuristics do not always correctly detect when a website
308 // requests a 2-digit rather than a 4-digit year. 309 // requests a 2-digit rather than a 4-digit year.
309 FillSelectControl(CREDIT_CARD_EXP_2_DIGIT_YEAR, field); 310 FillSelectControl(CREDIT_CARD_EXP_2_DIGIT_YEAR, app_locale, field);
310 } else if (type == CREDIT_CARD_TYPE) { 311 } else if (type == CREDIT_CARD_TYPE) {
311 FillCreditCardTypeSelectControl(field_text, field); 312 FillCreditCardTypeSelectControl(field_text, field);
312 } 313 }
313 } 314 }
314 315
315 bool FormGroup::FillCountrySelectControl(FormFieldData* field_data) const { 316 bool FormGroup::FillCountrySelectControl(const std::string& app_locale,
317 FormFieldData* field_data) const {
316 return false; 318 return false;
317 } 319 }
318 320
319 // static 321 // static
320 bool FormGroup::IsValidState(const string16& value) { 322 bool FormGroup::IsValidState(const string16& value) {
321 return !State::Abbreviation(value).empty() || !State::FullName(value).empty(); 323 return !State::Abbreviation(value).empty() || !State::FullName(value).empty();
322 } 324 }
OLDNEW
« no previous file with comments | « components/autofill/browser/form_group.h ('k') | components/autofill/browser/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698