Commit 09de3f51 authored by Roger McFarlane's avatar Roger McFarlane Committed by Commit Bot

[autofill] Support angularjs select with "string:" prefix.

AngularJS can prefix the value in select elements with a type
prefix. Autofill already supports teh "number:" prefix. This
CL adds support for "string:".

Bug: 770781
Change-Id: I5c2b272ca20a3f3a68e3445166c0df36ad5aa058
Reviewed-on: https://chromium-review.googlesource.com/695941
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505774}
parent fcaed195
...@@ -200,15 +200,18 @@ bool FillExpirationMonthSelectControl(const base::string16& value, ...@@ -200,15 +200,18 @@ bool FillExpirationMonthSelectControl(const base::string16& value,
if (!StringToInt(value, &month) || month <= 0 || month > 12) if (!StringToInt(value, &month) || month <= 0 || month > 12)
return false; return false;
// We trim the whitespace and a specific prefix used in AngularJS from the // Trim the whitespace and specific prefixes used in AngularJS from the
// select values before attempting to convert them to months. // select values before attempting to convert them to months.
std::vector<base::string16> trimmed_values(field->option_values.size()); std::vector<base::string16> trimmed_values(field->option_values.size());
const base::string16 kNumberPrefix = ASCIIToUTF16("number:"); const base::string16 kNumberPrefix = ASCIIToUTF16("number:");
const base::string16 kStringPrefix = ASCIIToUTF16("string:");
for (size_t i = 0; i < field->option_values.size(); ++i) { for (size_t i = 0; i < field->option_values.size(); ++i) {
base::TrimWhitespace(field->option_values[i], base::TRIM_ALL, base::TrimWhitespace(field->option_values[i], base::TRIM_ALL,
&trimmed_values[i]); &trimmed_values[i]);
base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kNumberPrefix, base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kNumberPrefix,
ASCIIToUTF16("")); ASCIIToUTF16(""));
base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kStringPrefix,
ASCIIToUTF16(""));
} }
if (trimmed_values.size() == 12) { if (trimmed_values.size() == 12) {
......
...@@ -705,13 +705,18 @@ INSTANTIATE_TEST_CASE_P( ...@@ -705,13 +705,18 @@ INSTANTIATE_TEST_CASE_P(
{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11"}, "11"},
NotNumericMonthsContentsNoPlaceholder()}, NotNumericMonthsContentsNoPlaceholder()},
// The AngularJS framework adds a prefix to number types. Test that it // The AngularJS framework can add a "number:" prefix to select values.
// is removed.
FillWithExpirationMonthTestCase{ FillWithExpirationMonthTestCase{
{"number:1", "number:2", "number:3", "number:4", "number:5", {"number:1", "number:2", "number:3", "number:4", "number:5",
"number:6", "number:7", "number:8", "number:9", "number:10", "number:6", "number:7", "number:8", "number:9", "number:10",
"number:11", "number:12"}, "number:11", "number:12"},
NotNumericMonthsContentsNoPlaceholder()}, NotNumericMonthsContentsNoPlaceholder()},
// The AngularJS framework can add a "string:" prefix to select values.
FillWithExpirationMonthTestCase{
{"string:1", "string:2", "string:3", "string:4", "string:5",
"string:6", "string:7", "string:8", "string:9", "string:10",
"string:11", "string:12"},
NotNumericMonthsContentsNoPlaceholder()},
// Values start at 0 and the first content is a placeholder. // Values start at 0 and the first content is a placeholder.
FillWithExpirationMonthTestCase{ FillWithExpirationMonthTestCase{
{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment