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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/content/renderer/form_autofill_util.h" | 9 #include "components/autofill/content/renderer/form_autofill_util.h" |
10 #include "components/autofill/core/common/autofill_constants.h" | 10 #include "components/autofill/core/common/autofill_constants.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 std::vector<WebFormControlElement> control_elements; | 171 std::vector<WebFormControlElement> control_elements; |
172 ExtractAutofillableElements(form_element, autofill::REQUIRE_NONE, | 172 ExtractAutofillableElements(form_element, autofill::REQUIRE_NONE, |
173 &control_elements); | 173 &control_elements); |
174 for (size_t i = 0; i < control_elements.size(); ++i) { | 174 for (size_t i = 0; i < control_elements.size(); ++i) { |
175 WebFormControlElement control_element = control_elements[i]; | 175 WebFormControlElement control_element = control_elements[i]; |
176 // Don't modify the value of disabled fields. | 176 // Don't modify the value of disabled fields. |
177 if (!control_element.isEnabled()) | 177 if (!control_element.isEnabled()) |
178 continue; | 178 continue; |
179 | 179 |
| 180 // Don't clear field that was not autofilled |
| 181 if (!control_element.isAutofilled()) |
| 182 continue; |
| 183 |
180 control_element.setAutofilled(false); | 184 control_element.setAutofilled(false); |
181 | 185 |
182 WebInputElement* input_element = toWebInputElement(&control_element); | 186 WebInputElement* input_element = toWebInputElement(&control_element); |
183 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 187 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
184 input_element->setValue(base::string16(), true); | 188 input_element->setValue(base::string16(), true); |
185 | 189 |
186 // Clearing the value in the focused node (above) can cause selection | 190 // Clearing the value in the focused node (above) can cause selection |
187 // to be lost. We force selection range to restore the text cursor. | 191 // to be lost. We force selection range to restore the text cursor. |
188 if (element == *input_element) { | 192 if (element == *input_element) { |
189 int length = input_element->value().length(); | 193 int length = input_element->value().length(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 element->setAttribute("placeholder", | 284 element->setAttribute("placeholder", |
281 WebString(base::UTF8ToUTF16(placeholder))); | 285 WebString(base::UTF8ToUTF16(placeholder))); |
282 } | 286 } |
283 element->setAttribute("title", WebString(title)); | 287 element->setAttribute("title", WebString(title)); |
284 } | 288 } |
285 | 289 |
286 return true; | 290 return true; |
287 } | 291 } |
288 | 292 |
289 } // namespace autofill | 293 } // namespace autofill |
OLD | NEW |