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

Unified Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 6306011: Remove wstring from autocomplete. (Closed) Base URL: svn://chrome-svn/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
Index: chrome/browser/autocomplete/history_url_provider.cc
===================================================================
--- chrome/browser/autocomplete/history_url_provider.cc (revision 72388)
+++ chrome/browser/autocomplete/history_url_provider.cc (working copy)
@@ -78,7 +78,7 @@
// Given the user's |input| and a |match| created from it, reduce the
// match's URL to just a host. If this host still matches the user input,
// return it. Returns the empty string on failure.
-GURL ConvertToHostOnly(const HistoryMatch& match, const std::wstring& input) {
+GURL ConvertToHostOnly(const HistoryMatch& match, const string16& input) {
// See if we should try to do host-only suggestions for this URL. Nonstandard
// schemes means there's no authority section, so suggesting the host name
// is useless. File URLs are standard, but host suggestion is not useful for
@@ -93,7 +93,7 @@
if ((host.spec().length() < (match.input_location + input.length())))
return GURL(); // User typing is longer than this host suggestion.
- const std::wstring spec = UTF8ToWide(host.spec());
+ const string16 spec = UTF8ToUTF16(host.spec());
if (spec.compare(match.input_location, input.length(), input))
return GURL(); // User typing is no longer a prefix.
@@ -188,7 +188,7 @@
(params->input.type() != AutocompleteInput::QUERY) &&
((params->input.type() != AutocompleteInput::UNKNOWN) ||
!params->trim_http ||
- url_util::FindAndCompareScheme(WideToUTF8(params->input.text()),
+ url_util::FindAndCompareScheme(UTF16ToUTF8(params->input.text()),
chrome::kHttpsScheme, NULL));
AutocompleteMatch what_you_typed_match(SuggestExactInput(params->input,
params->trim_http));
@@ -208,11 +208,11 @@
// for more results than we need, of every prefix type, in hopes this will
// give us far more than enough to work with. CullRedirects() will then
// reduce the list to the best kMaxMatches results.
- db->AutocompleteForPrefix(WideToUTF16(i->prefix + params->input.text()),
+ db->AutocompleteForPrefix(i->prefix + params->input.text(),
kMaxMatches * 2, (backend == NULL), &url_matches);
for (URLRowVector::const_iterator j(url_matches.begin());
j != url_matches.end(); ++j) {
- const Prefix* best_prefix = BestPrefix(j->url(), std::wstring());
+ const Prefix* best_prefix = BestPrefix(j->url(), string16());
DCHECK(best_prefix != NULL);
history_matches.push_back(HistoryMatch(*j, i->prefix.length(),
!i->num_components,
@@ -313,7 +313,7 @@
// |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have
// slightly different behavior as well (the latter will strip even without
// two slashes after the scheme).
- std::wstring display_string(StringForURLDisplay(url, false, false));
+ string16 display_string(StringForURLDisplay(url, false, false));
const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
match.fill_into_edit =
AutocompleteInput::FormattedStringWithEquivalentMeaning(url,
@@ -331,7 +331,7 @@
// to not contain the user's input at all. In this case don't mark anything
// as a match.
const size_t match_location = (best_prefix == NULL) ?
- std::wstring::npos : best_prefix->prefix.length() - offset;
+ string16::npos : best_prefix->prefix.length() - offset;
AutocompleteMatch::ClassifyLocationInString(match_location,
input.text().length(),
match.contents.length(),
@@ -371,7 +371,7 @@
if (!db->GetRowForURL(match->destination_url, &info)) {
if (input.desired_tld().empty())
return false;
- GURL destination_url(URLFixerUpper::FixupURL(WideToUTF8(input.text()),
+ GURL destination_url(URLFixerUpper::FixupURL(UTF16ToUTF8(input.text()),
std::string()));
if (!db->GetRowForURL(destination_url, NULL))
return false;
@@ -382,9 +382,9 @@
} else {
// We have data for this match, use it.
match->deletable = true;
- match->description = UTF16ToWide(info.title());
+ match->description = info.title();
AutocompleteMatch::ClassifyMatchInString(input.text(),
- UTF16ToWide(info.title()),
+ info.title(),
ACMatchClassification::NONE, &match->description_class);
if (!info.typed_count()) {
// If we reach here, we must be in the second pass, and we must not have
@@ -402,7 +402,7 @@
match->relevance = CalculateRelevance(input.type(), type, 0);
// Put it on the front of the HistoryMatches for redirect culling.
- EnsureMatchPresent(info, std::wstring::npos, false, matches, true);
+ EnsureMatchPresent(info, string16::npos, false, matches, true);
return true;
}
@@ -430,14 +430,15 @@
// We'll complete text following these prefixes.
// NOTE: There's no requirement that these be in any particular order.
Prefixes prefixes;
- prefixes.push_back(Prefix(L"https://www.", 2));
- prefixes.push_back(Prefix(L"http://www.", 2));
- prefixes.push_back(Prefix(L"ftp://ftp.", 2));
- prefixes.push_back(Prefix(L"ftp://www.", 2));
- prefixes.push_back(Prefix(L"https://", 1));
- prefixes.push_back(Prefix(L"http://", 1));
- prefixes.push_back(Prefix(L"ftp://", 1));
- prefixes.push_back(Prefix(L"", 0)); // Catches within-scheme matches as well
+ prefixes.push_back(Prefix(ASCIIToUTF16("https://www."), 2));
+ prefixes.push_back(Prefix(ASCIIToUTF16("http://www."), 2));
+ prefixes.push_back(Prefix(ASCIIToUTF16("ftp://ftp."), 2));
+ prefixes.push_back(Prefix(ASCIIToUTF16("ftp://www."), 2));
+ prefixes.push_back(Prefix(ASCIIToUTF16("https://"), 1));
+ prefixes.push_back(Prefix(ASCIIToUTF16("http://"), 1));
+ prefixes.push_back(Prefix(ASCIIToUTF16("ftp://"), 1));
+ // Empty string catches within-scheme matches as well.
+ prefixes.push_back(Prefix(string16(), 0));
return prefixes;
}
@@ -529,7 +530,7 @@
// static
void HistoryURLProvider::EnsureMatchPresent(
const history::URLRow& info,
- std::wstring::size_type input_location,
+ string16::size_type input_location,
bool match_in_scheme,
HistoryMatches* matches,
bool promote) {
@@ -594,7 +595,7 @@
// NOTE: This purposefully doesn't take input.desired_tld() into account; if
// it did, then holding "ctrl" would change all the results from the
// HistoryURLProvider provider, not just the What You Typed Result.
- const std::wstring fixed_text(FixupUserInput(input));
+ const string16 fixed_text(FixupUserInput(input));
if (fixed_text.empty()) {
// Conceivably fixup could result in an empty string (although I don't
// have cases where this happens offhand). We can't do anything with
@@ -635,14 +636,14 @@
const history::Prefix* HistoryURLProvider::BestPrefix(
const GURL& url,
- const std::wstring& prefix_suffix) const {
+ const string16& prefix_suffix) const {
const Prefix* best_prefix = NULL;
- const std::wstring text(UTF8ToWide(url.spec()));
+ const string16 text(UTF8ToUTF16(url.spec()));
for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end();
++i) {
if ((best_prefix == NULL) ||
(i->num_components > best_prefix->num_components)) {
- std::wstring prefix_with_suffix(i->prefix + prefix_suffix);
+ string16 prefix_with_suffix(i->prefix + prefix_suffix);
if ((text.length() >= prefix_with_suffix.length()) &&
!text.compare(0, prefix_with_suffix.length(), prefix_with_suffix))
best_prefix = &(*i);
@@ -778,32 +779,32 @@
0 : net::kFormatUrlOmitHTTP);
match.fill_into_edit =
AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(),
- UTF16ToWideHack(net::FormatUrl(info.url(), languages, format_types,
- UnescapeRule::SPACES, NULL, NULL,
- &inline_autocomplete_offset)));
+ net::FormatUrl(info.url(), languages, format_types,
+ UnescapeRule::SPACES, NULL, NULL,
+ &inline_autocomplete_offset));
if (!params->input.prevent_inline_autocomplete())
match.inline_autocomplete_offset = inline_autocomplete_offset;
- DCHECK((match.inline_autocomplete_offset == std::wstring::npos) ||
+ DCHECK((match.inline_autocomplete_offset == string16::npos) ||
(match.inline_autocomplete_offset <= match.fill_into_edit.length()));
size_t match_start = history_match.input_location;
- match.contents = UTF16ToWideHack(net::FormatUrl(info.url(), languages,
- format_types, UnescapeRule::SPACES, NULL, NULL, &match_start));
- if ((match_start != std::wstring::npos) &&
- (inline_autocomplete_offset != std::wstring::npos) &&
+ match.contents = net::FormatUrl(info.url(), languages,
+ format_types, UnescapeRule::SPACES, NULL, NULL, &match_start);
+ if ((match_start != string16::npos) &&
+ (inline_autocomplete_offset != string16::npos) &&
(inline_autocomplete_offset != match_start)) {
DCHECK(inline_autocomplete_offset > match_start);
AutocompleteMatch::ClassifyLocationInString(match_start,
inline_autocomplete_offset - match_start, match.contents.length(),
ACMatchClassification::URL, &match.contents_class);
} else {
- AutocompleteMatch::ClassifyLocationInString(std::wstring::npos, 0,
+ AutocompleteMatch::ClassifyLocationInString(string16::npos, 0,
match.contents.length(), ACMatchClassification::URL,
&match.contents_class);
}
- match.description = UTF16ToWide(info.title());
+ match.description = info.title();
AutocompleteMatch::ClassifyMatchInString(params->input.text(),
- UTF16ToWide(info.title()),
+ info.title(),
ACMatchClassification::NONE,
&match.description_class);

Powered by Google App Engine
This is Rietveld 408576698