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

Unified Diff: chrome/browser/history/scored_history_match.cc

Issue 284183011: Code clean up for ScoredHistoryMatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test info and formatted the code 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/scored_history_match.cc
diff --git a/chrome/browser/history/scored_history_match.cc b/chrome/browser/history/scored_history_match.cc
index b5219fe6b894b74e7b99e9e6668cb06594ec90e7..0d269befe053106b59d5dc0af6b27793a790083a 100644
--- a/chrome/browser/history/scored_history_match.cc
+++ b/chrome/browser/history/scored_history_match.cc
@@ -16,13 +16,20 @@
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/autocomplete/history_url_provider.h"
#include "chrome/browser/autocomplete/url_prefix.h"
#include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/history/core/browser/history_client.h"
#include "content/public/browser/browser_thread.h"
+namespace {
+
+// These magic numbers are duplicated from HistoryURLProvider
+const int kScoreForBestInlineableResult = 1413;
+const int kBaseScoreForNonInlineableResult = 900;
+
+} // namespace
+
namespace history {
// ScoredHistoryMatch ----------------------------------------------------------
@@ -38,7 +45,6 @@ int ScoredHistoryMatch::bookmark_value_ = 1;
bool ScoredHistoryMatch::allow_tld_matches_ = false;
bool ScoredHistoryMatch::allow_scheme_matches_ = false;
bool ScoredHistoryMatch::also_do_hup_like_scoring_ = false;
-int ScoredHistoryMatch::max_assigned_score_for_non_inlineable_matches_ = -1;
ScoredHistoryMatch::ScoredHistoryMatch()
: raw_score_(0),
@@ -166,9 +172,8 @@ ScoredHistoryMatch::ScoredHistoryMatch(
// HistoryURLProvider::PromoteMatchForInlineAutocomplete().
const bool promote_to_inline = (row.typed_count() > 1) ||
(IsHostOnly() && (row.typed_count() == 1));
- int hup_like_score = promote_to_inline ?
- HistoryURLProvider::kScoreForBestInlineableResult :
- HistoryURLProvider::kBaseScoreForNonInlineableResult;
+ int hup_like_score = promote_to_inline ? kScoreForBestInlineableResult
+ : kBaseScoreForNonInlineableResult;
// Also, if the user types the hostname of a host with a typed
// visit, then everything from that host get given inlineable scores
@@ -176,7 +181,7 @@ ScoredHistoryMatch::ScoredHistoryMatch(
// else will be assigned one minus the previous score, as coded
// at the end of HistoryURLProvider::DoAutocomplete().
if (base::UTF8ToUTF16(gurl.host()) == terms[0])
- hup_like_score = HistoryURLProvider::kScoreForBestInlineableResult;
+ hup_like_score = kScoreForBestInlineableResult;
// HistoryURLProvider has the function PromoteOrCreateShorterSuggestion()
// that's meant to promote prefixes of the best match (if they've
@@ -202,13 +207,6 @@ ScoredHistoryMatch::ScoredHistoryMatch(
raw_score_ = std::max(raw_score_, hup_like_score);
}
- // If this match is not inlineable and there's a cap on the maximum
blundell 2014/06/11 18:17:36 Why did this code go away?
nshaik 2014/06/11 20:46:50 That code is applicable only if max_assigned_score
- // score that can be given to non-inlineable matches, apply the cap.
- if (!can_inline_ && (max_assigned_score_for_non_inlineable_matches_ != -1)) {
- raw_score_ = std::min(max_assigned_score_for_non_inlineable_matches_,
- raw_score_);
- }
-
// Now that we're done processing this entry, correct the offsets of the
// matches in |url_matches_| so they point to offsets in the original URL
// spec, not the cleaned-up URL string that we used for matching.
@@ -585,20 +583,6 @@ float ScoredHistoryMatch::GetFinalRelevancyScore(float topicality_score,
void ScoredHistoryMatch::Init() {
if (initialized_)
return;
- also_do_hup_like_scoring_ = false;
blundell 2014/06/11 18:17:36 This assignment has to stay I would think?
nshaik 2014/06/11 20:46:50 It is always assigned to false. So I deleted it. I
- // When doing HUP-like scoring, don't allow a non-inlineable match
- // to beat the score of good inlineable matches. This is a problem
- // because if a non-inlineable match ends up with the highest score
- // from HistoryQuick provider, all HistoryQuick matches get demoted
- // to non-inlineable scores (scores less than 1200). Without
- // HUP-like-scoring, these results would actually come from the HUP
- // and not be demoted, thus outscoring the demoted HQP results.
- // When the HQP provides these, we need to clamp the non-inlineable
- // results to preserve this behavior.
- if (also_do_hup_like_scoring_) {
- max_assigned_score_for_non_inlineable_matches_ =
- HistoryURLProvider::kScoreForBestInlineableResult - 1;
- }
bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue();
allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue();
allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698