| 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 <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 // If the image was a data URL, use the favicon from the search URL instead. | 313 // If the image was a data URL, use the favicon from the search URL instead. |
| 314 // (see the TODO in EndElementImpl()). | 314 // (see the TODO in EndElementImpl()). |
| 315 GURL search_url(data_.url()); | 315 GURL search_url(data_.url()); |
| 316 if (derive_image_from_url_ && data_.favicon_url.is_empty()) | 316 if (derive_image_from_url_ && data_.favicon_url.is_empty()) |
| 317 data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url); | 317 data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url); |
| 318 | 318 |
| 319 // Generate a keyword for this search engine if a custom one was not present | 319 // Generate a keyword for this search engine if a custom one was not present |
| 320 // in the imported data. | 320 // in the imported data. |
| 321 if (!has_custom_keyword_) | 321 if (!has_custom_keyword_) |
| 322 data_.SetKeyword(TemplateURL::GenerateKeyword( | 322 data_.SetKeyword(TemplateURL::GenerateKeyword(search_url)); |
| 323 search_url, search_terms_data.GetAcceptLanguages())); | |
| 324 | 323 |
| 325 data_.show_in_default_list = show_in_default_list; | 324 data_.show_in_default_list = show_in_default_list; |
| 326 | 325 |
| 327 // Bail if the search URL is empty or if either TemplateURLRef is invalid. | 326 // Bail if the search URL is empty or if either TemplateURLRef is invalid. |
| 328 scoped_ptr<TemplateURL> template_url(new TemplateURL(data_)); | 327 scoped_ptr<TemplateURL> template_url(new TemplateURL(data_)); |
| 329 if (template_url->url().empty() || | 328 if (template_url->url().empty() || |
| 330 !template_url->url_ref().IsValid(search_terms_data) || | 329 !template_url->url_ref().IsValid(search_terms_data) || |
| 331 (!template_url->suggestions_url().empty() && | 330 (!template_url->suggestions_url().empty() && |
| 332 !template_url->suggestions_url_ref().IsValid(search_terms_data))) { | 331 !template_url->suggestions_url_ref().IsValid(search_terms_data))) { |
| 333 return NULL; | 332 return NULL; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 507 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
| 509 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 508 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
| 510 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 509 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
| 511 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 510 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
| 512 static_cast<int>(length)); | 511 static_cast<int>(length)); |
| 513 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 512 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
| 514 | 513 |
| 515 return error ? | 514 return error ? |
| 516 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); | 515 NULL : context.GetTemplateURL(search_terms_data, show_in_default_list); |
| 517 } | 516 } |
| OLD | NEW |