summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:14:03 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:14:03 +0000
commit94ae90b9e3ac759801997ff79d42fe27dff88139 (patch)
tree9f454072d60d6e65a99b1972649cb00371e7d779 /chrome/browser/autocomplete
parent6f8013422aeb79649086c0ee99b3fa453b3738af (diff)
downloadchromium_src-94ae90b9e3ac759801997ff79d42fe27dff88139.zip
chromium_src-94ae90b9e3ac759801997ff79d42fe27dff88139.tar.gz
chromium_src-94ae90b9e3ac759801997ff79d42fe27dff88139.tar.bz2
Revert "Incorporate 'quick' history provider index as an autocomplete ..."
Broke AutocompleteEditViewTest.DesiredTLD and AutocompleteEditView.EscapeToDefaultMatch on Linux. TBR=mrossetti Review URL: http://codereview.chromium.org/3052031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54380 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc11
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.cc10
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.h39
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc35
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc216
-rw-r--r--chrome/browser/autocomplete/history_url_provider.h109
6 files changed, 197 insertions, 223 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index 23a68f4..d24e209 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -8,12 +8,10 @@
#include "app/l10n_util.h"
#include "base/basictypes.h"
-#include "base/command_line.h"
#include "base/i18n/number_formatting.h"
#include "base/string_util.h"
-#include "chrome/browser/autocomplete/history_contents_provider.h"
-#include "chrome/browser/autocomplete/history_quick_provider.h"
#include "chrome/browser/autocomplete/history_url_provider.h"
+#include "chrome/browser/autocomplete/history_contents_provider.h"
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -22,7 +20,6 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -758,11 +755,7 @@ AutocompleteController::AutocompleteController(Profile* profile)
have_committed_during_this_query_(false),
done_(true) {
providers_.push_back(new SearchProvider(this, profile));
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableInMemoryURLIndex))
- providers_.push_back(new HistoryQuickProvider(this, profile));
- else
- providers_.push_back(new HistoryURLProvider(this, profile));
+ providers_.push_back(new HistoryURLProvider(this, profile));
providers_.push_back(new KeywordProvider(this, profile));
history_contents_provider_ = new HistoryContentsProvider(this, profile);
providers_.push_back(history_contents_provider_);
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc
deleted file mode 100644
index 0d4fdda..0000000
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "chrome/browser/autocomplete/history_quick_provider.h"
-
-void HistoryQuickProvider::Start(const AutocompleteInput& input,
- bool minimal_changes) {
- // TODO(mrossetti): Implement.
-}
diff --git a/chrome/browser/autocomplete/history_quick_provider.h b/chrome/browser/autocomplete/history_quick_provider.h
deleted file mode 100644
index c0dcc15..0000000
--- a/chrome/browser/autocomplete/history_quick_provider.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2010 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 CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
-#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
-
-#include "chrome/browser/autocomplete/autocomplete.h"
-
-// This class is an autocomplete provider (a pseudo-internal component of
-// the history system) which quickly (and synchronously) provides matching
-// results from recently or frequently visited sites in the profile's
-// history.
-//
-// TODO(mrossetti): Review to see if the following applies since we're not
-// using the database during the autocomplete pass.
-//
-// Note: This object can get leaked on shutdown if there are pending
-// requests on the database (which hold a reference to us). Normally, these
-// messages get flushed for each thread. We do a round trip from main, to
-// history, back to main while holding a reference. If the main thread
-// completes before the history thread, the message to delegate back to the
-// main thread will not run and the reference will leak. Therefore, don't do
-// anything on destruction.
-class HistoryQuickProvider : public AutocompleteProvider {
- public:
- HistoryQuickProvider(ACProviderListener* listener, Profile* profile)
- : AutocompleteProvider(listener, profile, "HistoryQuickProvider") {}
-
- // no destructor (see note above)
-
- // AutocompleteProvider
- void Start(const AutocompleteInput& input, bool minimal_changes);
-
- private:
- ~HistoryQuickProvider() {}
-};
-
-#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
deleted file mode 100644
index 24ed677..0000000
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "chrome/browser/autocomplete/history_quick_provider.h"
-
-#include "base/scoped_ptr.h"
-#include "chrome/test/testing_profile.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class HistoryQuickProviderTest : public testing::Test,
- public ACProviderListener {
- public:
- // ACProviderListener
- virtual void OnProviderUpdate(bool updated_matches);
-
- protected:
- void SetUp() {
- profile_.reset(new TestingProfile());
- provider_ = new HistoryQuickProvider(this, profile_.get());
- }
- void TearDown() {
- provider_ = NULL;
- }
-
- scoped_refptr<HistoryQuickProvider> provider_;
- scoped_ptr<TestingProfile> profile_;
-};
-
-void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) {
-}
-
-TEST_F(HistoryQuickProviderTest, Construction) {
- EXPECT_TRUE(provider_.get());
-}
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 3d15658..bac2d1a 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/histogram.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -17,6 +18,7 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -27,80 +29,6 @@
using base::Time;
using base::TimeDelta;
using base::TimeTicks;
-// TODO(mrossetti): Move these to a more appropriate place.
-using history::Prefix;
-using history::Prefixes;
-using history::HistoryMatch;
-using history::HistoryMatches;
-
-namespace history {
-
-// Returns true if |url| is just a host (e.g. "http://www.google.com/") and
-// not some other subpage (e.g. "http://www.google.com/foo.html").
-bool IsHostOnly(const GURL& url) {
- DCHECK(url.is_valid());
- return (!url.has_path() || (url.path() == "/")) && !url.has_query() &&
- !url.has_ref();
-}
-
-// Acts like the > operator for URLInfo classes.
-bool CompareHistoryMatch(const HistoryMatch& a, const HistoryMatch& b) {
- // A URL that has been typed at all is better than one that has never been
- // typed. (Note "!"s on each side)
- if (!a.url_info.typed_count() != !b.url_info.typed_count())
- return a.url_info.typed_count() > b.url_info.typed_count();
-
- // Innermost matches (matches after any scheme or "www.") are better than
- // non-innermost matches.
- if (a.innermost_match != b.innermost_match)
- return a.innermost_match;
-
- // URLs that have been typed more often are better.
- if (a.url_info.typed_count() != b.url_info.typed_count())
- return a.url_info.typed_count() > b.url_info.typed_count();
-
- // For URLs that have each been typed once, a host (alone) is better than a
- // page inside.
- if (a.url_info.typed_count() == 1) {
- const bool a_is_host_only = history::IsHostOnly(a.url_info.url());
- if (a_is_host_only != history::IsHostOnly(b.url_info.url()))
- return a_is_host_only;
- }
-
- // URLs that have been visited more often are better.
- if (a.url_info.visit_count() != b.url_info.visit_count())
- return a.url_info.visit_count() > b.url_info.visit_count();
-
- // URLs that have been visited more recently are better.
- return a.url_info.last_visit() > b.url_info.last_visit();
-}
-
-// Given the user's |input| and a |match| created from it, reduce the
-// match's URL to just a host. If this host still matches the user input,
-// return it. Returns the empty string on failure.
-GURL ConvertToHostOnly(const HistoryMatch& match, const std::wstring& input) {
- // See if we should try to do host-only suggestions for this URL. Nonstandard
- // schemes means there's no authority section, so suggesting the host name
- // is useless. File URLs are standard, but host suggestion is not useful for
- // them either.
- const GURL& url = match.url_info.url();
- if (!url.is_valid() || !url.IsStandard() || url.SchemeIsFile())
- return GURL();
-
- // Transform to a host-only match. Bail if the host no longer matches the
- // user input (e.g. because the user typed more than just a host).
- GURL host = url.GetWithEmptyPath();
- if ((host.spec().length() < (match.input_location + input.length())))
- return GURL(); // User typing is longer than this host suggestion.
-
- const std::wstring spec = UTF8ToWide(host.spec());
- if (spec.compare(match.input_location, input.length(), input))
- return GURL(); // User typing is no longer a prefix.
-
- return host;
-}
-
-} // namespace history
HistoryURLProviderParams::HistoryURLProviderParams(
const AutocompleteInput& input,
@@ -223,25 +151,30 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
URLRowVector url_matches;
HistoryMatches history_matches;
- for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end();
- ++i) {
- if (params->cancel)
- return; // Canceled in the middle of a query, give up.
- // We only need kMaxMatches results in the end, but before we get there we
- // need to promote lower-quality matches that are prefixes of
- // higher-quality matches, and remove lower-quality redirects. So we ask
- // for more results than we need, of every prefix type, in hopes this will
- // give us far more than enough to work with. CullRedirects() will then
- // reduce the list to the best kMaxMatches results.
- db->AutocompleteForPrefix(WideToUTF16(i->prefix + params->input.text()),
- kMaxMatches * 2, &url_matches);
- for (URLRowVector::const_iterator j(url_matches.begin());
- j != url_matches.end(); ++j) {
- const Prefix* best_prefix = BestPrefix(j->url(), std::wstring());
- DCHECK(best_prefix != NULL);
- history_matches.push_back(HistoryMatch(*j, i->prefix.length(),
- !i->num_components,
- i->num_components >= best_prefix->num_components));
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableInMemoryURLIndex)) {
+ // TODO(rohitrao): Fetch results from the index.
+ } else {
+ for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end();
+ ++i) {
+ if (params->cancel)
+ return; // Canceled in the middle of a query, give up.
+ // We only need kMaxMatches results in the end, but before we get there we
+ // need to promote lower-quality matches that are prefixes of
+ // higher-quality matches, and remove lower-quality redirects. So we ask
+ // for more results than we need, of every prefix type, in hopes this will
+ // give us far more than enough to work with. CullRedirects() will then
+ // reduce the list to the best kMaxMatches results.
+ db->AutocompleteForPrefix(WideToUTF16(i->prefix + params->input.text()),
+ kMaxMatches * 2, &url_matches);
+ for (URLRowVector::const_iterator j(url_matches.begin());
+ j != url_matches.end(); ++j) {
+ const Prefix* best_prefix = BestPrefix(j->url(), std::wstring());
+ DCHECK(best_prefix != NULL);
+ history_matches.push_back(HistoryMatch(*j, i->prefix.length(),
+ !i->num_components,
+ i->num_components >= best_prefix->num_components));
+ }
}
}
@@ -427,7 +360,7 @@ bool HistoryURLProvider::PromoteMatchForInlineAutocomplete(
// hand, we wouldn't want to immediately start autocompleting it.
if (!match.url_info.typed_count() ||
((match.url_info.typed_count() == 1) &&
- !history::IsHostOnly(match.url_info.url())))
+ !IsHostOnly(match.url_info.url())))
return false;
params->matches.push_back(HistoryMatchToACMatch(params, match,
@@ -521,7 +454,47 @@ size_t HistoryURLProvider::TrimHttpPrefix(std::wstring* url) {
}
// static
-history::Prefixes HistoryURLProvider::GetPrefixes() {
+bool HistoryURLProvider::IsHostOnly(const GURL& url) {
+ DCHECK(url.is_valid());
+ return (!url.has_path() || (url.path() == "/")) && !url.has_query() &&
+ !url.has_ref();
+}
+
+// static
+bool HistoryURLProvider::CompareHistoryMatch(const HistoryMatch& a,
+ const HistoryMatch& b) {
+ // A URL that has been typed at all is better than one that has never been
+ // typed. (Note "!"s on each side)
+ if (!a.url_info.typed_count() != !b.url_info.typed_count())
+ return a.url_info.typed_count() > b.url_info.typed_count();
+
+ // Innermost matches (matches after any scheme or "www.") are better than
+ // non-innermost matches.
+ if (a.innermost_match != b.innermost_match)
+ return a.innermost_match;
+
+ // URLs that have been typed more often are better.
+ if (a.url_info.typed_count() != b.url_info.typed_count())
+ return a.url_info.typed_count() > b.url_info.typed_count();
+
+ // For URLs that have each been typed once, a host (alone) is better than a
+ // page inside.
+ if (a.url_info.typed_count() == 1) {
+ const bool a_is_host_only = IsHostOnly(a.url_info.url());
+ if (a_is_host_only != IsHostOnly(b.url_info.url()))
+ return a_is_host_only;
+ }
+
+ // URLs that have been visited more often are better.
+ if (a.url_info.visit_count() != b.url_info.visit_count())
+ return a.url_info.visit_count() > b.url_info.visit_count();
+
+ // URLs that have been visited more recently are better.
+ return a.url_info.last_visit() > b.url_info.last_visit();
+}
+
+// static
+HistoryURLProvider::Prefixes HistoryURLProvider::GetPrefixes() {
// We'll complete text following these prefixes.
// NOTE: There's no requirement that these be in any particular order.
Prefixes prefixes;
@@ -553,6 +526,30 @@ int HistoryURLProvider::CalculateRelevance(AutocompleteInput::Type input_type,
}
// static
+GURL HistoryURLProvider::ConvertToHostOnly(const HistoryMatch& match,
+ const std::wstring& input) {
+ // See if we should try to do host-only suggestions for this URL. Nonstandard
+ // schemes means there's no authority section, so suggesting the host name
+ // is useless. File URLs are standard, but host suggestion is not useful for
+ // them either.
+ const GURL& url = match.url_info.url();
+ if (!url.is_valid() || !url.IsStandard() || url.SchemeIsFile())
+ return GURL();
+
+ // Transform to a host-only match. Bail if the host no longer matches the
+ // user input (e.g. because the user typed more than just a host).
+ GURL host = url.GetWithEmptyPath();
+ if ((host.spec().length() < (match.input_location + input.length())))
+ return GURL(); // User typing is longer than this host suggestion.
+
+ const std::wstring spec = UTF8ToWide(host.spec());
+ if (spec.compare(match.input_location, input.length(), input))
+ return GURL(); // User typing is no longer a prefix.
+
+ return host;
+}
+
+// static
void HistoryURLProvider::PromoteOrCreateShorterSuggestion(
history::URLDatabase* db,
const HistoryURLProviderParams& params,
@@ -566,7 +563,7 @@ void HistoryURLProvider::PromoteOrCreateShorterSuggestion(
// itself be added as a match. We can add the base iff it's not "effectively
// the same" as any "what you typed" match.
const HistoryMatch& match = matches->front();
- GURL search_base = history::ConvertToHostOnly(match, params.input.text());
+ GURL search_base = ConvertToHostOnly(match, params.input.text());
bool can_add_search_base_to_matches = !have_what_you_typed_match;
if (search_base.is_empty()) {
// Search from what the user typed when we couldn't reduce the best match
@@ -576,14 +573,9 @@ void HistoryURLProvider::PromoteOrCreateShorterSuggestion(
// "http://google.com/", but |match| might begin with
// "http://www.google.com/".
// TODO: this should be cleaned up, and is probably incorrect for IDN.
- std::string new_match = match.url_info.url().possibly_invalid_spec();
- std::string::size_type substring_length = params.input.text().length();
- substring_length += match.input_location;
- new_match = new_match.substr(0, substring_length);
+ std::string new_match = match.url_info.url().possibly_invalid_spec().
+ substr(0, match.input_location + params.input.text().length());
search_base = GURL(new_match);
- // TODO(mrossetti): There is a degenerate case where the following may
- // cause a failure: http://www/~someword/fubar.html. Diagnose.
- // See: http://crbug.com/50101
if (search_base.is_empty())
return; // Can't construct a valid URL from which to start a search.
} else if (!can_add_search_base_to_matches) {
@@ -730,7 +722,7 @@ void HistoryURLProvider::RunAutocompletePasses(
}
}
-const history::Prefix* HistoryURLProvider::BestPrefix(
+const HistoryURLProvider::Prefix* HistoryURLProvider::BestPrefix(
const GURL& url,
const std::wstring& prefix_suffix) const {
const Prefix* best_prefix = NULL;
@@ -750,7 +742,7 @@ const history::Prefix* HistoryURLProvider::BestPrefix(
void HistoryURLProvider::SortMatches(HistoryMatches* matches) const {
// Sort by quality, best first.
- std::sort(matches->begin(), matches->end(), &history::CompareHistoryMatch);
+ std::sort(matches->begin(), matches->end(), &CompareHistoryMatch);
// Remove duplicate matches (caused by the search string appearing in one of
// the prefixes as well as after it). Consider the following scenario:
@@ -783,13 +775,15 @@ void HistoryURLProvider::SortMatches(HistoryMatches* matches) const {
}
void HistoryURLProvider::CullPoorMatches(HistoryMatches* matches) const {
- Time recent_threshold = history::AutocompleteAgeThreshold();
+ static const int kLowQualityMatchTypedLimit = 1;
+ static const int kLowQualityMatchVisitLimit = 3;
+ static const int kLowQualityMatchAgeLimitInDays = 3;
+ Time recent_threshold =
+ Time::Now() - TimeDelta::FromDays(kLowQualityMatchAgeLimitInDays);
for (HistoryMatches::iterator i(matches->begin()); i != matches->end();) {
- const history::URLRow& url_info(i->url_info);
- if ((url_info.typed_count() <=
- history::kLowQualityMatchTypedLimit) &&
- (url_info.visit_count() <=
- history::kLowQualityMatchVisitLimit) &&
+ const history::URLRow& url_info = i->url_info;
+ if ((url_info.typed_count() <= kLowQualityMatchTypedLimit) &&
+ (url_info.visit_count() <= kLowQualityMatchVisitLimit) &&
(url_info.last_visit() < recent_threshold)) {
i = matches->erase(i);
} else {
diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h
index bfd13b9..56633b4 100644
--- a/chrome/browser/autocomplete/history_url_provider.h
+++ b/chrome/browser/autocomplete/history_url_provider.h
@@ -17,9 +17,10 @@ class MessageLoop;
class Profile;
namespace history {
- class HistoryBackend;
+class HistoryBackend;
} // namespace history
+
// How history autocomplete works
// ==============================
//
@@ -179,6 +180,69 @@ class HistoryURLProvider : public AutocompleteProvider {
private:
~HistoryURLProvider() {}
+ struct Prefix {
+ Prefix(std::wstring prefix, int num_components)
+ : prefix(prefix),
+ num_components(num_components) { }
+
+ std::wstring prefix;
+
+ // The number of "components" in the prefix. The scheme is a component,
+ // and the initial "www." or "ftp." is a component. So "http://foo.com"
+ // and "www.bar.com" each have one component, "ftp://ftp.ftp.com" has two,
+ // and "mysite.com" has none. This is used to tell whether the user's
+ // input is an innermost match or not. See comments in HistoryMatch.
+ int num_components;
+ };
+ typedef std::vector<Prefix> Prefixes;
+
+ // Used for intermediate history result operations.
+ struct HistoryMatch {
+ // Required for STL, we don't use this directly.
+ HistoryMatch()
+ : url_info(),
+ input_location(std::wstring::npos),
+ match_in_scheme(false),
+ innermost_match(true) {
+ }
+
+ HistoryMatch(const history::URLRow& url_info,
+ size_t input_location,
+ bool match_in_scheme,
+ bool innermost_match)
+ : url_info(url_info),
+ input_location(input_location),
+ match_in_scheme(match_in_scheme),
+ innermost_match(innermost_match) {
+ }
+
+ bool operator==(const GURL& url) const {
+ return url_info.url() == url;
+ }
+
+ history::URLRow url_info;
+
+ // The offset of the user's input within the URL.
+ size_t input_location;
+
+ // Whether this is a match in the scheme. This determines whether we'll go
+ // ahead and show a scheme on the URL even if the user didn't type one.
+ // If our best match was in the scheme, not showing the scheme is both
+ // confusing and, for inline autocomplete of the fill_into_edit, dangerous.
+ // (If the user types "h" and we match "http://foo/", we need to inline
+ // autocomplete that, not "foo/", which won't show anything at all, and
+ // will mislead the user into thinking the What You Typed match is what's
+ // selected.)
+ bool match_in_scheme;
+
+ // A match after any scheme/"www.", if the user input could match at both
+ // locations. If the user types "w", an innermost match ("website.com") is
+ // better than a non-innermost match ("www.google.com"). If the user types
+ // "x", no scheme in our prefix list (or "www.") begins with x, so all
+ // matches are, vacuously, "innermost matches".
+ bool innermost_match;
+ };
+ typedef std::deque<HistoryMatch> HistoryMatches;
enum MatchType {
NORMAL,
@@ -204,8 +268,16 @@ class HistoryURLProvider : public AutocompleteProvider {
// return 0.
static size_t TrimHttpPrefix(std::wstring* url);
+ // Returns true if |url| is just a host (e.g. "http://www.google.com/") and
+ // not some other subpage (e.g. "http://www.google.com/foo.html").
+ static bool IsHostOnly(const GURL& url);
+
+ // Acts like the > operator for URLInfo classes.
+ static bool CompareHistoryMatch(const HistoryMatch& a,
+ const HistoryMatch& b);
+
// Returns the set of prefixes to use for prefixes_.
- static history::Prefixes GetPrefixes();
+ static Prefixes GetPrefixes();
// Determines the relevance for some input, given its type and which match it
// is. If |match_type| is NORMAL, |match_number| is a number
@@ -218,7 +290,7 @@ class HistoryURLProvider : public AutocompleteProvider {
// Given the user's |input| and a |match| created from it, reduce the
// match's URL to just a host. If this host still matches the user input,
// return it. Returns the empty string on failure.
- static GURL ConvertToHostOnly(const history::HistoryMatch& match,
+ static GURL ConvertToHostOnly(const HistoryMatch& match,
const std::wstring& input);
// See if a shorter version of the best match should be created, and if so
@@ -233,7 +305,7 @@ class HistoryURLProvider : public AutocompleteProvider {
const HistoryURLProviderParams& params,
bool have_what_you_typed_match,
const AutocompleteMatch& what_you_typed_match,
- history::HistoryMatches* matches);
+ HistoryMatches* matches);
// Ensures that |matches| contains an entry for |info|, which may mean adding
// a new such entry (using |input_location| and |match_in_scheme|).
@@ -245,7 +317,7 @@ class HistoryURLProvider : public AutocompleteProvider {
static void EnsureMatchPresent(const history::URLRow& info,
std::wstring::size_type input_location,
bool match_in_scheme,
- history::HistoryMatches* matches,
+ HistoryMatches* matches,
bool promote);
// Helper function that actually launches the two autocomplete passes.
@@ -258,8 +330,8 @@ class HistoryURLProvider : public AutocompleteProvider {
// |prefix_suffix| (which may be empty) is appended to every attempted
// prefix. This is useful when you need to figure out the innermost match
// for some user input in a URL.
- const history::Prefix* BestPrefix(const GURL& text,
- const std::wstring& prefix_suffix) const;
+ const Prefix* BestPrefix(const GURL& text,
+ const std::wstring& prefix_suffix) const;
// Returns a match corresponding to exactly what the user has typed.
AutocompleteMatch SuggestExactInput(const AutocompleteInput& input,
@@ -274,25 +346,25 @@ class HistoryURLProvider : public AutocompleteProvider {
bool FixupExactSuggestion(history::URLDatabase* db,
const AutocompleteInput& input,
AutocompleteMatch* match,
- history::HistoryMatches* matches) const;
+ HistoryMatches* matches) const;
// Determines if |match| is suitable for inline autocomplete, and promotes it
// if so.
bool PromoteMatchForInlineAutocomplete(HistoryURLProviderParams* params,
- const history::HistoryMatch& match);
+ const HistoryMatch& match);
// Sorts the given list of matches.
- void SortMatches(history::HistoryMatches* matches) const;
+ void SortMatches(HistoryMatches* matches) const;
// Removes results that have been rarely typed or visited, and not any time
// recently. The exact parameters for this heuristic can be found in the
// function body.
- void CullPoorMatches(history::HistoryMatches* matches) const;
+ void CullPoorMatches(HistoryMatches* matches) const;
// Removes results that redirect to each other, leaving at most |max_results|
// results.
void CullRedirects(history::HistoryBackend* backend,
- history::HistoryMatches* matches,
+ HistoryMatches* matches,
size_t max_results) const;
// Helper function for CullRedirects, this removes all but the first
@@ -304,19 +376,18 @@ class HistoryURLProvider : public AutocompleteProvider {
// is removed, the next item will be shifted, and this allows the caller to
// pick up on the next one when this happens.
size_t RemoveSubsequentMatchesOf(
- history::HistoryMatches* matches,
+ HistoryMatches* matches,
size_t source_index,
const std::vector<GURL>& remove) const;
// Converts a line from the database into an autocomplete match for display.
- AutocompleteMatch HistoryMatchToACMatch(
- HistoryURLProviderParams* params,
- const history::HistoryMatch& history_match,
- MatchType match_type,
- size_t match_number);
+ AutocompleteMatch HistoryMatchToACMatch(HistoryURLProviderParams* params,
+ const HistoryMatch& history_match,
+ MatchType match_type,
+ size_t match_number);
// Prefixes to try appending to user input when looking for a match.
- const history::Prefixes prefixes_;
+ const Prefixes prefixes_;
// Params for the current query. The provider should not free this directly;
// instead, it is passed as a parameter through the history backend, and the