| Index: chrome/browser/autocomplete/autocomplete_match.cc
|
| ===================================================================
|
| --- chrome/browser/autocomplete/autocomplete_match.cc (revision 81359)
|
| +++ chrome/browser/autocomplete/autocomplete_match.cc (working copy)
|
| @@ -16,9 +16,10 @@
|
| transition(PageTransition::GENERATED),
|
| is_history_what_you_typed_match(false),
|
| type(SEARCH_WHAT_YOU_TYPED),
|
| - template_url(NULL),
|
| + keyword_url(NULL),
|
| starred(false),
|
| - from_previous(false) {
|
| + from_previous(false),
|
| + keyword_state(NO_KEYWORD) {
|
| }
|
|
|
| AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider,
|
| @@ -32,9 +33,10 @@
|
| transition(PageTransition::TYPED),
|
| is_history_what_you_typed_match(false),
|
| type(type),
|
| - template_url(NULL),
|
| + keyword_url(NULL),
|
| starred(false),
|
| - from_previous(false) {
|
| + from_previous(false),
|
| + keyword_state(NO_KEYWORD) {
|
| }
|
|
|
| AutocompleteMatch::~AutocompleteMatch() {
|
| @@ -94,15 +96,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
|
| @@ -151,6 +153,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);
|
| + 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);
|
|
|