Home | History | Annotate | Download | only in browser
      1 // Copyright 2014 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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_MATCH_H_
      6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_MATCH_H_
      7 
      8 #include <deque>
      9 
     10 #include "components/history/core/browser/url_row.h"
     11 
     12 namespace history {
     13 
     14 // Used for intermediate history result operations.
     15 struct HistoryMatch {
     16   // Required for STL, we don't use this directly.
     17   HistoryMatch();
     18 
     19   HistoryMatch(const URLRow& url_info,
     20                size_t input_location,
     21                bool match_in_scheme,
     22                bool innermost_match);
     23 
     24   static bool EqualsGURL(const HistoryMatch& h, const GURL& url);
     25 
     26   // Returns true if url in this HistoryMatch is just a host
     27   // (e.g. "http://www.google.com/") and not some other subpage
     28   // (e.g. "http://www.google.com/foo.html").
     29   bool IsHostOnly() const;
     30 
     31   URLRow url_info;
     32 
     33   // The offset of the user's input within the URL.
     34   size_t input_location;
     35 
     36   // Whether this is a match in the scheme.  This determines whether we'll go
     37   // ahead and show a scheme on the URL even if the user didn't type one.
     38   // If our best match was in the scheme, not showing the scheme is both
     39   // confusing and, for inline autocomplete of the fill_into_edit, dangerous.
     40   // (If the user types "h" and we match "http://foo/", we need to inline
     41   // autocomplete that, not "foo/", which won't show anything at all, and
     42   // will mislead the user into thinking the What You Typed match is what's
     43   // selected.)
     44   bool match_in_scheme;
     45 
     46   // A match after any scheme/"www.", if the user input could match at both
     47   // locations.  If the user types "w", an innermost match ("website.com") is
     48   // better than a non-innermost match ("www.google.com").  If the user types
     49   // "x", no scheme in our prefix list (or "www.") begins with x, so all
     50   // matches are, vacuously, "innermost matches".
     51   bool innermost_match;
     52 };
     53 typedef std::deque<HistoryMatch> HistoryMatches;
     54 
     55 }  // namespace history
     56 
     57 #endif  // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_MATCH_H_
     58