Commit a7043040 authored by Roger McFarlane's avatar Roger McFarlane Committed by Commit Bot

[autofill] Fix --show-autofill-type-predictions.

Corrects the code that generates field title strings when the
--show-autofill-type-predictions flag is specified. Formatting
bugs were introduced when the string was moved out of the .pak
file and into code (escape sequences for string replacement
were retained and some values were duplicated/missing due to
copy-paste).

BUG=703134

Change-Id: Id81a974be4ee12f0c6e2870da2b80c592962d730
Reviewed-on: https://chromium-review.googlesource.com/600994
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491852}
parent cd7b37e9
...@@ -310,27 +310,36 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form) { ...@@ -310,27 +310,36 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form) {
continue; continue;
} }
static const size_t kMaxLabelSize = 100; constexpr size_t kMaxLabelSize = 100;
const base::string16 truncated_label = field_data.label.substr( const base::string16 truncated_label = field_data.label.substr(
0, std::min(field_data.label.length(), kMaxLabelSize)); 0, std::min(field_data.label.length(), kMaxLabelSize));
const FormFieldDataPredictions& field = form.fields[i]; const FormFieldDataPredictions& field = form.fields[i];
// A rough estimate of the maximum title size is:
// 7 field titles at <17 chars each
// + 6 values at <40 chars each
// + 1 truncated label at <kMaxLabelSize;
// = 459 chars, rounded up to the next multiple of 64 = 512
// A particularly large parseable name could blow through this and cause
// another allocation, but that's OK.
constexpr size_t kMaxTitleSize = 512;
std::string title; std::string title;
title.reserve(kMaxTitleSize);
title += "overall type: "; title += "overall type: ";
title += field.overall_type; title += field.overall_type;
title += " server type: $2 "; title += "\nserver type: ";
title += field.server_type; title += field.server_type;
title += " heuristic type: $3"; title += "\nheuristic type: ";
title += field.heuristic_type; title += field.heuristic_type;
title += " label: $4"; title += "\nlabel: ";
title += base::UTF16ToUTF8(truncated_label); title += base::UTF16ToUTF8(truncated_label);
title += " parseable name: $5"; title += "\nparseable name: ";
title += field.overall_type; title += field.parseable_name;
title += " field signature: $6"; title += "\nfield signature: ";
title += field.overall_type; title += field.signature;
title += " form signature: $7"; title += "\nform signature: ";
title += field.overall_type; title += form.signature;
element.SetAttribute("title", WebString::FromUTF8(title)); element.SetAttribute("title", WebString::FromUTF8(title));
......
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