| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_engines/template_url_parser.h" | 5 #include "components/search_engines/template_url_parser.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 for (; *atts; atts += 2) { | 357 for (; *atts; atts += 2) { |
| 358 std::string name(XMLCharToString(*atts)); | 358 std::string name(XMLCharToString(*atts)); |
| 359 const xmlChar* value = atts[1]; | 359 const xmlChar* value = atts[1]; |
| 360 if (name == kURLTypeAttribute) { | 360 if (name == kURLTypeAttribute) { |
| 361 std::string type = XMLCharToString(value); | 361 std::string type = XMLCharToString(value); |
| 362 is_html_url = (type == kHTMLType); | 362 is_html_url = (type == kHTMLType); |
| 363 is_suggest_url = (type == kSuggestionType); | 363 is_suggest_url = (type == kSuggestionType); |
| 364 } else if (name == kURLTemplateAttribute) { | 364 } else if (name == kURLTemplateAttribute) { |
| 365 template_url = XMLCharToString(value); | 365 template_url = XMLCharToString(value); |
| 366 } else if (name == kParamMethodAttribute) { | 366 } else if (name == kParamMethodAttribute) { |
| 367 is_post = LowerCaseEqualsASCII(XMLCharToString(value), "post"); | 367 is_post = base::LowerCaseEqualsASCII(XMLCharToString(value), "post"); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 if (is_html_url && !template_url.empty()) { | 371 if (is_html_url && !template_url.empty()) { |
| 372 data_.SetURL(template_url); | 372 data_.SetURL(template_url); |
| 373 is_suggest_url_ = false; | 373 is_suggest_url_ = false; |
| 374 if (is_post) | 374 if (is_post) |
| 375 method_ = POST; | 375 method_ = POST; |
| 376 } else if (is_suggest_url) { | 376 } else if (is_suggest_url) { |
| 377 data_.suggestions_url = template_url; | 377 data_.suggestions_url = template_url; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 503 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
| 504 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 504 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
| 505 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 505 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
| 506 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 506 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
| 507 static_cast<int>(length)); | 507 static_cast<int>(length)); |
| 508 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 508 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
| 509 | 509 |
| 510 return error ? | 510 return error ? |
| 511 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); | 511 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); |
| 512 } | 512 } |
| OLD | NEW |