OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "components/autofill/browser/autocheckout_page_meta_data.h" |
14 #include "components/autofill/browser/autofill_server_field_info.h" | 15 #include "components/autofill/browser/autofill_server_field_info.h" |
15 #include "components/autofill/browser/field_types.h" | 16 #include "components/autofill/browser/field_types.h" |
16 #include "components/autofill/browser/form_structure.h" | 17 #include "components/autofill/browser/form_structure.h" |
17 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" | 18 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" |
18 | 19 |
19 namespace autofill { | 20 namespace autofill { |
20 | 21 |
21 struct AutocheckoutPageMetaData; | 22 struct AutocheckoutPageMetaData; |
22 | 23 |
23 // The base class that contains common functionality between | 24 // The base class that contains common functionality between |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 83 |
83 private: | 84 private: |
84 // A callback for the beginning of a new <element>, called by Expat. | 85 // A callback for the beginning of a new <element>, called by Expat. |
85 // |context| is a parsing context used to resolve element/attribute names. | 86 // |context| is a parsing context used to resolve element/attribute names. |
86 // |name| is the name of the element. | 87 // |name| is the name of the element. |
87 // |attrs| is the list of attributes (names and values) for the element. | 88 // |attrs| is the list of attributes (names and values) for the element. |
88 virtual void StartElement(buzz::XmlParseContext* context, | 89 virtual void StartElement(buzz::XmlParseContext* context, |
89 const char* name, | 90 const char* name, |
90 const char** attrs) OVERRIDE; | 91 const char** attrs) OVERRIDE; |
91 | 92 |
| 93 // A helper function to parse a <click_elements_before_formfill> or |
| 94 // <click_elements_after_formfill>. |
| 95 // |context| is the current parsing context. |
| 96 // |attrs| is the list of attributes (names and values) for the element. |
| 97 // |click_elements| is the list a new |ClickElement| will be appended to. |
| 98 void ParseClickElement( |
| 99 buzz::XmlParseContext* context, |
| 100 const char** attrs, |
| 101 std::vector<AutocheckoutPageMetaData::ClickElement>* click_elements); |
| 102 |
| 103 // A helper function to parse a |WebElementDescriptor|. |
| 104 // |context| is the current parsing context. |
| 105 // |attrs| is the list of attributes (names and values) for the element. |
| 106 // |element_descriptor| will be populated by this function. |
| 107 WebElementDescriptor* ParseElementDescriptor( |
| 108 buzz::XmlParseContext* context, |
| 109 const char** attrs, |
| 110 WebElementDescriptor* element_descriptor); |
| 111 |
92 // A helper function to retrieve integer values from strings. Raises an | 112 // A helper function to retrieve integer values from strings. Raises an |
93 // XML parse error if it fails. | 113 // XML parse error if it fails. |
94 // |context| is the current parsing context. | 114 // |context| is the current parsing context. |
95 // |value| is the string to convert. | 115 // |value| is the string to convert. |
96 int GetIntValue(buzz::XmlParseContext* context, const char* attribute); | 116 int GetIntValue(buzz::XmlParseContext* context, const char* attribute); |
97 | 117 |
98 // The parsed <field type, default value> pairs. | 118 // The parsed <field type, default value> pairs. |
99 std::vector<AutofillServerFieldInfo>* field_infos_; | 119 std::vector<AutofillServerFieldInfo>* field_infos_; |
100 | 120 |
101 // A flag indicating whether the client should upload Autofill data when this | 121 // A flag indicating whether the client should upload Autofill data when this |
102 // form is submitted. | 122 // form is submitted. |
103 UploadRequired* upload_required_; | 123 UploadRequired* upload_required_; |
104 | 124 |
105 // The server experiment to which this query response belongs. | 125 // The server experiment to which this query response belongs. |
106 // For the default server implementation, this is empty. | 126 // For the default server implementation, this is empty. |
107 std::string* experiment_id_; | 127 std::string* experiment_id_; |
108 | 128 |
109 // Page metadata for multipage autofill flow. | 129 // Page metadata for multipage autofill flow. |
110 AutocheckoutPageMetaData* page_meta_data_; | 130 AutocheckoutPageMetaData* page_meta_data_; |
111 | 131 |
| 132 // The click element the parser is currently processing. |
| 133 AutocheckoutPageMetaData::ClickElement* current_click_element_; |
| 134 |
112 DISALLOW_COPY_AND_ASSIGN(AutofillQueryXmlParser); | 135 DISALLOW_COPY_AND_ASSIGN(AutofillQueryXmlParser); |
113 }; | 136 }; |
114 | 137 |
115 // The XML parser for handling Autofill upload responses. Typical upload | 138 // The XML parser for handling Autofill upload responses. Typical upload |
116 // responses look like: | 139 // responses look like: |
117 // | 140 // |
118 // <autofilluploadresponse negativeuploadrate="0.00125" positiveuploadrate="1"/> | 141 // <autofilluploadresponse negativeuploadrate="0.00125" positiveuploadrate="1"/> |
119 // | 142 // |
120 // The positive upload rate is the percentage of uploads to send to the server | 143 // The positive upload rate is the percentage of uploads to send to the server |
121 // when something in the users profile matches what they have entered in a form. | 144 // when something in the users profile matches what they have entered in a form. |
(...skipping 26 matching lines...) Expand all Loading... |
148 | 171 |
149 double* positive_upload_rate_; | 172 double* positive_upload_rate_; |
150 double* negative_upload_rate_; | 173 double* negative_upload_rate_; |
151 | 174 |
152 DISALLOW_COPY_AND_ASSIGN(AutofillUploadXmlParser); | 175 DISALLOW_COPY_AND_ASSIGN(AutofillUploadXmlParser); |
153 }; | 176 }; |
154 | 177 |
155 } // namespace autofill | 178 } // namespace autofill |
156 | 179 |
157 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ | 180 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ |
OLD | NEW |