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

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

Issue 6633001: Convert autofill messages to use the new IPC macros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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/form_field.h ('k') | webkit/glue/webpasswordautocompletelistener_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/form_field.h" 5 #include "webkit/glue/form_field.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h"
12 12
13 using WebKit::WebFormControlElement; 13 using WebKit::WebFormControlElement;
14 using WebKit::WebElement; 14 using WebKit::WebElement;
15 using WebKit::WebInputElement; 15 using WebKit::WebInputElement;
16 using WebKit::WebOptionElement; 16 using WebKit::WebOptionElement;
17 using WebKit::WebSelectElement; 17 using WebKit::WebSelectElement;
18 using WebKit::WebVector; 18 using WebKit::WebVector;
19 19
20 namespace webkit_glue { 20 namespace webkit_glue {
21 21
22 FormField::FormField() 22 FormField::FormField()
23 : max_length_(0), 23 : max_length(0),
24 is_autofilled_(false) { 24 is_autofilled(false) {
25 } 25 }
26 26
27 // TODO(jhawkins): This constructor should probably be deprecated and the 27 // TODO(jhawkins): This constructor should probably be deprecated and the
28 // functionality moved to FormManager. 28 // functionality moved to FormManager.
29 FormField::FormField(WebFormControlElement element) 29 FormField::FormField(WebFormControlElement element)
30 : max_length_(0), 30 : max_length(0),
31 is_autofilled_(false) { 31 is_autofilled(false) {
32 name_ = element.nameForAutofill(); 32 name = element.nameForAutofill();
33 33
34 // TODO(jhawkins): Extract the field label. For now we just use the field 34 // TODO(jhawkins): Extract the field label. For now we just use the field
35 // name. 35 // name.
36 label_ = name_; 36 label = name;
37 37
38 form_control_type_ = element.formControlType(); 38 form_control_type = element.formControlType();
39 if (form_control_type_ == ASCIIToUTF16("text")) { 39 if (form_control_type == ASCIIToUTF16("text")) {
40 const WebInputElement& input_element = element.toConst<WebInputElement>(); 40 const WebInputElement& input_element = element.toConst<WebInputElement>();
41 value_ = input_element.value(); 41 value = input_element.value();
42 max_length_ = input_element.size(); 42 max_length = input_element.size();
43 is_autofilled_ = input_element.isAutofilled(); 43 is_autofilled = input_element.isAutofilled();
44 } else if (form_control_type_ == ASCIIToUTF16("select-one")) { 44 } else if (form_control_type == ASCIIToUTF16("select-one")) {
45 WebSelectElement select_element = element.to<WebSelectElement>(); 45 WebSelectElement select_element = element.to<WebSelectElement>();
46 value_ = select_element.value(); 46 value = select_element.value();
47 47
48 // For select-one elements copy option strings. 48 // For select-one elements copy option strings.
49 WebVector<WebElement> list_items = select_element.listItems(); 49 WebVector<WebElement> list_items = select_element.listItems();
50 option_strings_.reserve(list_items.size()); 50 option_strings.reserve(list_items.size());
51 for (size_t i = 0; i < list_items.size(); ++i) { 51 for (size_t i = 0; i < list_items.size(); ++i) {
52 if (list_items[i].hasTagName("option")) 52 if (list_items[i].hasTagName("option"))
53 option_strings_.push_back(list_items[i].to<WebOptionElement>().value()); 53 option_strings.push_back(list_items[i].to<WebOptionElement>().value());
54 } 54 }
55 } 55 }
56 56
57 TrimWhitespace(value_, TRIM_LEADING, &value_); 57 TrimWhitespace(value, TRIM_LEADING, &value);
58 } 58 }
59 59
60 FormField::FormField(const string16& label, 60 FormField::FormField(const string16& label,
61 const string16& name, 61 const string16& name,
62 const string16& value, 62 const string16& value,
63 const string16& form_control_type, 63 const string16& form_control_type,
64 int max_length, 64 int max_length,
65 bool is_autofilled) 65 bool is_autofilled)
66 : label_(label), 66 : label(label),
67 name_(name), 67 name(name),
68 value_(value), 68 value(value),
69 form_control_type_(form_control_type), 69 form_control_type(form_control_type),
70 max_length_(max_length), 70 max_length(max_length),
71 is_autofilled_(is_autofilled) { 71 is_autofilled(is_autofilled) {
72 } 72 }
73 73
74 FormField::~FormField() { 74 FormField::~FormField() {
75 } 75 }
76 76
77 bool FormField::operator==(const FormField& field) const { 77 bool FormField::operator==(const FormField& field) const {
78 // A FormField stores a value, but the value is not part of the identity of 78 // A FormField stores a value, but the value is not part of the identity of
79 // the field, so we don't want to compare the values. 79 // the field, so we don't want to compare the values.
80 return (label_ == field.label_ && 80 return (label == field.label &&
81 name_ == field.name_ && 81 name == field.name &&
82 form_control_type_ == field.form_control_type_ && 82 form_control_type == field.form_control_type &&
83 max_length_ == field.max_length_); 83 max_length == field.max_length);
84 } 84 }
85 85
86 bool FormField::operator!=(const FormField& field) const { 86 bool FormField::operator!=(const FormField& field) const {
87 return !operator==(field); 87 return !operator==(field);
88 } 88 }
89 89
90 bool FormField::StrictlyEqualsHack(const FormField& field) const { 90 bool FormField::StrictlyEqualsHack(const FormField& field) const {
91 return (label_ == field.label_ && 91 return (label == field.label &&
92 name_ == field.name_ && 92 name == field.name &&
93 value_ == field.value_ && 93 value == field.value &&
94 form_control_type_ == field.form_control_type_ && 94 form_control_type == field.form_control_type &&
95 max_length_ == field.max_length_); 95 max_length == field.max_length);
96 } 96 }
97 97
98 std::ostream& operator<<(std::ostream& os, const FormField& field) { 98 std::ostream& operator<<(std::ostream& os, const FormField& field) {
99 return os 99 return os
100 << UTF16ToUTF8(field.label()) 100 << UTF16ToUTF8(field.label)
101 << " " 101 << " "
102 << UTF16ToUTF8(field.name()) 102 << UTF16ToUTF8(field.name)
103 << " " 103 << " "
104 << UTF16ToUTF8(field.value()) 104 << UTF16ToUTF8(field.value)
105 << " " 105 << " "
106 << UTF16ToUTF8(field.form_control_type()) 106 << UTF16ToUTF8(field.form_control_type)
107 << " " 107 << " "
108 << field.max_length(); 108 << field.max_length;
109 } 109 }
110 110
111 } // namespace webkit_glue 111 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/form_field.h ('k') | webkit/glue/webpasswordautocompletelistener_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698