Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: chrome/browser/search_engines/template_url.cc

Issue 6291003: Revert 71485 - Remove wstring from TemplateURL and friends.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search_engines/template_url.h ('k') | chrome/browser/search_engines/template_url_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url.cc
===================================================================
--- chrome/browser/search_engines/template_url.cc (revision 71499)
+++ chrome/browser/search_engines/template_url.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -262,9 +262,9 @@
std::string TemplateURLRef::ReplaceSearchTerms(
const TemplateURL& host,
- const string16& terms,
+ const std::wstring& terms,
int accepted_suggestion,
- const string16& original_query_for_suggestion) const {
+ const std::wstring& original_query_for_suggestion) const {
UIThreadSearchTermsData search_terms_data;
return ReplaceSearchTermsUsingTermsData(host,
terms,
@@ -275,9 +275,9 @@
std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
const TemplateURL& host,
- const string16& terms,
+ const std::wstring& terms,
int accepted_suggestion,
- const string16& original_query_for_suggestion,
+ const std::wstring& original_query_for_suggestion,
const SearchTermsData& search_terms_data) const {
ParseIfNecessaryUsingTermsData(search_terms_data);
if (!valid_)
@@ -292,9 +292,9 @@
for (Replacements::iterator i = replacements_.begin();
i != replacements_.end(); ++i) {
if (i->type == SEARCH_TERMS) {
- string16::size_type query_start = parsed_url_.find('?');
- is_in_query = query_start != string16::npos &&
- (static_cast<string16::size_type>(i->index) > query_start);
+ std::wstring::size_type query_start = parsed_url_.find('?');
+ is_in_query = query_start != std::wstring::npos &&
+ (static_cast<std::wstring::size_type>(i->index) > query_start);
break;
}
}
@@ -307,11 +307,11 @@
// Encode the search terms so that we know the encoding.
const std::vector<std::string>& encodings = host.input_encodings();
for (size_t i = 0; i < encodings.size(); ++i) {
- if (EscapeQueryParamValue(terms,
+ if (EscapeQueryParamValue(WideToUTF16Hack(terms),
encodings[i].c_str(), true,
&encoded_terms)) {
if (!original_query_for_suggestion.empty()) {
- EscapeQueryParamValue(original_query_for_suggestion,
+ EscapeQueryParamValue(WideToUTF16Hack(original_query_for_suggestion),
encodings[i].c_str(),
true,
&encoded_original_query);
@@ -321,15 +321,17 @@
}
}
if (input_encoding.empty()) {
- encoded_terms = EscapeQueryParamValueUTF8(terms, true);
+ encoded_terms = WideToUTF16Hack(
+ EscapeQueryParamValueUTF8(terms, true));
if (!original_query_for_suggestion.empty()) {
encoded_original_query =
- EscapeQueryParamValueUTF8(original_query_for_suggestion, true);
+ WideToUTF16Hack(EscapeQueryParamValueUTF8(
+ original_query_for_suggestion, true));
}
input_encoding = "UTF-8";
}
} else {
- encoded_terms = UTF8ToUTF16(EscapePath(UTF16ToUTF8(terms)));
+ encoded_terms = WideToUTF16Hack(UTF8ToWide(EscapePath(WideToUTF8(terms))));
input_encoding = "UTF-8";
}
@@ -371,10 +373,10 @@
// empty string. (If we don't handle this case, we hit a
// NOTREACHED below.)
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- string16 rlz_string = search_terms_data.GetRlzParameterValue();
+ std::wstring rlz_string = search_terms_data.GetRlzParameterValue();
if (!rlz_string.empty()) {
rlz_string = L"rlz=" + rlz_string + L"&";
- url.insert(i->index, UTF16ToUTF8(rlz_string));
+ url.insert(i->index, WideToUTF8(rlz_string));
}
#endif
break;
@@ -382,9 +384,9 @@
case GOOGLE_UNESCAPED_SEARCH_TERMS: {
std::string unescaped_terms;
- base::UTF16ToCodepage(terms, input_encoding.c_str(),
- base::OnStringConversionError::SKIP,
- &unescaped_terms);
+ base::WideToCodepage(terms, input_encoding.c_str(),
+ base::OnStringConversionError::SKIP,
+ &unescaped_terms);
url.insert(i->index, std::string(unescaped_terms.begin(),
unescaped_terms.end()));
break;
@@ -429,10 +431,10 @@
return valid_;
}
-string16 TemplateURLRef::DisplayURL() const {
+std::wstring TemplateURLRef::DisplayURL() const {
ParseIfNecessary();
if (!valid_ || replacements_.empty())
- return UTF8ToUTF16(url_);
+ return UTF8ToWide(url_);
string16 result = UTF8ToUTF16(url_);
ReplaceSubstringsAfterOffset(&result, 0,
@@ -444,13 +446,13 @@
ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull),
ASCIIToUTF16(kDisplayUnescapedSearchTerms));
- return result;
+ return UTF16ToWideHack(result);
}
// static
std::string TemplateURLRef::DisplayURLToURLRef(
- const string16& display_url) {
- string16 result = display_url;
+ const std::wstring& display_url) {
+ string16 result = WideToUTF16Hack(display_url);
ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16(kDisplaySearchTerms),
ASCIIToUTF16(kSearchTermsParameterFull));
ReplaceSubstringsAfterOffset(
@@ -475,29 +477,29 @@
return search_term_key_;
}
-string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host,
+std::wstring TemplateURLRef::SearchTermToWide(const TemplateURL& host,
const std::string& term) const {
const std::vector<std::string>& encodings = host.input_encodings();
- string16 result;
+ std::wstring result;
std::string unescaped =
UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE |
UnescapeRule::URL_SPECIAL_CHARS);
for (size_t i = 0; i < encodings.size(); ++i) {
- if (base::CodepageToUTF16(unescaped, encodings[i].c_str(),
- base::OnStringConversionError::FAIL, &result))
+ if (base::CodepageToWide(unescaped, encodings[i].c_str(),
+ base::OnStringConversionError::FAIL, &result))
return result;
}
// Always fall back on UTF-8 if it works.
- if (base::CodepageToUTF16(unescaped, base::kCodepageUTF8,
- base::OnStringConversionError::FAIL, &result))
+ if (base::CodepageToWide(unescaped, base::kCodepageUTF8,
+ base::OnStringConversionError::FAIL, &result))
return result;
// When nothing worked, just use the escaped text. We have no idea what the
// encoding is. We need to substitute spaces for pluses ourselves since we're
// not sending it through an unescaper.
- result = UTF8ToUTF16(term);
+ result = UTF8ToWide(term);
std::replace(result.begin(), result.end(), '+', ' ');
return result;
}
@@ -575,8 +577,8 @@
TemplateURL::~TemplateURL() {
}
-string16 TemplateURL::AdjustedShortNameForLocaleDirection() const {
- string16 bidi_safe_short_name = short_name_;
+std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const {
+ std::wstring bidi_safe_short_name = short_name_;
base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
return bidi_safe_short_name;
}
@@ -599,14 +601,14 @@
instant_url_.Set(url, index_offset, page_offset);
}
-void TemplateURL::set_keyword(const string16& keyword) {
+void TemplateURL::set_keyword(const std::wstring& keyword) {
// Case sensitive keyword matching is confusing. As such, we force all
// keywords to be lower case.
- keyword_ = l10n_util::ToLower(keyword);
+ keyword_ = UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword)));
autogenerate_keyword_ = false;
}
-string16 TemplateURL::keyword() const {
+const std::wstring& TemplateURL::keyword() const {
EnsureKeyword();
return keyword_;
}
@@ -627,7 +629,7 @@
void TemplateURL::SetFavIconURL(const GURL& url) {
for (std::vector<ImageRef>::iterator i = image_refs_.begin();
i != image_refs_.end(); ++i) {
- if (i->type == "image/x-icon" &&
+ if (i->type == L"image/x-icon" &&
i->width == kFavIconSize && i->height == kFavIconSize) {
if (!url.is_valid())
image_refs_.erase(i);
@@ -639,15 +641,15 @@
// Don't have one yet, add it.
if (url.is_valid()) {
add_image_ref(
- TemplateURL::ImageRef("image/x-icon", kFavIconSize,
- kFavIconSize, url));
+ TemplateURL::ImageRef(L"image/x-icon", kFavIconSize, kFavIconSize,
+ url));
}
}
GURL TemplateURL::GetFavIconURL() const {
for (std::vector<ImageRef>::const_iterator i = image_refs_.begin();
i != image_refs_.end(); ++i) {
- if ((i->type == "image/x-icon" || i->type == "image/vnd.microsoft.icon")
+ if ((i->type == L"image/x-icon" || i->type == L"image/vnd.microsoft.icon")
&& i->width == kFavIconSize && i->height == kFavIconSize) {
return i->url;
}
« no previous file with comments | « chrome/browser/search_engines/template_url.h ('k') | chrome/browser/search_engines/template_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698