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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // that use POST yet. | 306 // that use POST yet. |
307 if (method_ == TemplateURLParsingContext::POST) | 307 if (method_ == TemplateURLParsingContext::POST) |
308 return NULL; | 308 return NULL; |
309 if (suggestion_method_ == TemplateURLParsingContext::POST) | 309 if (suggestion_method_ == TemplateURLParsingContext::POST) |
310 data_.suggestions_url.clear(); | 310 data_.suggestions_url.clear(); |
311 | 311 |
312 string16 keyword(TemplateURLService::GenerateKeyword(url, false)); | 312 string16 keyword(TemplateURLService::GenerateKeyword(url, false)); |
313 DCHECK(!keyword.empty()); | 313 DCHECK(!keyword.empty()); |
314 data_.SetKeyword(keyword); | 314 data_.SetKeyword(keyword); |
315 data_.show_in_default_list = show_in_default_list; | 315 data_.show_in_default_list = show_in_default_list; |
316 return new TemplateURL(data_); | 316 return new TemplateURL(profile, data_); |
317 } | 317 } |
318 | 318 |
319 // static | 319 // static |
320 void TemplateURLParsingContext::InitMapping() { | 320 void TemplateURLParsingContext::InitMapping() { |
321 kElementNameToElementTypeMap = new std::map<std::string, ElementType>; | 321 kElementNameToElementTypeMap = new std::map<std::string, ElementType>; |
322 (*kElementNameToElementTypeMap)[kURLElement] = URL; | 322 (*kElementNameToElementTypeMap)[kURLElement] = URL; |
323 (*kElementNameToElementTypeMap)[kParamElement] = PARAM; | 323 (*kElementNameToElementTypeMap)[kParamElement] = PARAM; |
324 (*kElementNameToElementTypeMap)[kShortNameElement] = SHORT_NAME; | 324 (*kElementNameToElementTypeMap)[kShortNameElement] = SHORT_NAME; |
325 (*kElementNameToElementTypeMap)[kImageElement] = IMAGE; | 325 (*kElementNameToElementTypeMap)[kImageElement] = IMAGE; |
326 (*kElementNameToElementTypeMap)[kOpenSearchDescriptionElement] = | 326 (*kElementNameToElementTypeMap)[kOpenSearchDescriptionElement] = |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 xmlSAXHandler sax_handler; | 485 xmlSAXHandler sax_handler; |
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 xmlSAXUserParseMemory(&sax_handler, &context, data, static_cast<int>(length)); | 490 xmlSAXUserParseMemory(&sax_handler, &context, data, static_cast<int>(length)); |
491 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 491 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
492 | 492 |
493 return context.GetTemplateURL(profile, show_in_default_list); | 493 return context.GetTemplateURL(profile, show_in_default_list); |
494 } | 494 } |
OLD | NEW |