| 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 CHROME_BROWSER_AUTOFILL_AUTOFILL_XML_PARSER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_XML_PARSER_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_XML_PARSER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_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 "chrome/browser/autofill/autofill_server_field_info.h" |
| 13 #include "chrome/browser/autofill/field_types.h" | 14 #include "chrome/browser/autofill/field_types.h" |
| 14 #include "chrome/browser/autofill/form_structure.h" | 15 #include "chrome/browser/autofill/form_structure.h" |
| 15 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" | 16 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" |
| 16 | 17 |
| 17 // The base class that contains common functionality between | 18 // The base class that contains common functionality between |
| 18 // AutofillQueryXmlParser and AutofillUploadXmlParser. | 19 // AutofillQueryXmlParser and AutofillUploadXmlParser. |
| 19 class AutofillXmlParser : public buzz::XmlParseHandler { | 20 class AutofillXmlParser : public buzz::XmlParseHandler { |
| 20 public: | 21 public: |
| 21 AutofillXmlParser(); | 22 AutofillXmlParser(); |
| 22 | 23 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // <field autofilltype="1" /> | 60 // <field autofilltype="1" /> |
| 60 // <field autofilltype="3" /> | 61 // <field autofilltype="3" /> |
| 61 // <field autofilltype="2" /> | 62 // <field autofilltype="2" /> |
| 62 // </autofillqueryresponse> | 63 // </autofillqueryresponse> |
| 63 // | 64 // |
| 64 // Fields are returned in the same order they were sent to the server. | 65 // Fields are returned in the same order they were sent to the server. |
| 65 // autofilltype: The server's guess at what type of field this is. 0 is | 66 // autofilltype: The server's guess at what type of field this is. 0 is |
| 66 // unknown, other types are documented in chrome/browser/autofill/field_types.h. | 67 // unknown, other types are documented in chrome/browser/autofill/field_types.h. |
| 67 class AutofillQueryXmlParser : public AutofillXmlParser { | 68 class AutofillQueryXmlParser : public AutofillXmlParser { |
| 68 public: | 69 public: |
| 69 AutofillQueryXmlParser(std::vector<AutofillFieldType>* field_types, | 70 AutofillQueryXmlParser(std::vector<AutofillServerFieldInfo>* field_infos, |
| 70 UploadRequired* upload_required, | 71 UploadRequired* upload_required, |
| 71 std::string* experiment_id); | 72 std::string* experiment_id); |
| 72 | 73 |
| 73 private: | 74 private: |
| 74 // A callback for the beginning of a new <element>, called by Expat. | 75 // A callback for the beginning of a new <element>, called by Expat. |
| 75 // |context| is a parsing context used to resolve element/attribute names. | 76 // |context| is a parsing context used to resolve element/attribute names. |
| 76 // |name| is the name of the element. | 77 // |name| is the name of the element. |
| 77 // |attrs| is the list of attributes (names and values) for the element. | 78 // |attrs| is the list of attributes (names and values) for the element. |
| 78 virtual void StartElement(buzz::XmlParseContext* context, | 79 virtual void StartElement(buzz::XmlParseContext* context, |
| 79 const char* name, | 80 const char* name, |
| 80 const char** attrs) OVERRIDE; | 81 const char** attrs) OVERRIDE; |
| 81 | 82 |
| 82 // A helper function to retrieve integer values from strings. Raises an | 83 // A helper function to retrieve integer values from strings. Raises an |
| 83 // XML parse error if it fails. | 84 // XML parse error if it fails. |
| 84 // |context| is the current parsing context. | 85 // |context| is the current parsing context. |
| 85 // |value| is the string to convert. | 86 // |value| is the string to convert. |
| 86 int GetIntValue(buzz::XmlParseContext* context, const char* attribute); | 87 int GetIntValue(buzz::XmlParseContext* context, const char* attribute); |
| 87 | 88 |
| 88 // The parsed field types. | 89 // The parsed <field type, default value> pairs. |
| 89 std::vector<AutofillFieldType>* field_types_; | 90 std::vector<AutofillServerFieldInfo>* field_infos_; |
| 90 | 91 |
| 91 // A flag indicating whether the client should upload Autofill data when this | 92 // A flag indicating whether the client should upload Autofill data when this |
| 92 // form is submitted. | 93 // form is submitted. |
| 93 UploadRequired* upload_required_; | 94 UploadRequired* upload_required_; |
| 94 | 95 |
| 95 // The server experiment to which this query response belongs. | 96 // The server experiment to which this query response belongs. |
| 96 // For the default server implementation, this is empty. | 97 // For the default server implementation, this is empty. |
| 97 std::string* experiment_id_; | 98 std::string* experiment_id_; |
| 98 | 99 |
| 99 DISALLOW_COPY_AND_ASSIGN(AutofillQueryXmlParser); | 100 DISALLOW_COPY_AND_ASSIGN(AutofillQueryXmlParser); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // True if parsing succeeded. | 134 // True if parsing succeeded. |
| 134 bool succeeded_; | 135 bool succeeded_; |
| 135 | 136 |
| 136 double* positive_upload_rate_; | 137 double* positive_upload_rate_; |
| 137 double* negative_upload_rate_; | 138 double* negative_upload_rate_; |
| 138 | 139 |
| 139 DISALLOW_COPY_AND_ASSIGN(AutofillUploadXmlParser); | 140 DISALLOW_COPY_AND_ASSIGN(AutofillUploadXmlParser); |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_XML_PARSER_H_ | 143 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_XML_PARSER_H_ |
| OLD | NEW |