Index: components/history/core/browser/scored_history_match_client.h |
diff --git a/components/history/core/browser/scored_history_match_client.h b/components/history/core/browser/scored_history_match_client.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..14ac5a0bb54b2ac00d1dd20030a7c0cb53523a7a |
--- /dev/null |
+++ b/components/history/core/browser/scored_history_match_client.h |
@@ -0,0 +1,72 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_HISTORY_CORE_BROWSER_SCORED_HISTORY_MATCH_CLIENT_H_ |
+#define COMPONENTS_HISTORY_CORE_BROWSER_SCORED_HISTORY_MATCH_CLIENT_H_ |
+ |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/strings/string16.h" |
+#include "base/strings/utf_offset_string_conversions.h" |
+ |
+class GURL; |
+ |
+namespace history { |
+ |
+class ScoredHistoryMatchClient { |
+ public: |
+ ScoredHistoryMatchClient(); |
+ virtual ~ScoredHistoryMatchClient(); |
+ |
+ // Returns whether the URL is bookmarked or not. |
+ virtual bool IsBoomarked(const GURL& url) const = 0; |
+ |
+ // Score for untyped visit to bookmarked pages (as opposed to 1 for |
+ // untyped visits to non-bookmarked pages and 20 for typed visits). |
+ virtual int BookmarkValue() const = 0; |
+ |
+ // If true, allow input terms to match in the TLD (e.g., .com). |
+ virtual bool AllowTldMatches() const = 0; |
+ |
+ // If true, allow input terms to match in the scheme (e.g., http://). |
+ virtual bool AllowSchemeMatches() const = 0; |
+ |
+ // Returns whether an autocomplete match can be inlined. If |innermost_match| |
+ // is non-null it will be set to true if the best prefix is the innermost one. |
+ virtual bool CanInlineAutocompleteMatch(const GURL& url, |
+ const base::string16& term, |
+ bool* innermost_match) const = 0; |
+ |
+ // Cleans up URL and title for matching, returning the cleaned up URL. |
+ // |languages| is passed to net::FormatURL(). |adjustments|, if non-null, is |
+ // set to reflect the transformations the URL spec underwent to become the |
+ // return value. |title|, if non-null, is cleaned up in-place. |
+ virtual base::string16 CleanUpUrlAndTitleForMatching( |
+ const GURL& url, |
+ const std::string& languages, |
+ base::OffsetAdjuster::Adjustments* adjustments, |
+ base::string16* title) const = 0; |
+ |
+ // Converts a raw score (a weighted sum of the number of hits for the term, |
+ // weigthed by how important the hit is: hostname, path, etc.) to the |
+ // topicality score we should assign it. |
+ float GetTopicalityScoreFromRawScore(int raw_score) const; |
+ |
+ // Returns the recency score to assign depending on how long ago a page was |
+ // visited (in days). |
+ float GetRecencyScore(int last_visit_days_ago) const; |
+ |
+ private: |
+ // Pre-computed information for |GetTopicalityScoreFromRawScore()| and |
+ // |GetRecencyScore()| respectively. |
+ std::vector<float> raw_score_to_topicality_score_; |
+ std::vector<float> days_ago_to_recency_score_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScoredHistoryMatchClient); |
+}; |
+ |
+} // namespace history |
+ |
+#endif // COMPONENTS_HISTORY_CORE_BROWSER_SCORED_HISTORY_MATCH_CLIENT_H_ |