| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 335 } |
| 336 | 336 |
| 337 string16 encoded_terms; | 337 string16 encoded_terms; |
| 338 string16 encoded_original_query; | 338 string16 encoded_original_query; |
| 339 std::string input_encoding; | 339 std::string input_encoding; |
| 340 // If the search terms are in query - escape them respecting the encoding. | 340 // If the search terms are in query - escape them respecting the encoding. |
| 341 if (is_in_query) { | 341 if (is_in_query) { |
| 342 // Encode the search terms so that we know the encoding. | 342 // Encode the search terms so that we know the encoding. |
| 343 const std::vector<std::string>& encodings = host.input_encodings(); | 343 const std::vector<std::string>& encodings = host.input_encodings(); |
| 344 for (size_t i = 0; i < encodings.size(); ++i) { | 344 for (size_t i = 0; i < encodings.size(); ++i) { |
| 345 if (EscapeQueryParamValue(terms, | 345 if (net::EscapeQueryParamValue(terms, |
| 346 encodings[i].c_str(), true, | 346 encodings[i].c_str(), true, |
| 347 &encoded_terms)) { | 347 &encoded_terms)) { |
| 348 if (!original_query_for_suggestion.empty()) { | 348 if (!original_query_for_suggestion.empty()) { |
| 349 EscapeQueryParamValue(original_query_for_suggestion, | 349 net::EscapeQueryParamValue(original_query_for_suggestion, |
| 350 encodings[i].c_str(), | 350 encodings[i].c_str(), |
| 351 true, | 351 true, |
| 352 &encoded_original_query); | 352 &encoded_original_query); |
| 353 } | 353 } |
| 354 input_encoding = encodings[i]; | 354 input_encoding = encodings[i]; |
| 355 break; | 355 break; |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 if (input_encoding.empty()) { | 358 if (input_encoding.empty()) { |
| 359 encoded_terms = net::EscapeQueryParamValueUTF8(terms, true); | 359 encoded_terms = net::EscapeQueryParamValueUTF8(terms, true); |
| 360 if (!original_query_for_suggestion.empty()) { | 360 if (!original_query_for_suggestion.empty()) { |
| 361 encoded_original_query = | 361 encoded_original_query = |
| 362 net::EscapeQueryParamValueUTF8(original_query_for_suggestion, true); | 362 net::EscapeQueryParamValueUTF8(original_query_for_suggestion, true); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 751 } |
| 752 | 752 |
| 753 std::string TemplateURL::GetExtensionId() const { | 753 std::string TemplateURL::GetExtensionId() const { |
| 754 DCHECK(IsExtensionKeyword()); | 754 DCHECK(IsExtensionKeyword()); |
| 755 return GURL(url_.url()).host(); | 755 return GURL(url_.url()).host(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 bool TemplateURL::IsExtensionKeyword() const { | 758 bool TemplateURL::IsExtensionKeyword() const { |
| 759 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); | 759 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); |
| 760 } | 760 } |
| OLD | NEW |