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

Side by Side Diff: webkit/glue/autofill_form.cc

Issue 48033: Autocomplete should work with nameless fields (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « webkit/glue/autofill_form.h ('k') | webkit/glue/editor_client_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 7
8 MSVC_PUSH_WARNING_LEVEL(0); 8 MSVC_PUSH_WARNING_LEVEL(0);
9 #include "Frame.h" 9 #include "Frame.h"
10 #include "HTMLInputElement.h" 10 #include "HTMLInputElement.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) 57 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT)
58 continue; 58 continue;
59 59
60 // For each TEXT input field, store the name and value 60 // For each TEXT input field, store the name and value
61 std::wstring value = webkit_glue::StringToStdWString( 61 std::wstring value = webkit_glue::StringToStdWString(
62 input_element->value()); 62 input_element->value());
63 TrimWhitespace(value, TRIM_LEADING, &value); 63 TrimWhitespace(value, TRIM_LEADING, &value);
64 if (value.length() == 0) 64 if (value.length() == 0)
65 continue; 65 continue;
66 66
67 std::wstring name = webkit_glue::StringToStdWString(input_element->name()); 67 std::wstring name = GetNameForInputElement(input_element);
68 // Test that the name is not blank. 68 if (name.length() == 0)
69 std::wstring trimmed_name; 69 continue; // If we have no name, there is nothing to store.
70 TrimWhitespace(name, TRIM_LEADING, &trimmed_name);
71 if (trimmed_name.length() == 0)
72 continue;
73 70
74 result->elements.push_back(AutofillForm::Element(name, value)); 71 result->elements.push_back(AutofillForm::Element(name, value));
75 } 72 }
76 73
77 return result; 74 return result;
78 } 75 }
76
77 // static
78 std::wstring AutofillForm::GetNameForInputElement(WebCore::HTMLInputElement*
79 element) {
80 std::wstring name = webkit_glue::StringToStdWString(element->name());
81 std::wstring trimmed_name;
82 TrimWhitespace(name, TRIM_LEADING, &trimmed_name);
83 if (trimmed_name.length() > 0)
84 return trimmed_name;
85
86 name = webkit_glue::StringToStdWString(element->id());
87 TrimWhitespace(name, TRIM_LEADING, &trimmed_name);
88 if (trimmed_name.length() > 0)
89 return trimmed_name;
90
91 return std::wstring();
92 }
OLDNEW
« no previous file with comments | « webkit/glue/autofill_form.h ('k') | webkit/glue/editor_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698