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

Side by Side Diff: components/autofill/content/renderer/form_cache.cc

Issue 316853006: Autofill's "Clear Form" should clear only autofilled fields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated test case Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698