OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/search_engines/template_url.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 return search_term_key_; | 521 return search_term_key_; |
522 } | 522 } |
523 | 523 |
524 string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host, | 524 string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host, |
525 const std::string& term) const { | 525 const std::string& term) const { |
526 const std::vector<std::string>& encodings = host.input_encodings(); | 526 const std::vector<std::string>& encodings = host.input_encodings(); |
527 string16 result; | 527 string16 result; |
528 | 528 |
529 std::string unescaped = net::UnescapeURLComponent( | 529 std::string unescaped = net::UnescapeURLComponent( |
530 term, | 530 term, |
531 UnescapeRule::REPLACE_PLUS_WITH_SPACE | UnescapeRule::URL_SPECIAL_CHARS); | 531 net::UnescapeRule::REPLACE_PLUS_WITH_SPACE | |
| 532 net::UnescapeRule::URL_SPECIAL_CHARS); |
532 for (size_t i = 0; i < encodings.size(); ++i) { | 533 for (size_t i = 0; i < encodings.size(); ++i) { |
533 if (base::CodepageToUTF16(unescaped, encodings[i].c_str(), | 534 if (base::CodepageToUTF16(unescaped, encodings[i].c_str(), |
534 base::OnStringConversionError::FAIL, &result)) | 535 base::OnStringConversionError::FAIL, &result)) |
535 return result; | 536 return result; |
536 } | 537 } |
537 | 538 |
538 // Always fall back on UTF-8 if it works. | 539 // Always fall back on UTF-8 if it works. |
539 if (base::CodepageToUTF16(unescaped, base::kCodepageUTF8, | 540 if (base::CodepageToUTF16(unescaped, base::kCodepageUTF8, |
540 base::OnStringConversionError::FAIL, &result)) | 541 base::OnStringConversionError::FAIL, &result)) |
541 return result; | 542 return result; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 } | 747 } |
747 | 748 |
748 std::string TemplateURL::GetExtensionId() const { | 749 std::string TemplateURL::GetExtensionId() const { |
749 DCHECK(IsExtensionKeyword()); | 750 DCHECK(IsExtensionKeyword()); |
750 return GURL(url_.url()).host(); | 751 return GURL(url_.url()).host(); |
751 } | 752 } |
752 | 753 |
753 bool TemplateURL::IsExtensionKeyword() const { | 754 bool TemplateURL::IsExtensionKeyword() const { |
754 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); | 755 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); |
755 } | 756 } |
OLD | NEW |