| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ | |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <deque> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "chrome/browser/history/history_types.h" | |
| 13 | |
| 14 namespace history { | |
| 15 | |
| 16 // Constants which specify, when considered altogether, 'significant' | |
| 17 // history items. These are used to filter out insignificant items | |
| 18 // for consideration as autocomplete candidates. | |
| 19 extern const int kLowQualityMatchTypedLimit; | |
| 20 extern const int kLowQualityMatchVisitLimit; | |
| 21 extern const int kLowQualityMatchAgeLimitInDays; | |
| 22 | |
| 23 // Used for intermediate history result operations. | |
| 24 struct HistoryMatch { | |
| 25 // Required for STL, we don't use this directly. | |
| 26 HistoryMatch(); | |
| 27 | |
| 28 HistoryMatch(const URLRow& url_info, | |
| 29 size_t input_location, | |
| 30 bool match_in_scheme, | |
| 31 bool innermost_match); | |
| 32 | |
| 33 bool operator==(const GURL& url) const; | |
| 34 | |
| 35 URLRow url_info; | |
| 36 | |
| 37 // The offset of the user's input within the URL. | |
| 38 size_t input_location; | |
| 39 | |
| 40 // Whether this is a match in the scheme. This determines whether we'll go | |
| 41 // ahead and show a scheme on the URL even if the user didn't type one. | |
| 42 // If our best match was in the scheme, not showing the scheme is both | |
| 43 // confusing and, for inline autocomplete of the fill_into_edit, dangerous. | |
| 44 // (If the user types "h" and we match "http://foo/", we need to inline | |
| 45 // autocomplete that, not "foo/", which won't show anything at all, and | |
| 46 // will mislead the user into thinking the What You Typed match is what's | |
| 47 // selected.) | |
| 48 bool match_in_scheme; | |
| 49 | |
| 50 // A match after any scheme/"www.", if the user input could match at both | |
| 51 // locations. If the user types "w", an innermost match ("website.com") is | |
| 52 // better than a non-innermost match ("www.google.com"). If the user types | |
| 53 // "x", no scheme in our prefix list (or "www.") begins with x, so all | |
| 54 // matches are, vacuously, "innermost matches". | |
| 55 bool innermost_match; | |
| 56 }; | |
| 57 typedef std::deque<HistoryMatch> HistoryMatches; | |
| 58 | |
| 59 struct Prefix { | |
| 60 Prefix(const std::wstring& prefix, int num_components) | |
| 61 : prefix(prefix), | |
| 62 num_components(num_components) {} | |
| 63 | |
| 64 std::wstring prefix; | |
| 65 | |
| 66 // The number of "components" in the prefix. The scheme is a component, | |
| 67 // and the initial "www." or "ftp." is a component. So "http://foo.com" | |
| 68 // and "www.bar.com" each have one component, "ftp://ftp.ftp.com" has two, | |
| 69 // and "mysite.com" has none. This is used to tell whether the user's | |
| 70 // input is an innermost match or not. See comments in HistoryMatch. | |
| 71 int num_components; | |
| 72 }; | |
| 73 typedef std::vector<Prefix> Prefixes; | |
| 74 | |
| 75 // Returns the date threshold for considering an history item as significant. | |
| 76 base::Time AutocompleteAgeThreshold(); | |
| 77 | |
| 78 } | |
| 79 | |
| 80 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ | |
| OLD | NEW |