Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / autocomplete / history_provider_util.h
blobd6b04da5344d536d06af834ee47ff8f49bf075d8
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_
8 #include <deque>
9 #include <vector>
11 #include "chrome/browser/history/history_types.h"
13 namespace history {
15 // Used for intermediate history result operations.
16 struct HistoryMatch {
17 // Required for STL, we don't use this directly.
18 HistoryMatch();
20 HistoryMatch(const URLRow& url_info,
21 size_t input_location,
22 bool match_in_scheme,
23 bool innermost_match);
25 static bool EqualsGURL(const HistoryMatch& h, const GURL& url);
27 // Returns true if url in this HistoryMatch is just a host
28 // (e.g. "http://www.google.com/") and not some other subpage
29 // (e.g. "http://www.google.com/foo.html").
30 bool IsHostOnly() const;
32 URLRow url_info;
34 // The offset of the user's input within the URL.
35 size_t input_location;
37 // Whether this is a match in the scheme. This determines whether we'll go
38 // ahead and show a scheme on the URL even if the user didn't type one.
39 // If our best match was in the scheme, not showing the scheme is both
40 // confusing and, for inline autocomplete of the fill_into_edit, dangerous.
41 // (If the user types "h" and we match "http://foo/", we need to inline
42 // autocomplete that, not "foo/", which won't show anything at all, and
43 // will mislead the user into thinking the What You Typed match is what's
44 // selected.)
45 bool match_in_scheme;
47 // A match after any scheme/"www.", if the user input could match at both
48 // locations. If the user types "w", an innermost match ("website.com") is
49 // better than a non-innermost match ("www.google.com"). If the user types
50 // "x", no scheme in our prefix list (or "www.") begins with x, so all
51 // matches are, vacuously, "innermost matches".
52 bool innermost_match;
54 // When sorting, all promoted matches should appear before all non-promoted
55 // matches, regardless of other properties of the match.
56 bool promoted;
58 typedef std::deque<HistoryMatch> HistoryMatches;
60 } // namespace history
62 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_