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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 for (; *atts; atts += 2) { | 338 for (; *atts; atts += 2) { |
339 std::string name(XMLCharToString(*atts)); | 339 std::string name(XMLCharToString(*atts)); |
340 const xmlChar* value = atts[1]; | 340 const xmlChar* value = atts[1]; |
341 if (name == kURLTypeAttribute) { | 341 if (name == kURLTypeAttribute) { |
342 std::string type = XMLCharToString(value); | 342 std::string type = XMLCharToString(value); |
343 is_html_url = (type == kHTMLType); | 343 is_html_url = (type == kHTMLType); |
344 is_suggest_url = (type == kSuggestionType); | 344 is_suggest_url = (type == kSuggestionType); |
345 } else if (name == kURLTemplateAttribute) { | 345 } else if (name == kURLTemplateAttribute) { |
346 template_url = XMLCharToString(value); | 346 template_url = XMLCharToString(value); |
347 } else if (name == kParamMethodAttribute) { | 347 } else if (name == kParamMethodAttribute) { |
348 is_post = LowerCaseEqualsASCII(XMLCharToString(value), "post"); | 348 is_post = base::LowerCaseEqualsASCII(XMLCharToString(value), "post"); |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 if (is_html_url && !template_url.empty()) { | 352 if (is_html_url && !template_url.empty()) { |
353 data_.SetURL(template_url); | 353 data_.SetURL(template_url); |
354 is_suggest_url_ = false; | 354 is_suggest_url_ = false; |
355 if (is_post) | 355 if (is_post) |
356 method_ = POST; | 356 method_ = POST; |
357 } else if (is_suggest_url) { | 357 } else if (is_suggest_url) { |
358 data_.suggestions_url = template_url; | 358 data_.suggestions_url = template_url; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 484 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
485 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 485 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
486 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 486 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
487 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 487 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
488 static_cast<int>(length)); | 488 static_cast<int>(length)); |
489 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 489 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
490 | 490 |
491 return error ? | 491 return error ? |
492 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); | 492 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); |
493 } | 493 } |
OLD | NEW |