Index: chrome/browser/autocomplete/autocomplete_match.cc |
diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc |
index 3909a32593f8a692fc2a7023069fa6b325a79d08..2573e1cc4617259c19f63836de7c66e1092dc164 100644 |
--- a/chrome/browser/autocomplete/autocomplete_match.cc |
+++ b/chrome/browser/autocomplete/autocomplete_match.cc |
@@ -356,11 +356,27 @@ bool AutocompleteMatch::IsSearchType(Type type) { |
type == SEARCH_OTHER_ENGINE; |
} |
-void AutocompleteMatch::ComputeStrippedDestinationURL() { |
+void AutocompleteMatch::ComputeStrippedDestinationURL( |
+ TemplateURL* search_provider_url) { |
stripped_destination_url = destination_url; |
if (!stripped_destination_url.is_valid()) |
return; |
+ // Attempt to normalize search URLs by removing non-essential substitutions |
+ // like aqs/oq/aq. |
beaudoin
2012/10/19 14:25:34
I would not be opposed to adding a NormalizeURL to
|
+ if (search_provider_url != NULL) { |
+ string16 search_terms; |
+ if (search_provider_url->ExtractSearchTermsFromURL(stripped_destination_url, |
+ &search_terms)) { |
+ // Rewrite the URL by using the extracted search terms and ignoring other |
+ // arguments (it's OK, because it doesn't affect the destination URL and |
+ // is sufficient from de-dupping perspective). |
beaudoin
2012/10/19 14:25:34
This may confuse an "image search" with a regular
Peter Kasting
2012/10/19 22:49:33
Uuuuugggghhh. This is the sort of reason why I ge
Bart N.
2012/10/22 18:20:24
I agree this is a problem here. Even with your pro
beaudoin
2012/10/22 18:43:23
The problem is that ExtractSearchTermsFromURL is "
Bart N.
2012/10/22 19:19:42
Yes, totally makes sense. I didn't mean to make Ex
beaudoin
2012/10/22 21:36:48
Totally. It would probably also have to wait after
|
+ stripped_destination_url = |
+ GURL(search_provider_url->url_ref().ReplaceSearchTerms( |
+ TemplateURLRef::SearchTermsArgs(search_terms))); |
Peter Kasting
2012/10/19 22:49:33
In the original bug we proposed replacing the actu
Bart N.
2012/10/22 18:20:24
Yup, I'm totally aware of that, in fact it could h
beaudoin
2012/10/22 18:43:23
With the approach above we could maybe even recons
Bart N.
2012/10/22 19:19:42
Agreed. It would be clean and Google-agnostic.
|
+ } |
+ } |
+ |
// |replacements| keeps all the substitions we're going to make to |
// from {destination_url} to {stripped_destination_url}. |need_replacement| |
// is a helper variable that helps us keep track of whether we need |
@@ -371,7 +387,7 @@ void AutocompleteMatch::ComputeStrippedDestinationURL() { |
// Remove the www. prefix from the host. |
static const char prefix[] = "www."; |
static const size_t prefix_len = arraysize(prefix) - 1; |
- std::string host = destination_url.host(); |
+ std::string host = stripped_destination_url.host(); |
if (host.compare(0, prefix_len, prefix) == 0) { |
host = host.substr(prefix_len); |
replacements.SetHostStr(host); |
@@ -387,7 +403,8 @@ void AutocompleteMatch::ComputeStrippedDestinationURL() { |
} |
if (needs_replacement) |
- stripped_destination_url = destination_url.ReplaceComponents(replacements); |
+ stripped_destination_url = stripped_destination_url.ReplaceComponents( |
+ replacements); |
} |
void AutocompleteMatch::GetKeywordUIState(Profile* profile, |