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

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: Created 6 years, 7 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/history/scored_history_match.cc
diff --git a/chrome/browser/history/scored_history_match.cc b/chrome/browser/history/scored_history_match.cc
index e713b2575df6caf2d206ec399eb901b3bd96db01..7246107dbb699c55387d40ac9667083c06390c64 100644
--- a/chrome/browser/history/scored_history_match.cc
+++ b/chrome/browser/history/scored_history_match.cc
@@ -16,7 +16,6 @@
#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_service.h"
@@ -40,6 +39,12 @@ bool ScoredHistoryMatch::allow_scheme_matches_ = false;
bool ScoredHistoryMatch::also_do_hup_like_scoring_ = false;
int ScoredHistoryMatch::max_assigned_score_for_non_inlineable_matches_ = -1;
+// These magic numbers are duplicated from HistoryURLProvider
+const int ScoredHistoryMatch::kScoreForBestInlineableResult = 1413;
+const int ScoredHistoryMatch::kScoreForUnvisitedIntranetResult = 1403;
+const int ScoredHistoryMatch::kScoreForWhatYouTypedResult = 1203;
+const int ScoredHistoryMatch::kBaseScoreForNonInlineableResult = 900;
+
ScoredHistoryMatch::ScoredHistoryMatch()
: raw_score_(0),
can_inline_(false) {
@@ -163,20 +168,20 @@ ScoredHistoryMatch::ScoredHistoryMatch(
// capable of being inlined a certain minimum score. Some of these
// are given a higher score that lets them be shown in inline.
// This test here derives from the test in
- // HistoryURLProvider::PromoteMatchForInlineAutocomplete().
+ // ScoredHistoryMatch::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;
+ ScoredHistoryMatch::kScoreForBestInlineableResult :
+ ScoredHistoryMatch::kBaseScoreForNonInlineableResult;
// Also, if the user types the hostname of a host with a typed
// visit, then everything from that host get given inlineable scores
// (because the URL-that-you-typed will go first and everything
// else will be assigned one minus the previous score, as coded
- // at the end of HistoryURLProvider::DoAutocomplete().
+ // at the end of ScoredHistoryMatch::DoAutocomplete().
if (base::UTF8ToUTF16(gurl.host()) == terms[0])
- hup_like_score = HistoryURLProvider::kScoreForBestInlineableResult;
+ hup_like_score = ScoredHistoryMatch::kScoreForBestInlineableResult;
// HistoryURLProvider has the function PromoteOrCreateShorterSuggestion()
// that's meant to promote prefixes of the best match (if they've
@@ -597,7 +602,7 @@ void ScoredHistoryMatch::Init() {
// results to preserve this behavior.
if (also_do_hup_like_scoring_) {
max_assigned_score_for_non_inlineable_matches_ =
- HistoryURLProvider::kScoreForBestInlineableResult - 1;
+ ScoredHistoryMatch::kScoreForBestInlineableResult - 1;
}
bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue();
allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue();

Powered by Google App Engine
This is Rietveld 408576698