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

Unified Diff: chrome/browser/search_engines/template_url_service.cc

Issue 343823002: Move GenerateSearchURL() and GenerateKeyword() from TemplateURLService to TemplateURL (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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/search_engines/template_url_service.cc
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index fc0e8874c5751ec3b26c5fa20e8f8ab4f4a36117..cbd7d18b3abfbb461c6ac34c217d3ab3a56509ff 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -377,18 +377,6 @@ bool TemplateURLService::LoadDefaultSearchProviderFromPrefs(
}
// static
-base::string16 TemplateURLService::GenerateKeyword(const GURL& url) {
- DCHECK(url.is_valid());
- // Strip "www." off the front of the keyword; otherwise the keyword won't work
- // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 .
- // Special case: if the host was exactly "www." (not sure this can happen but
- // perhaps with some weird intranet and custom DNS server?), ensure we at
- // least don't return the empty string.
- base::string16 keyword(net::StripWWWFromHost(url));
- return keyword.empty() ? base::ASCIIToUTF16("www") : keyword;
-}
-
-// static
base::string16 TemplateURLService::CleanUserInputKeyword(
const base::string16& keyword) {
// Remove the scheme.
@@ -424,30 +412,6 @@ base::string16 TemplateURLService::CleanUserInputKeyword(
}
// static
-GURL TemplateURLService::GenerateSearchURL(
- const TemplateURL* t_url,
- const SearchTermsData& search_terms_data) {
- DCHECK(t_url);
-
- const TemplateURLRef& search_ref = t_url->url_ref();
- if (!search_ref.IsValid(search_terms_data))
- return GURL();
-
- if (!search_ref.SupportsReplacement(search_terms_data))
- return GURL(t_url->url());
-
- // Use something obscure for the search terms argument so that in the rare
- // case the term replaces the URL it's unlikely another keyword would have the
- // same url.
- // TODO(jnd): Add additional parameters to get post data when the search URL
- // has post parameters.
- return GURL(search_ref.ReplaceSearchTerms(
- TemplateURLRef::SearchTermsArgs(
- base::ASCIIToUTF16("blah.blah.blah.blah.blah")),
- search_terms_data, NULL));
-}
-
-// static
void TemplateURLService::SaveDefaultSearchProviderToPrefs(
const TemplateURL* t_url,
PrefService* prefs) {
@@ -608,7 +572,7 @@ TemplateURL* TemplateURLService::GetTemplateURLForHost(
TemplateURL* initial_dsp = initial_default_search_provider_.get();
if (!initial_dsp)
return NULL;
- return (GenerateSearchURL(initial_dsp, search_terms_data()).host() == host) ?
+ return (initial_dsp->GenerateSearchURL(search_terms_data()).host() == host) ?
initial_dsp : NULL;
}
@@ -698,8 +662,8 @@ void TemplateURLService::RemoveAutoGeneratedForOriginBetween(
template_urls_[i]->date_created() < created_before) &&
CanReplace(template_urls_[i]) &&
(o.is_empty() ||
- GenerateSearchURL(template_urls_[i],
- search_terms_data()).GetOrigin() == o)) {
+ template_urls_[i]->GenerateSearchURL(
+ search_terms_data()).GetOrigin() == o)) {
RemoveNoNotify(template_urls_[i]);
should_notify = true;
} else {
@@ -2274,7 +2238,7 @@ base::string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl,
GURL gurl(turl.url());
if (gurl.is_valid() &&
(turl.GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) {
- base::string16 keyword_candidate = GenerateKeyword(gurl);
+ base::string16 keyword_candidate = TemplateURL::GenerateKeyword(gurl);
if (!GetTemplateURLForKeyword(keyword_candidate))
return keyword_candidate;
}

Powered by Google App Engine
This is Rietveld 408576698