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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const char kParamNameAttribute[] = "name"; | 46 const char kParamNameAttribute[] = "name"; |
47 const char kParamValueAttribute[] = "value"; | 47 const char kParamValueAttribute[] = "value"; |
48 const char kParamMethodAttribute[] = "method"; | 48 const char kParamMethodAttribute[] = "method"; |
49 | 49 |
50 // Mime type for search results. | 50 // Mime type for search results. |
51 const char kHTMLType[] = "text/html"; | 51 const char kHTMLType[] = "text/html"; |
52 | 52 |
53 // Mime type for as you type suggestions. | 53 // Mime type for as you type suggestions. |
54 const char kSuggestionType[] = "application/x-suggestions+json"; | 54 const char kSuggestionType[] = "application/x-suggestions+json"; |
55 | 55 |
56 // Namespace identifier. | |
57 const char kOSDNS[] = "xmlns"; | |
58 | |
59 // The namespace for documents we understand. | |
60 const char kNameSpace[] = "http://a9.com/-/spec/opensearch/1.1/"; | |
61 | |
62 std::string XMLCharToString(const xmlChar* value) { | 56 std::string XMLCharToString(const xmlChar* value) { |
63 return std::string(reinterpret_cast<const char*>(value)); | 57 return std::string(reinterpret_cast<const char*>(value)); |
64 } | 58 } |
65 | 59 |
66 // Returns true if input_encoding contains a valid input encoding string. This | 60 // Returns true if input_encoding contains a valid input encoding string. This |
67 // doesn't verify that we have a valid encoding for the string, just that the | 61 // doesn't verify that we have a valid encoding for the string, just that the |
68 // string contains characters that constitute a valid input encoding. | 62 // string contains characters that constitute a valid input encoding. |
69 bool IsValidEncodingString(const std::string& input_encoding) { | 63 bool IsValidEncodingString(const std::string& input_encoding) { |
70 if (input_encoding.empty()) | 64 if (input_encoding.empty()) |
71 return false; | 65 return false; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 memset(&sax_handler, 0, sizeof(sax_handler)); | 487 memset(&sax_handler, 0, sizeof(sax_handler)); |
494 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; | 488 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; |
495 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; | 489 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; |
496 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; | 490 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; |
497 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, | 491 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, |
498 static_cast<int>(length)); | 492 static_cast<int>(length)); |
499 xmlSubstituteEntitiesDefault(last_sub_entities_value); | 493 xmlSubstituteEntitiesDefault(last_sub_entities_value); |
500 | 494 |
501 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list); | 495 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list); |
502 } | 496 } |
OLD | NEW |