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

Side by Side Diff: chrome/browser/autofill/autofill_xml_parser.cc

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed review comments. Created 7 years, 11 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
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/browser/autofill/autofill_xml_parser.h" 5 #include "chrome/browser/autofill/autofill_xml_parser.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 15 matching lines...) Expand all
26 XML_Error error_code) { 26 XML_Error error_code) {
27 succeeded_ = false; 27 succeeded_ = false;
28 } 28 }
29 29
30 AutofillQueryXmlParser::AutofillQueryXmlParser( 30 AutofillQueryXmlParser::AutofillQueryXmlParser(
31 std::vector<AutofillFieldType>* field_types, 31 std::vector<AutofillFieldType>* field_types,
32 UploadRequired* upload_required, 32 UploadRequired* upload_required,
33 std::string* experiment_id) 33 std::string* experiment_id)
34 : field_types_(field_types), 34 : field_types_(field_types),
35 upload_required_(upload_required), 35 upload_required_(upload_required),
36 page_number_(-1),
Albert Bodenhamer 2013/01/14 22:10:18 nit: I assume -1 is illegal? Maybe create a const
Raman Kakilate 2013/01/14 23:37:46 -1 is being used in similar fashion at http://cod
37 total_pages_(-1),
36 experiment_id_(experiment_id) { 38 experiment_id_(experiment_id) {
37 DCHECK(upload_required_); 39 DCHECK(upload_required_);
38 DCHECK(experiment_id_); 40 DCHECK(experiment_id_);
39 } 41 }
40 42
41 void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context, 43 void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
42 const char* name, 44 const char* name,
43 const char** attrs) { 45 const char** attrs) {
44 buzz::QName qname = context->ResolveQName(name, false); 46 buzz::QName qname = context->ResolveQName(name, false);
45 const std::string& element = qname.LocalPart(); 47 const std::string& element = qname.LocalPart();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (attribute_name.compare("autofilltype") == 0) { 84 if (attribute_name.compare("autofilltype") == 0) {
83 int value = GetIntValue(context, attrs[1]); 85 int value = GetIntValue(context, attrs[1]);
84 field_type = static_cast<AutofillFieldType>(value); 86 field_type = static_cast<AutofillFieldType>(value);
85 if (field_type < 0 || field_type > MAX_VALID_FIELD_TYPE) { 87 if (field_type < 0 || field_type > MAX_VALID_FIELD_TYPE) {
86 field_type = NO_SERVER_DATA; 88 field_type = NO_SERVER_DATA;
87 } 89 }
88 } 90 }
89 91
90 // Record this field type. 92 // Record this field type.
91 field_types_->push_back(field_type); 93 field_types_->push_back(field_type);
94 } else if (element.compare("autofill_flow") == 0) {
95 // |attrs| is a NULL-terminated list of (attribute, value) pairs.
96 while (*attrs) {
97 buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
98 ++attrs;
99 const std::string& attribute_name = attribute_qname.LocalPart();
100 if (attribute_name.compare("page_no") == 0) {
101 page_number_ = GetIntValue(context, *attrs);
102 } else if (attribute_name.compare("total_pages") == 0) {
103 total_pages_ = GetIntValue(context, *attrs);
104 }
105 ++attrs;
106 }
92 } 107 }
93 } 108 }
94 109
95 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context, 110 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context,
96 const char* attribute) { 111 const char* attribute) {
97 char* attr_end = NULL; 112 char* attr_end = NULL;
98 int value = strtol(attribute, &attr_end, 10); 113 int value = strtol(attribute, &attr_end, 10);
99 if (attr_end != NULL && attr_end == attribute) { 114 if (attr_end != NULL && attr_end == attribute) {
100 context->RaiseError(XML_ERROR_SYNTAX); 115 context->RaiseError(XML_ERROR_SYNTAX);
101 return 0; 116 return 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 double AutofillUploadXmlParser::GetDoubleValue(buzz::XmlParseContext* context, 150 double AutofillUploadXmlParser::GetDoubleValue(buzz::XmlParseContext* context,
136 const char* attribute) { 151 const char* attribute) {
137 char* attr_end = NULL; 152 char* attr_end = NULL;
138 double value = strtod(attribute, &attr_end); 153 double value = strtod(attribute, &attr_end);
139 if (attr_end != NULL && attr_end == attribute) { 154 if (attr_end != NULL && attr_end == attribute) {
140 context->RaiseError(XML_ERROR_SYNTAX); 155 context->RaiseError(XML_ERROR_SYNTAX);
141 return 0.0; 156 return 0.0;
142 } 157 }
143 return value; 158 return value;
144 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698