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

Side by Side Diff: chrome/renderer/autofill/form_manager.cc

Issue 7038003: Refactor autofill form fields. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/renderer/autofill/form_manager.h" 5 #include "chrome/renderer/autofill/form_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 field->name = element.nameForAutofill(); 368 field->name = element.nameForAutofill();
369 field->form_control_type = element.formControlType(); 369 field->form_control_type = element.formControlType();
370 370
371 if (!IsAutofillableElement(element)) 371 if (!IsAutofillableElement(element))
372 return; 372 return;
373 373
374 const WebInputElement* input_element = toWebInputElement(&element); 374 const WebInputElement* input_element = toWebInputElement(&element);
375 if (IsTextInput(input_element)) { 375 if (IsTextInput(input_element)) {
376 field->max_length = input_element->maxLength(); 376 field->max_length = input_element->maxLength();
377 field->is_autofilled = input_element->isAutofilled(); 377 field->is_autofilled = input_element->isAutofilled();
378 field->is_text_input = true;
378 } else if (extract_mask & EXTRACT_OPTIONS) { 379 } else if (extract_mask & EXTRACT_OPTIONS) {
379 // Set option strings on the field if available. 380 // Set option strings on the field if available.
380 DCHECK(IsSelectElement(element)); 381 DCHECK(IsSelectElement(element));
381 const WebSelectElement select_element = element.toConst<WebSelectElement>(); 382 const WebSelectElement select_element = element.toConst<WebSelectElement>();
382 std::vector<string16> option_strings; 383 std::vector<string16> option_strings;
383 GetOptionStringsFromElement(select_element, &option_strings); 384 GetOptionStringsFromElement(select_element, &option_strings);
384 field->option_strings = option_strings; 385 field->option_strings = option_strings;
385 } 386 }
386 387
387 if (!(extract_mask & EXTRACT_VALUE)) 388 if (!(extract_mask & EXTRACT_VALUE))
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 data->value.substr(0, input_element->maxLength())); 957 data->value.substr(0, input_element->maxLength()));
957 input_element->setAutofilled(true); 958 input_element->setAutofilled(true);
958 if (is_initiating_node) { 959 if (is_initiating_node) {
959 // Select the part of the text that the user didn't type. 960 // Select the part of the text that the user didn't type.
960 input_element->setSelectionRange(input_element->value().length(), 961 input_element->setSelectionRange(input_element->value().length(),
961 input_element->suggestedValue().length()); 962 input_element->suggestedValue().length());
962 } 963 }
963 } 964 }
964 965
965 } // namespace autofill 966 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698