OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 while (*attributes) { | 304 while (*attributes) { |
305 std::string name(XMLCharToString(*attributes)); | 305 std::string name(XMLCharToString(*attributes)); |
306 const xmlChar* value = attributes[1]; | 306 const xmlChar* value = attributes[1]; |
307 if (name == kURLTypeAttribute) { | 307 if (name == kURLTypeAttribute) { |
308 std::string type = XMLCharToString(value); | 308 std::string type = XMLCharToString(value); |
309 is_html_url = (type == kHTMLType); | 309 is_html_url = (type == kHTMLType); |
310 is_suggest_url = (type == kSuggestionType); | 310 is_suggest_url = (type == kSuggestionType); |
311 } else if (name == kURLTemplateAttribute) { | 311 } else if (name == kURLTemplateAttribute) { |
312 template_url = XMLCharToWide(value); | 312 template_url = XMLCharToWide(value); |
313 } else if (name == kURLIndexOffsetAttribute) { | 313 } else if (name == kURLIndexOffsetAttribute) { |
314 index_offset = std::max(1, StringToInt(XMLCharToWide(value))); | 314 index_offset = |
| 315 std::max(1, StringToInt(WideToUTF16Hack(XMLCharToWide(value)))); |
315 } else if (name == kURLPageOffsetAttribute) { | 316 } else if (name == kURLPageOffsetAttribute) { |
316 page_offset = std::max(1, StringToInt(XMLCharToWide(value))); | 317 page_offset = |
| 318 std::max(1, StringToInt(WideToUTF16Hack(XMLCharToWide(value)))); |
317 } else if (name == kParamMethodAttribute) { | 319 } else if (name == kParamMethodAttribute) { |
318 is_post = LowerCaseEqualsASCII(XMLCharToString(value), "post"); | 320 is_post = LowerCaseEqualsASCII(XMLCharToString(value), "post"); |
319 } | 321 } |
320 attributes += 2; | 322 attributes += 2; |
321 } | 323 } |
322 if (is_html_url) { | 324 if (is_html_url) { |
323 turl->SetURL(template_url, index_offset, page_offset); | 325 turl->SetURL(template_url, index_offset, page_offset); |
324 context->set_is_suggestion(false); | 326 context->set_is_suggestion(false); |
325 if (is_post) | 327 if (is_post) |
326 context->set_method(ParsingContext::POST); | 328 context->set_method(ParsingContext::POST); |
(...skipping 12 matching lines...) Expand all Loading... |
339 const xmlChar** attributes = atts; | 341 const xmlChar** attributes = atts; |
340 int width = 0; | 342 int width = 0; |
341 int height = 0; | 343 int height = 0; |
342 std::wstring type; | 344 std::wstring type; |
343 while (*attributes) { | 345 while (*attributes) { |
344 std::string name(XMLCharToString(*attributes)); | 346 std::string name(XMLCharToString(*attributes)); |
345 const xmlChar* value = attributes[1]; | 347 const xmlChar* value = attributes[1]; |
346 if (name == kImageTypeAttribute) { | 348 if (name == kImageTypeAttribute) { |
347 type = XMLCharToWide(value); | 349 type = XMLCharToWide(value); |
348 } else if (name == kImageWidthAttribute) { | 350 } else if (name == kImageWidthAttribute) { |
349 width = StringToInt(XMLCharToWide(value)); | 351 width = StringToInt(WideToUTF16Hack(XMLCharToWide(value))); |
350 } else if (name == kImageHeightAttribute) { | 352 } else if (name == kImageHeightAttribute) { |
351 height = StringToInt(XMLCharToWide(value)); | 353 height = StringToInt(WideToUTF16Hack(XMLCharToWide(value))); |
352 } | 354 } |
353 attributes += 2; | 355 attributes += 2; |
354 } | 356 } |
355 if (width > 0 && height > 0 && !type.empty()) { | 357 if (width > 0 && height > 0 && !type.empty()) { |
356 // Valid Image URL. | 358 // Valid Image URL. |
357 context->AddImageRef(type, width, height); | 359 context->AddImageRef(type, width, height); |
358 } | 360 } |
359 } | 361 } |
360 | 362 |
361 void ParseParam(const xmlChar** atts, ParsingContext* context) { | 363 void ParseParam(const xmlChar** atts, ParsingContext* context) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 return false; | 580 return false; |
579 if (context.suggestion_method() == ParsingContext::POST) | 581 if (context.suggestion_method() == ParsingContext::POST) |
580 url->SetSuggestionsURL(L"", 0, 0); | 582 url->SetSuggestionsURL(L"", 0, 0); |
581 | 583 |
582 if (!url->short_name().empty() && !url->description().empty()) { | 584 if (!url->short_name().empty() && !url->description().empty()) { |
583 // So far so good, make sure the urls are http. | 585 // So far so good, make sure the urls are http. |
584 return IsLegal(url); | 586 return IsLegal(url); |
585 } | 587 } |
586 return false; | 588 return false; |
587 } | 589 } |
588 | |
589 | |
OLD | NEW |