Index: chrome/browser/autocomplete/autocomplete_match.cc |
=================================================================== |
--- chrome/browser/autocomplete/autocomplete_match.cc (revision 94623) |
+++ chrome/browser/autocomplete/autocomplete_match.cc (working copy) |
@@ -37,9 +37,61 @@ |
from_previous(false) { |
} |
+AutocompleteMatch::AutocompleteMatch(const AutocompleteMatch& match) |
+ : provider(match.provider), |
+ relevance(match.relevance), |
+ deletable(match.deletable), |
+ inline_autocomplete_offset(match.inline_autocomplete_offset), |
+ transition(match.transition), |
+ is_history_what_you_typed_match(match.is_history_what_you_typed_match), |
+ type(match.type), |
+ keyword(match.keyword), |
+ template_url(match.template_url), |
+ starred(match.starred), |
+ from_previous(match.from_previous), |
sky
2011/08/01 16:02:15
Order doesn't match declaration order.
|
+ fill_into_edit(match.fill_into_edit), |
+ destination_url(match.destination_url), |
+ stripped_destination_url(match.stripped_destination_url), |
+ contents(match.contents), |
+ contents_class(match.contents_class), |
+ description(match.description), |
+ description_class(match.description_class) { |
+ if (match.associated_keyword.get()) |
+ associated_keyword.reset(new AutocompleteMatch(*match.associated_keyword)); |
+} |
+ |
AutocompleteMatch::~AutocompleteMatch() { |
} |
+AutocompleteMatch& AutocompleteMatch::operator=( |
+ const AutocompleteMatch& match) { |
+ if (this == &match) |
+ return *this; |
+ |
+ provider = match.provider; |
+ relevance = match.relevance; |
+ deletable = match.deletable; |
+ inline_autocomplete_offset = match.inline_autocomplete_offset; |
+ transition = match.transition; |
+ is_history_what_you_typed_match = match.is_history_what_you_typed_match; |
+ type = match.type; |
+ keyword = match.keyword; |
+ template_url = match.template_url; |
+ starred = match.starred; |
+ from_previous = match.from_previous; |
+ fill_into_edit = match.fill_into_edit; |
+ destination_url = match.destination_url; |
+ stripped_destination_url = match.stripped_destination_url; |
+ contents = match.contents; |
+ contents_class = match.contents_class; |
+ description = match.description; |
+ description_class = match.description_class; |
+ associated_keyword.reset(match.associated_keyword.get() ? |
+ new AutocompleteMatch(*match.associated_keyword) : NULL); |
sky
2011/08/01 16:02:15
nit: indent 2 more
|
+ |
+ return *this; |
+} |
+ |
// static |
std::string AutocompleteMatch::TypeToString(Type type) { |
const char* strings[] = { |
@@ -98,15 +150,15 @@ |
// Sort identical destination_urls together. Place the most relevant matches |
// first, so that when we call std::unique(), these are the ones that get |
// preserved. |
- return (elem1.destination_url != elem2.destination_url) ? |
- (elem1.destination_url < elem2.destination_url) : |
+ return (elem1.stripped_destination_url != elem2.stripped_destination_url) ? |
+ (elem1.stripped_destination_url < elem2.stripped_destination_url) : |
MoreRelevant(elem1, elem2); |
} |
// static |
bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, |
const AutocompleteMatch& elem2) { |
- return elem1.destination_url == elem2.destination_url; |
+ return elem1.stripped_destination_url == elem2.stripped_destination_url; |
} |
// static |
@@ -156,6 +208,22 @@ |
} |
} |
+void AutocompleteMatch::ComputeStrippedDestinationURL() { |
+ static const char prefix[] = "www."; |
+ static const size_t prefix_len = arraysize(prefix) - 1; |
+ |
+ std::string host = destination_url.host(); |
+ if (destination_url.is_valid() && host.compare(0, prefix_len, prefix) == 0) { |
+ host = host.substr(prefix_len); |
sky
2011/08/01 16:02:15
Spacing is off.
|
+ GURL::Replacements replace_host; |
+ replace_host.SetHostStr(host); |
+ stripped_destination_url = |
+ destination_url.ReplaceComponents(replace_host); |
+ } else { |
+ stripped_destination_url = destination_url; |
+ } |
+} |
+ |
#ifndef NDEBUG |
void AutocompleteMatch::Validate() const { |
ValidateClassifications(contents, contents_class); |