| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 context->string_.clear(); | 285 context->string_.clear(); |
| 286 context->elements_.pop_back(); | 286 context->elements_.pop_back(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 // static | 289 // static |
| 290 void TemplateURLParsingContext::CharactersImpl(void* ctx, | 290 void TemplateURLParsingContext::CharactersImpl(void* ctx, |
| 291 const xmlChar* ch, | 291 const xmlChar* ch, |
| 292 int len) { | 292 int len) { |
| 293 reinterpret_cast<TemplateURLParsingContext*>(ctx)->string_ += | 293 reinterpret_cast<TemplateURLParsingContext*>(ctx)->string_ += |
| 294 base::UTF8ToUTF16(std::string(reinterpret_cast<const char*>(ch), len)); | 294 base::UTF8ToUTF16( |
| 295 base::StringPiece(reinterpret_cast<const char*>(ch), len)); |
| 295 } | 296 } |
| 296 | 297 |
| 297 TemplateURL* TemplateURLParsingContext::GetTemplateURL( | 298 TemplateURL* TemplateURLParsingContext::GetTemplateURL( |
| 298 const SearchTermsData& search_terms_data, | 299 const SearchTermsData& search_terms_data, |
| 299 bool show_in_default_list) { | 300 bool show_in_default_list) { |
| 300 // TODO(jcampan): Support engines that use POST; see http://crbug.com/18107 | 301 // TODO(jcampan): Support engines that use POST; see http://crbug.com/18107 |
| 301 if (method_ == TemplateURLParsingContext::POST || data_.short_name.empty() || | 302 if (method_ == TemplateURLParsingContext::POST || data_.short_name.empty() || |
| 302 !IsHTTPRef(data_.url()) || !IsHTTPRef(data_.suggestions_url)) | 303 !IsHTTPRef(data_.url()) || !IsHTTPRef(data_.suggestions_url)) |
| 303 return NULL; | 304 return NULL; |
| 304 if (suggestion_method_ == TemplateURLParsingContext::POST) | 305 if (suggestion_method_ == TemplateURLParsingContext::POST) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 502 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
| 502 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 503 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
| 503 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 504 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
| 504 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 505 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
| 505 static_cast<int>(length)); | 506 static_cast<int>(length)); |
| 506 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 507 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
| 507 | 508 |
| 508 return error ? | 509 return error ? |
| 509 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); | 510 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); |
| 510 } | 511 } |
| OLD | NEW |