summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-20 20:06:53 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-20 20:06:53 +0000
commitebb1d5806faab39f4fcbc4a1261c47c3ebeda96a (patch)
treeeee91a248c5b1d705d3fa4feb8b01446ed16cafa
parent695891bb988c755ca79881169e1a8ab544d127dd (diff)
downloadchromium_src-ebb1d5806faab39f4fcbc4a1261c47c3ebeda96a.zip
chromium_src-ebb1d5806faab39f4fcbc4a1261c47c3ebeda96a.tar.gz
chromium_src-ebb1d5806faab39f4fcbc4a1261c47c3ebeda96a.tar.bz2
Merge 143064 - Allow nonzero verbatim relevance with no other SearchProvider matches.
Only ignore suggestions to suppres verbatim with no other matches. My previous CL is too restrictive of suggested verbatim relevances. (r142922 - Only use verbatimrelevance with other suggestions available) ignores suggested verbatim relevance if there are no other matches. Instead, it should only ignore suggestions to suppres verbatim. Note: Top scores are still clamped >= the calculated verbatim score. (see SearchProvider::ConvertResultsToAutocompleteMatches() line 776) I've also made this check applicable to verbatim matches themselves. BUG=125871,132942 TEST=Updated tests, manual. Review URL: https://chromiumcodereview.appspot.com/10559060 TBR=msw@chromium.org Review URL: https://chromiumcodereview.appspot.com/10581045 git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@143244 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/search_provider.cc43
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc4
2 files changed, 26 insertions, 21 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 256b188..daa9185 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -764,23 +764,23 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
if (!matches_.empty() &&
(has_suggested_relevance_ || verbatim_relevance_ >= 0)) {
bool reconstruct_matches = false;
- if (matches_.front().type == AutocompleteMatch::SEARCH_SUGGEST ||
- matches_.front().type == AutocompleteMatch::NAVSUGGEST) {
- if (matches_.front().inline_autocomplete_offset == string16::npos &&
- matches_.front().fill_into_edit != input_.text()) {
- // Disregard suggested relevances if the top result is not inlinable.
- // For example, input "foo" should not invoke a search for "bar", which
- // would happen if the "bar" search match outranked all other matches.
- ApplyCalculatedRelevance();
- reconstruct_matches = true;
- } else if (matches_.front().relevance < CalculateRelevanceForVerbatim()) {
- // Disregard the suggested verbatim relevance if the top score is below
- // the usual verbatim value. For example, a BarProvider may rely on
- // SearchProvider's verbatim or inlineable matches for input "foo" to
- // always outrank its own lowly-ranked non-inlineable "bar" match.
- verbatim_relevance_ = -1;
- reconstruct_matches = true;
- }
+ if (matches_.front().type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED &&
+ matches_.front().type != AutocompleteMatch::URL_WHAT_YOU_TYPED &&
+ matches_.front().inline_autocomplete_offset == string16::npos &&
+ matches_.front().fill_into_edit != input_.text()) {
+ // Disregard suggested relevances if the top match is not SWYT, inlinable,
+ // or URL_WHAT_YOU_TYPED (which may be top match regardless of inlining).
+ // For example, input "foo" should not invoke a search for "bar", which
+ // would happen if the "bar" search match outranked all other matches.
+ ApplyCalculatedRelevance();
+ reconstruct_matches = true;
+ } else if (matches_.front().relevance < CalculateRelevanceForVerbatim()) {
+ // Disregard the suggested verbatim relevance if the top score is below
+ // the usual verbatim value. For example, a BarProvider may rely on
+ // SearchProvider's verbatim or inlineable matches for input "foo" to
+ // always outrank its own lowly-ranked non-inlineable "bar" match.
+ verbatim_relevance_ = -1;
+ reconstruct_matches = true;
}
if (input_.type() == AutocompleteInput::URL &&
matches_.front().relevance > CalculateRelevanceForVerbatim() &&
@@ -933,14 +933,15 @@ void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results,
int SearchProvider::GetVerbatimRelevance() const {
// Use the suggested verbatim relevance score if it is non-negative (valid),
// if inline autocomplete isn't prevented (always show verbatim on backspace),
- // and if there is at least one other suggestion from the default provider
- // (otherwise, if the default provider returned no matches and was still able
+ // and if it won't suppress verbatim, leaving no default provider matches.
+ // Otherwise, if the default provider returned no matches and was still able
// to suppress verbatim, the user would have no search/nav matches and may be
- // left unable to search from the omnibox).
+ // left unable to search using their default provider from the omnibox.
// Check for results on each verbatim calculation, as results from older
// queries (on previous input) may be trimmed for failing to inline new input.
if (verbatim_relevance_ >= 0 && !input_.prevent_inline_autocomplete() &&
- (!default_suggest_results_.empty() ||
+ (verbatim_relevance_ > 0 ||
+ !default_suggest_results_.empty() ||
!default_navigation_results_.empty())) {
return verbatim_relevance_;
}
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 8d2d385..020ee41 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -809,6 +809,9 @@ TEST_F(SearchProviderTest, SuggestRelevanceExperiment) {
{ "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
"\"google:verbatimrelevance\":0}]",
{ "a", "a2", "a1", kNotApplicable } },
+ { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
+ "\"google:verbatimrelevance\":2}]",
+ { "a", "a2", "a1", kNotApplicable } },
{ "[\"a\",[\"http://a.com\"],[],[],"
"{\"google:suggesttype\":[\"NAVIGATION\"],"
"\"google:suggestrelevance\":[1],"
@@ -858,6 +861,7 @@ TEST_F(SearchProviderTest, SuggestRelevanceExperiment) {
{ "a2", "a", "a1", kNotApplicable } },
// Ensure that verbatim is always generated without other suggestions.
+ // TODO(msw): Ensure verbatimrelevance is respected (except suppression).
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
{ "a", kNotApplicable, kNotApplicable, kNotApplicable } },
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",