OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content/renderer/form_cache.h" | 5 #include "components/autofill/content/renderer/form_cache.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 // Don't clear field that was not autofilled | 204 // Don't clear field that was not autofilled |
205 if (!control_element.isAutofilled()) | 205 if (!control_element.isAutofilled()) |
206 continue; | 206 continue; |
207 | 207 |
208 control_element.setAutofilled(false); | 208 control_element.setAutofilled(false); |
209 | 209 |
210 WebInputElement* input_element = toWebInputElement(&control_element); | 210 WebInputElement* input_element = toWebInputElement(&control_element); |
211 if (form_util::IsTextInput(input_element) || | 211 if (form_util::IsTextInput(input_element) || |
212 form_util::IsMonthInput(input_element)) { | 212 form_util::IsMonthInput(input_element)) { |
213 input_element->setValue(blink::WebString(), true); | 213 input_element->setAutofillValue(blink::WebString()); |
214 | 214 |
215 // Clearing the value in the focused node (above) can cause selection | 215 // Clearing the value in the focused node (above) can cause selection |
216 // to be lost. We force selection range to restore the text cursor. | 216 // to be lost. We force selection range to restore the text cursor. |
217 if (element == *input_element) { | 217 if (element == *input_element) { |
218 int length = input_element->value().length(); | 218 int length = input_element->value().length(); |
219 input_element->setSelectionRange(length, length); | 219 input_element->setSelectionRange(length, length); |
220 } | 220 } |
221 } else if (form_util::IsTextAreaElement(control_element)) { | 221 } else if (form_util::IsTextAreaElement(control_element)) { |
222 control_element.setValue(blink::WebString(), true); | 222 control_element.setAutofillValue(blink::WebString()); |
223 } else if (form_util::IsSelectElement(control_element)) { | 223 } else if (form_util::IsSelectElement(control_element)) { |
224 WebSelectElement select_element = control_element.to<WebSelectElement>(); | 224 WebSelectElement select_element = control_element.to<WebSelectElement>(); |
225 | 225 |
226 std::map<const WebSelectElement, base::string16>::const_iterator | 226 std::map<const WebSelectElement, base::string16>::const_iterator |
227 initial_value_iter = initial_select_values_.find(select_element); | 227 initial_value_iter = initial_select_values_.find(select_element); |
228 if (initial_value_iter != initial_select_values_.end() && | 228 if (initial_value_iter != initial_select_values_.end() && |
229 select_element.value().utf16() != initial_value_iter->second) { | 229 select_element.value().utf16() != initial_value_iter->second) { |
230 select_element.setValue( | 230 select_element.setAutofillValue( |
231 blink::WebString::fromUTF16(initial_value_iter->second), true); | 231 blink::WebString::fromUTF16(initial_value_iter->second)); |
232 } | 232 } |
233 } else { | 233 } else { |
234 WebInputElement input_element = control_element.to<WebInputElement>(); | 234 WebInputElement input_element = control_element.to<WebInputElement>(); |
235 DCHECK(form_util::IsCheckableElement(&input_element)); | 235 DCHECK(form_util::IsCheckableElement(&input_element)); |
236 std::map<const WebInputElement, bool>::const_iterator it = | 236 std::map<const WebInputElement, bool>::const_iterator it = |
237 initial_checked_state_.find(input_element); | 237 initial_checked_state_.find(input_element); |
238 if (it != initial_checked_state_.end() && | 238 if (it != initial_checked_state_.end() && |
239 input_element.isChecked() != it->second) { | 239 input_element.isChecked() != it->second) { |
240 input_element.setChecked(it->second, true); | 240 input_element.setChecked(it->second, true); |
241 } | 241 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 const WebInputElement* input_element = toWebInputElement(&element); | 369 const WebInputElement* input_element = toWebInputElement(&element); |
370 if (form_util::IsCheckableElement(input_element)) { | 370 if (form_util::IsCheckableElement(input_element)) { |
371 initial_checked_state_.insert( | 371 initial_checked_state_.insert( |
372 std::make_pair(*input_element, input_element->isChecked())); | 372 std::make_pair(*input_element, input_element->isChecked())); |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 } | 376 } |
377 | 377 |
378 } // namespace autofill | 378 } // namespace autofill |
OLD | NEW |