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

Unified Diff: components/autofill/content/renderer/form_cache.cc

Issue 2650623002: Use explicit WebString conversions in autofill (Closed)
Patch Set: . Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/renderer/form_cache.cc
diff --git a/components/autofill/content/renderer/form_cache.cc b/components/autofill/content/renderer/form_cache.cc
index 925379d1915662fc9826d81efd9a8fe3c95c42e4..3ecbbb9e7796368c1a4ae975b4d7cd488bd48948 100644
--- a/components/autofill/content/renderer/form_cache.cc
+++ b/components/autofill/content/renderer/form_cache.cc
@@ -41,8 +41,7 @@ namespace {
void LogDeprecationMessages(const WebFormControlElement& element) {
std::string autocomplete_attribute =
- base::UTF16ToUTF8(base::StringPiece16(
- element.getAttribute("autocomplete")));
+ element.getAttribute("autocomplete").utf8();
static const char* const deprecated[] = { "region", "locality" };
for (const char* str : deprecated) {
@@ -51,8 +50,7 @@ void LogDeprecationMessages(const WebFormControlElement& element) {
std::string msg = std::string("autocomplete='") + str +
"' is deprecated and will soon be ignored. See http://goo.gl/YjeSsW";
WebConsoleMessage console_message = WebConsoleMessage(
- WebConsoleMessage::LevelWarning,
- WebString(base::ASCIIToUTF16(msg)));
+ WebConsoleMessage::LevelWarning, WebString::fromASCII(msg));
element.document().frame()->addMessageToConsole(console_message);
}
}
@@ -212,7 +210,7 @@ bool FormCache::ClearFormWithElement(const WebFormControlElement& element) {
WebInputElement* input_element = toWebInputElement(&control_element);
if (form_util::IsTextInput(input_element) ||
form_util::IsMonthInput(input_element)) {
- input_element->setValue(base::string16(), true);
+ input_element->setValue(blink::WebString(), true);
// Clearing the value in the focused node (above) can cause selection
// to be lost. We force selection range to restore the text cursor.
@@ -221,15 +219,16 @@ bool FormCache::ClearFormWithElement(const WebFormControlElement& element) {
input_element->setSelectionRange(length, length);
}
} else if (form_util::IsTextAreaElement(control_element)) {
- control_element.setValue(base::string16(), true);
+ control_element.setValue(blink::WebString(), true);
} else if (form_util::IsSelectElement(control_element)) {
WebSelectElement select_element = control_element.to<WebSelectElement>();
std::map<const WebSelectElement, base::string16>::const_iterator
initial_value_iter = initial_select_values_.find(select_element);
if (initial_value_iter != initial_select_values_.end() &&
- select_element.value() != initial_value_iter->second) {
- select_element.setValue(initial_value_iter->second, true);
+ select_element.value().utf16() != initial_value_iter->second) {
+ select_element.setValue(
+ blink::WebString::fromUTF16(initial_value_iter->second), true);
}
} else {
WebInputElement input_element = control_element.to<WebInputElement>();
@@ -301,7 +300,7 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form) {
WebFormControlElement& element = control_elements[i];
const FormFieldData& field_data = form.data.fields[i];
- if (base::string16(element.nameForAutofill()) != field_data.name) {
+ if (element.nameForAutofill().utf16() != field_data.name) {
// Keep things simple. Don't show predictions for elements whose names
// were modified between page load and the server's response to our query.
continue;
@@ -325,9 +324,10 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form) {
replacements.push_back(base::UTF8ToUTF16(form.signature));
const base::string16 title = l10n_util::GetStringFUTF16(
IDS_AUTOFILL_SHOW_PREDICTIONS_TITLE, replacements, nullptr);
- element.setAttribute("title", WebString(title));
+ element.setAttribute("title", WebString::fromUTF16(title));
- element.setAttribute("autofill-prediction", WebString(overall_type));
+ element.setAttribute("autofill-prediction",
+ WebString::fromUTF16(overall_type));
}
return true;
@@ -364,7 +364,7 @@ void FormCache::SaveInitialValues(
const WebSelectElement select_element =
element.toConst<WebSelectElement>();
initial_select_values_.insert(
- std::make_pair(select_element, select_element.value()));
+ std::make_pair(select_element, select_element.value().utf16()));
} else {
const WebInputElement* input_element = toWebInputElement(&element);
if (form_util::IsCheckableElement(input_element)) {
« no previous file with comments | « components/autofill/content/renderer/form_autofill_util.cc ('k') | components/autofill/content/renderer/form_classifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698