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

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

Issue 11198074: Initial implementation of dedupping search provider's URLs. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix a minor compilation error. Created 8 years, 2 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/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,

Powered by Google App Engine
This is Rietveld 408576698