Remove Profile from BaseSearchProvider::NavigationResult

No need to call GetPrefs()->GetString(prefs::kAcceptLanguages) as all callers are passing the same value as |languages|.

BUG=388515
TEST=build

Review URL: https://codereview.chromium.org/372843005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281972 0039d316-1c4b-4281-b951-d872f2087c98
parent bac78f9f
......@@ -65,15 +65,6 @@ AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) {
return AutocompleteMatchType::SEARCH_SUGGEST;
}
base::string16 StringForURLDisplayWithAcceptLanguages(Profile* profile,
const GURL& url) {
std::string languages = profile ?
profile->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::string();
return net::FormatUrl(url, languages,
net::kFormatUrlOmitAll & ~net::kFormatUrlOmitHTTP,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
}
} // namespace
// SuggestionDeletionHandler -------------------------------------------------
......@@ -364,8 +355,7 @@ int BaseSearchProvider::SuggestResult::CalculateRelevance(
// BaseSearchProvider::NavigationResult ----------------------------------------
BaseSearchProvider::NavigationResult::NavigationResult(
const AutocompleteProvider& provider,
Profile* profile,
const AutocompleteSchemeClassifier& scheme_classifier,
const GURL& url,
AutocompleteMatchType::Type type,
const base::string16& description,
......@@ -379,8 +369,10 @@ BaseSearchProvider::NavigationResult::NavigationResult(
deletion_url),
url_(url),
formatted_url_(AutocompleteInput::FormattedStringWithEquivalentMeaning(
url, StringForURLDisplayWithAcceptLanguages(profile, url),
ChromeAutocompleteSchemeClassifier(profile))),
url, net::FormatUrl(url, languages,
net::kFormatUrlOmitAll & ~net::kFormatUrlOmitHTTP,
net::UnescapeRule::SPACES, NULL, NULL, NULL),
scheme_classifier)),
description_(description) {
DCHECK(url_.is_valid());
CalculateAndClassifyMatchContents(true, input_text, languages);
......@@ -913,9 +905,9 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val,
if (descriptions != NULL)
descriptions->GetString(index, &title);
results->navigation_results.push_back(NavigationResult(
*this, profile_, url, match_type, title, deletion_url,
is_keyword_result, relevance, relevances != NULL, input.text(),
languages));
ChromeAutocompleteSchemeClassifier(profile_), url, match_type,
title, deletion_url, is_keyword_result, relevance,
relevances != NULL, input.text(), languages));
}
} else {
base::string16 match_contents = suggestion;
......
......@@ -248,9 +248,7 @@ class BaseSearchProvider : public AutocompleteProvider,
class NavigationResult : public Result {
public:
// |provider| and |profile| are both used to compute |formatted_url_|.
NavigationResult(const AutocompleteProvider& provider,
Profile* profile,
NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier,
const GURL& url,
AutocompleteMatchType::Type type,
const base::string16& description,
......
......@@ -2359,7 +2359,7 @@ TEST_F(SearchProviderTest, NavigationInline) {
QueryForInput(ASCIIToUTF16(cases[i].input), false, false);
AutocompleteMatch match(
provider_->NavigationToMatch(SearchProvider::NavigationResult(
*provider_.get(), &profile_, GURL(cases[i].url),
ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url),
AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(),
false, 0, false, ASCIIToUTF16(cases[i].input), std::string())));
EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
......@@ -2372,7 +2372,7 @@ TEST_F(SearchProviderTest, NavigationInline) {
QueryForInput(ASCIIToUTF16(cases[i].input), true, false);
AutocompleteMatch match_prevent_inline(
provider_->NavigationToMatch(SearchProvider::NavigationResult(
*provider_.get(), &profile_, GURL(cases[i].url),
ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url),
AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(),
false, 0, false, ASCIIToUTF16(cases[i].input), std::string())));
EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
......@@ -2389,7 +2389,8 @@ TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) {
const base::string16 input(ASCIIToUTF16("ht"));
const base::string16 url(ASCIIToUTF16("http://a.com"));
const SearchProvider::NavigationResult result(
*provider_.get(), &profile_, GURL(url), AutocompleteMatchType::NAVSUGGEST,
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST,
base::string16(), std::string(), false, 0, false, input, std::string());
// Check the offset and strings when inline autocompletion is allowed.
......@@ -2413,7 +2414,8 @@ TEST_F(SearchProviderTest, NavigationInlineDomainClassify) {
QueryForInput(ASCIIToUTF16("w"), false, false);
AutocompleteMatch match(
provider_->NavigationToMatch(SearchProvider::NavigationResult(
*provider_.get(), &profile_, GURL("http://www.wow.com"),
ChromeAutocompleteSchemeClassifier(&profile_),
GURL("http://www.wow.com"),
AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(),
false, 0, false, ASCIIToUTF16("w"), std::string())));
EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion);
......
......@@ -376,10 +376,10 @@ void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
for (size_t i = 0; i < most_visited_urls_.size(); i++) {
const history::MostVisitedURL& url = most_visited_urls_[i];
NavigationResult nav(*this, profile_, url.url,
AutocompleteMatchType::NAVSUGGEST, url.title,
std::string(), false, relevance, true,
current_query_string16, languages);
NavigationResult nav(
ChromeAutocompleteSchemeClassifier(profile_), url.url,
AutocompleteMatchType::NAVSUGGEST, url.title, std::string(), false,
relevance, true, current_query_string16, languages);
matches_.push_back(NavigationToMatch(nav));
--relevance;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment