| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/search_engines/template_url_parser.h" | 5 #include "chrome/browser/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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // If the image was a data URL, use the favicon from the search URL instead. | 296 // If the image was a data URL, use the favicon from the search URL instead. |
| 297 // (see the TODO in EndElementImpl()). | 297 // (see the TODO in EndElementImpl()). |
| 298 GURL search_url(data_.url()); | 298 GURL search_url(data_.url()); |
| 299 if (derive_image_from_url_ && data_.favicon_url.is_empty()) | 299 if (derive_image_from_url_ && data_.favicon_url.is_empty()) |
| 300 data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url); | 300 data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url); |
| 301 | 301 |
| 302 data_.SetKeyword(TemplateURLService::GenerateKeyword(search_url)); | 302 data_.SetKeyword(TemplateURLService::GenerateKeyword(search_url)); |
| 303 data_.show_in_default_list = show_in_default_list; | 303 data_.show_in_default_list = show_in_default_list; |
| 304 | 304 |
| 305 // Bail if the search URL is empty or if either TemplateURLRef is invalid. | 305 // Bail if the search URL is empty or if either TemplateURLRef is invalid. |
| 306 scoped_ptr<TemplateURL> template_url(new TemplateURL(profile, data_)); | 306 scoped_ptr<TemplateURL> template_url(new TemplateURL(data_)); |
| 307 scoped_ptr<SearchTermsData> search_terms_data(profile ? | 307 scoped_ptr<SearchTermsData> search_terms_data(profile ? |
| 308 new UIThreadSearchTermsData(profile) : new SearchTermsData()); | 308 new UIThreadSearchTermsData(profile) : new SearchTermsData()); |
| 309 if (template_url->url().empty() || | 309 if (template_url->url().empty() || |
| 310 !template_url->url_ref().IsValid(*search_terms_data) || | 310 !template_url->url_ref().IsValid(*search_terms_data) || |
| 311 (!template_url->suggestions_url().empty() && | 311 (!template_url->suggestions_url().empty() && |
| 312 !template_url->suggestions_url_ref().IsValid(*search_terms_data))) { | 312 !template_url->suggestions_url_ref().IsValid(*search_terms_data))) { |
| 313 return NULL; | 313 return NULL; |
| 314 } | 314 } |
| 315 | 315 |
| 316 return template_url.release(); | 316 return template_url.release(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 memset(&sax_handler, 0, sizeof(sax_handler)); | 486 memset(&sax_handler, 0, sizeof(sax_handler)); |
| 487 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 487 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
| 488 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 488 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
| 489 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 489 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
| 490 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 490 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
| 491 static_cast<int>(length)); | 491 static_cast<int>(length)); |
| 492 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 492 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
| 493 | 493 |
| 494 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list); | 494 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list); |
| 495 } | 495 } |
| OLD | NEW |