summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Pearson <mpearson@chromium.org>2016-02-09 13:34:48 -0800
committerMark Pearson <mpearson@chromium.org>2016-02-09 21:36:40 +0000
commit3d40035c85583ee38860377c5984be9dd26cd8d3 (patch)
tree3407b6476d7d6fb49fc440bfe0c888ad14116622
parente3a796a42615edf1f62f6bc8987fba51a8778ed3 (diff)
downloadchromium_src-3d40035c85583ee38860377c5984be9dd26cd8d3.zip
chromium_src-3d40035c85583ee38860377c5984be9dd26cd8d3.tar.gz
chromium_src-3d40035c85583ee38860377c5984be9dd26cd8d3.tar.bz2
Revert "Omnibox - HistoryQuickProvider - Cull Search Redirects Earlier"
This was the cause of a significant ommnibox performance review. See bug for details. TBR=pkasting TBR=sky TBR=droger BUG=574181 Review URL: https://codereview.chromium.org/1602253002 Cr-Commit-Position: refs/heads/master@{#370181} (cherry picked from commit e29e658dd6d2ac8ffd326c939a6d7d907a37ff2a) Review URL: https://codereview.chromium.org/1684793002 . Cr-Commit-Position: refs/branch-heads/2623@{#339} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc43
-rw-r--r--chrome/browser/autocomplete/in_memory_url_index_factory.cc3
-rw-r--r--chrome/browser/autocomplete/in_memory_url_index_unittest.cc10
-rw-r--r--chrome/test/base/testing_profile.cc2
-rw-r--r--components/omnibox/browser/history_quick_provider.cc23
-rw-r--r--components/omnibox/browser/in_memory_url_index.cc5
-rw-r--r--components/omnibox/browser/in_memory_url_index.h6
-rw-r--r--components/omnibox/browser/scored_history_match.cc13
-rw-r--r--components/omnibox/browser/scored_history_match.h16
-rw-r--r--components/omnibox/browser/scored_history_match_unittest.cc127
-rw-r--r--components/omnibox/browser/url_index_private_data.cc13
-rw-r--r--components/omnibox/browser/url_index_private_data.h6
-rw-r--r--ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc3
13 files changed, 102 insertions, 168 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index 166813d..8054a2c 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -24,6 +24,8 @@
#include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history_service_factory.h"
+#include "chrome/browser/search_engines/chrome_template_url_service_client.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
@@ -39,6 +41,8 @@
#include "components/omnibox/browser/in_memory_url_index.h"
#include "components/omnibox/browser/url_index_private_data.h"
#include "components/search_engines/search_terms_data.h"
+#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_service.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_utils.h"
#include "sql/transaction.h"
@@ -201,6 +205,17 @@ class HistoryQuickProviderTest : public testing::Test {
std::set<std::string> matches_;
};
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
+ content::BrowserContext* context) {
+ Profile* profile = static_cast<Profile*>(context);
+ return make_scoped_ptr(new TemplateURLService(
+ profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL,
+ scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
+ HistoryServiceFactory::GetForProfile(
+ profile, ServiceAccessType::EXPLICIT_ACCESS))),
+ NULL, NULL, base::Closure()));
+ }
+
void SetUp() override;
void TearDown() override;
@@ -269,6 +284,8 @@ void HistoryQuickProviderTest::SetUp() {
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
EXPECT_TRUE(history_service_);
provider_ = new HistoryQuickProvider(client_.get());
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService);
FillData();
InMemoryURLIndex* index =
InMemoryURLIndexFactory::GetForProfile(profile_.get());
@@ -773,6 +790,32 @@ TEST_F(HistoryQuickProviderTest, PreventInlineAutocomplete) {
ASCIIToUTF16("popularsitewithroot.com"), base::string16());
}
+TEST_F(HistoryQuickProviderTest, CullSearchResults) {
+ // Set up a default search engine.
+ TemplateURLData data;
+ data.SetShortName(ASCIIToUTF16("TestEngine"));
+ data.SetKeyword(ASCIIToUTF16("TestEngine"));
+ data.SetURL("http://testsearch.com/?q={searchTerms}");
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_.get());
+ TemplateURL* template_url = new TemplateURL(data);
+ template_url_service->Add(template_url);
+ template_url_service->SetUserSelectedDefaultSearchProvider(template_url);
+ template_url_service->Load();
+
+ // A search results page should not be returned when typing a query.
+ std::vector<std::string> expected_urls;
+ RunTest(ASCIIToUTF16("thequery"), false, expected_urls, false,
+ ASCIIToUTF16("anotherengine.com/?q=thequery"), base::string16());
+
+ // A search results page should not be returned when typing the engine URL.
+ expected_urls.clear();
+ expected_urls.push_back("http://testsearch.com/");
+ RunTest(ASCIIToUTF16("testsearch"), false, expected_urls, true,
+ ASCIIToUTF16("testsearch.com"),
+ ASCIIToUTF16(".com"));
+}
+
TEST_F(HistoryQuickProviderTest, DoesNotProvideMatchesOnFocus) {
AutocompleteInput input(
ASCIIToUTF16("popularsite"), base::string16::npos, std::string(), GURL(),
diff --git a/chrome/browser/autocomplete/in_memory_url_index_factory.cc b/chrome/browser/autocomplete/in_memory_url_index_factory.cc
index efb3939..25d3a2a 100644
--- a/chrome/browser/autocomplete/in_memory_url_index_factory.cc
+++ b/chrome/browser/autocomplete/in_memory_url_index_factory.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/service_access_type.h"
@@ -35,7 +34,6 @@ InMemoryURLIndexFactory::InMemoryURLIndexFactory()
BrowserContextDependencyManager::GetInstance()) {
DependsOn(BookmarkModelFactory::GetInstance());
DependsOn(HistoryServiceFactory::GetInstance());
- DependsOn(TemplateURLServiceFactory::GetInstance());
}
InMemoryURLIndexFactory::~InMemoryURLIndexFactory() {
@@ -51,7 +49,6 @@ KeyedService* InMemoryURLIndexFactory::BuildServiceInstanceFor(
BookmarkModelFactory::GetForProfile(profile),
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::IMPLICIT_ACCESS),
- TemplateURLServiceFactory::GetForProfile(profile),
content::BrowserThread::GetBlockingPool(), profile->GetPath(),
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
chrome_schemes_to_whitelist);
diff --git a/chrome/browser/autocomplete/in_memory_url_index_unittest.cc b/chrome/browser/autocomplete/in_memory_url_index_unittest.cc
index b47939e..a40d78e 100644
--- a/chrome/browser/autocomplete/in_memory_url_index_unittest.cc
+++ b/chrome/browser/autocomplete/in_memory_url_index_unittest.cc
@@ -335,8 +335,7 @@ void InMemoryURLIndexTest::InitializeInMemoryURLIndex() {
SchemeSet client_schemes_to_whitelist;
client_schemes_to_whitelist.insert(kClientWhitelistedScheme);
url_index_.reset(new InMemoryURLIndex(
- nullptr, history_service_, nullptr,
- content::BrowserThread::GetBlockingPool(),
+ nullptr, history_service_, content::BrowserThread::GetBlockingPool(),
base::FilePath(), kTestLanguages, client_schemes_to_whitelist));
url_index_->Init();
url_index_->RebuildFromHistory(history_database_);
@@ -1250,8 +1249,7 @@ TEST_F(InMemoryURLIndexTest, AddHistoryMatch) {
String16Vector lower_terms;
StringToTerms(test_cases[i].search_string, test_cases[i].cursor_position,
&lower_string, &lower_terms);
- URLIndexPrivateData::AddHistoryMatch match(nullptr, nullptr,
- *GetPrivateData(),
+ URLIndexPrivateData::AddHistoryMatch match(nullptr, *GetPrivateData(),
kTestLanguages, lower_string,
lower_terms, base::Time::Now());
@@ -1287,8 +1285,8 @@ void InMemoryURLIndexCacheTest::SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
base::FilePath path(temp_dir_.path());
url_index_.reset(new InMemoryURLIndex(
- nullptr, nullptr, nullptr, content::BrowserThread::GetBlockingPool(),
- path, kTestLanguages, SchemeSet()));
+ nullptr, nullptr, content::BrowserThread::GetBlockingPool(), path,
+ kTestLanguages, SchemeSet()));
}
void InMemoryURLIndexCacheTest::TearDown() {
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 9717b02..010ca1a5 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -42,7 +42,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/storage_partition_descriptor.h"
#include "chrome/browser/search_engines/template_url_fetcher_factory.h"
-#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/browser/web_data_service_factory.h"
@@ -205,7 +204,6 @@ scoped_ptr<KeyedService> BuildInMemoryURLIndex(
BookmarkModelFactory::GetForProfile(profile),
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::IMPLICIT_ACCESS),
- TemplateURLServiceFactory::GetForProfile(profile),
content::BrowserThread::GetBlockingPool(), profile->GetPath(),
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
SchemeSet()));
diff --git a/components/omnibox/browser/history_quick_provider.cc b/components/omnibox/browser/history_quick_provider.cc
index 9a7774d..59998aa 100644
--- a/components/omnibox/browser/history_quick_provider.cc
+++ b/components/omnibox/browser/history_quick_provider.cc
@@ -27,6 +27,8 @@
#include "components/omnibox/browser/in_memory_url_index_types.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/url_prefix.h"
+#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_service.h"
#include "components/url_formatter/url_formatter.h"
#include "net/base/escape.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
@@ -169,6 +171,10 @@ void HistoryQuickProvider::DoAutocomplete() {
// they're visited.) The strength of this reduction depends on the
// likely score for the URL-what-you-typed result.
+ // |template_url_service| or |template_url| can be NULL in unit tests.
+ TemplateURLService* template_url_service = client()->GetTemplateURLService();
+ TemplateURL* template_url = template_url_service ?
+ template_url_service->GetDefaultSearchProvider() : NULL;
int max_match_score = matches.begin()->raw_score;
if (will_have_url_what_you_typed_match_first) {
max_match_score = std::min(max_match_score,
@@ -177,11 +183,18 @@ void HistoryQuickProvider::DoAutocomplete() {
for (ScoredHistoryMatches::const_iterator match_iter = matches.begin();
match_iter != matches.end(); ++match_iter) {
const ScoredHistoryMatch& history_match(*match_iter);
- // Set max_match_score to the score we'll assign this result.
- max_match_score = std::min(max_match_score, history_match.raw_score);
- matches_.push_back(QuickMatchToACMatch(history_match, max_match_score));
- // Mark this max_match_score as being used.
- max_match_score--;
+ // Culls results corresponding to queries from the default search engine.
+ // These are low-quality, difficult-to-understand matches for users, and the
+ // SearchProvider should surface past queries in a better way anyway.
+ if (!template_url ||
+ !template_url->IsSearchURL(history_match.url_info.url(),
+ template_url_service->search_terms_data())) {
+ // Set max_match_score to the score we'll assign this result:
+ max_match_score = std::min(max_match_score, history_match.raw_score);
+ matches_.push_back(QuickMatchToACMatch(history_match, max_match_score));
+ // Mark this max_match_score as being used:
+ max_match_score--;
+ }
}
}
diff --git a/components/omnibox/browser/in_memory_url_index.cc b/components/omnibox/browser/in_memory_url_index.cc
index c027301..9920013 100644
--- a/components/omnibox/browser/in_memory_url_index.cc
+++ b/components/omnibox/browser/in_memory_url_index.cc
@@ -78,14 +78,12 @@ InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::
InMemoryURLIndex::InMemoryURLIndex(
bookmarks::BookmarkModel* bookmark_model,
history::HistoryService* history_service,
- TemplateURLService* template_url_service,
base::SequencedWorkerPool* worker_pool,
const base::FilePath& history_dir,
const std::string& languages,
const SchemeSet& client_schemes_to_whitelist)
: bookmark_model_(bookmark_model),
history_service_(history_service),
- template_url_service_(template_url_service),
history_dir_(history_dir),
languages_(languages),
private_data_(new URLIndexPrivateData),
@@ -133,8 +131,7 @@ ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms(
size_t cursor_position,
size_t max_matches) {
return private_data_->HistoryItemsForTerms(
- term_string, cursor_position, max_matches, languages_, bookmark_model_,
- template_url_service_);
+ term_string, cursor_position, max_matches, languages_, bookmark_model_);
}
// Updating --------------------------------------------------------------------
diff --git a/components/omnibox/browser/in_memory_url_index.h b/components/omnibox/browser/in_memory_url_index.h
index 1f098cb..da8639c 100644
--- a/components/omnibox/browser/in_memory_url_index.h
+++ b/components/omnibox/browser/in_memory_url_index.h
@@ -27,7 +27,6 @@
#include "components/history/core/browser/history_types.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/omnibox/browser/scored_history_match.h"
-#include "components/search_engines/template_url_service.h"
class HistoryQuickProviderTest;
@@ -108,7 +107,6 @@ class InMemoryURLIndex : public KeyedService,
// characters.
InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
history::HistoryService* history_service,
- TemplateURLService* template_url_service,
base::SequencedWorkerPool* worker_pool,
const base::FilePath& history_dir,
const std::string& languages,
@@ -280,10 +278,6 @@ class InMemoryURLIndex : public KeyedService,
// The HistoryService; may be null when testing.
history::HistoryService* history_service_;
- // The TemplateURLService; may be null when testing. Used to identify URLs
- // that are from the default search provider.
- TemplateURLService* template_url_service_;
-
// Directory where cache file resides. This is, except when unit testing,
// the same directory in which the history database is found. It should never
// be empty.
diff --git a/components/omnibox/browser/scored_history_match.cc b/components/omnibox/browser/scored_history_match.cc
index cca9028..05c88dc 100644
--- a/components/omnibox/browser/scored_history_match.cc
+++ b/components/omnibox/browser/scored_history_match.cc
@@ -20,7 +20,6 @@
#include "components/omnibox/browser/history_url_provider.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/url_prefix.h"
-#include "components/search_engines/template_url_service.h"
namespace {
@@ -131,7 +130,6 @@ ScoredHistoryMatch::ScoredHistoryMatch()
WordStarts(),
RowWordStarts(),
false,
- nullptr,
base::Time::Max()) {
}
@@ -144,7 +142,6 @@ ScoredHistoryMatch::ScoredHistoryMatch(
const WordStarts& terms_to_word_starts_offsets,
const RowWordStarts& word_starts,
bool is_url_bookmarked,
- TemplateURLService* template_url_service,
base::Time now)
: HistoryMatch(row, 0, false, false), raw_score(0) {
// NOTE: Call Init() before doing any validity checking to ensure that the
@@ -157,16 +154,6 @@ ScoredHistoryMatch::ScoredHistoryMatch(
if (!gurl.is_valid())
return;
- // Skip results corresponding to queries from the default search engine.
- // These are low-quality, difficult-to-understand matches for users.
- // SearchProvider should surface past queries in a better way.
- TemplateURL* template_url = template_url_service ?
- template_url_service->GetDefaultSearchProvider() : nullptr;
- if (template_url &&
- template_url->IsSearchURL(gurl,
- template_url_service->search_terms_data()))
- return;
-
// Figure out where each search term appears in the URL and/or page title
// so that we can score as well as provide autocomplete highlighting.
base::OffsetAdjuster::Adjustments adjustments;
diff --git a/components/omnibox/browser/scored_history_match.h b/components/omnibox/browser/scored_history_match.h
index 0b2e1a0..dfc5ccb 100644
--- a/components/omnibox/browser/scored_history_match.h
+++ b/components/omnibox/browser/scored_history_match.h
@@ -18,7 +18,6 @@
#include "components/omnibox/browser/in_memory_url_index_types.h"
class ScoredHistoryMatchTest;
-class TemplateURLService;
// An HistoryMatch that has a score as well as metrics defining where in the
// history item's URL and/or page title matches have occurred.
@@ -35,14 +34,12 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
// Initializes the ScoredHistoryMatch with a raw score calculated for the
// history item given in |row| with recent visits as indicated in |visits|. It
// first determines if the row qualifies by seeing if all of the terms in
- // |terms_vector| occur in |row| and checking if the URL does not come from
- // the default search provider (obtained from |template_url_service|). If
- // both those constraints are true, calculates a raw score. This raw score
- // is in part determined by whether the matches occur at word boundaries, the
- // locations of which are stored in |word_starts|. For some terms, it's
- // appropriate to look for the word boundary within the term. For instance,
- // the term ".net" should look for a word boundary at the "n". These offsets
- // (".net" should have an offset of 1) come from
+ // |terms_vector| occur in |row|. If so, calculates a raw score. This raw
+ // score is in part determined by whether the matches occur at word
+ // boundaries, the locations of which are stored in |word_starts|. For some
+ // terms, it's appropriate to look for the word boundary within the term. For
+ // instance, the term ".net" should look for a word boundary at the "n". These
+ // offsets (".net" should have an offset of 1) come from
// |terms_to_word_starts_offsets|. |is_url_bookmarked| indicates whether the
// match's URL is referenced by any bookmarks, which can also affect the raw
// score. The raw score allows the matches to be ordered and can be used to
@@ -57,7 +54,6 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
const WordStarts& terms_to_word_starts_offsets,
const RowWordStarts& word_starts,
bool is_url_bookmarked,
- TemplateURLService* template_url_service,
base::Time now);
~ScoredHistoryMatch();
diff --git a/components/omnibox/browser/scored_history_match_unittest.cc b/components/omnibox/browser/scored_history_match_unittest.cc
index ecab0a3..9f78bc8f 100644
--- a/components/omnibox/browser/scored_history_match_unittest.cc
+++ b/components/omnibox/browser/scored_history_match_unittest.cc
@@ -11,10 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/search_engines/search_terms_data.h"
-#include "components/search_engines/template_url.h"
-#include "components/search_engines/template_url_service.h"
-#include "components/search_engines/template_url_service_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -137,8 +133,7 @@ TEST_F(ScoredHistoryMatchTest, Scoring) {
visits_a[0].second = ui::PAGE_TRANSITION_TYPED;
ScoredHistoryMatch scored_a(row_a, visits_a, std::string(),
ASCIIToUTF16("abc"), Make1Term("abc"),
- one_word_no_offset, word_starts_a, false, nullptr,
- now);
+ one_word_no_offset, word_starts_a, false, now);
// Test scores based on visit_count.
history::URLRow row_b(MakeURLRow("http://abcdef", "abcd bcd", 10, 30, 1));
@@ -148,8 +143,7 @@ TEST_F(ScoredHistoryMatchTest, Scoring) {
visits_b[0].second = ui::PAGE_TRANSITION_TYPED;
ScoredHistoryMatch scored_b(row_b, visits_b, std::string(),
ASCIIToUTF16("abc"), Make1Term("abc"),
- one_word_no_offset, word_starts_b, false, nullptr,
- now);
+ one_word_no_offset, word_starts_b, false, now);
EXPECT_GT(scored_b.raw_score, scored_a.raw_score);
// Test scores based on last_visit.
@@ -160,8 +154,7 @@ TEST_F(ScoredHistoryMatchTest, Scoring) {
visits_c[0].second = ui::PAGE_TRANSITION_TYPED;
ScoredHistoryMatch scored_c(row_c, visits_c, std::string(),
ASCIIToUTF16("abc"), Make1Term("abc"),
- one_word_no_offset, word_starts_c, false, nullptr,
- now);
+ one_word_no_offset, word_starts_c, false, now);
EXPECT_GT(scored_c.raw_score, scored_a.raw_score);
// Test scores based on typed_count.
@@ -174,8 +167,7 @@ TEST_F(ScoredHistoryMatchTest, Scoring) {
visits_d[2].second = ui::PAGE_TRANSITION_TYPED;
ScoredHistoryMatch scored_d(row_d, visits_d, std::string(),
ASCIIToUTF16("abc"), Make1Term("abc"),
- one_word_no_offset, word_starts_d, false, nullptr,
- now);
+ one_word_no_offset, word_starts_d, false, now);
EXPECT_GT(scored_d.raw_score, scored_a.raw_score);
// Test scores based on a terms appearing multiple times.
@@ -187,16 +179,14 @@ TEST_F(ScoredHistoryMatchTest, Scoring) {
const VisitInfoVector visits_e = visits_d;
ScoredHistoryMatch scored_e(row_e, visits_e, std::string(),
ASCIIToUTF16("csi"), Make1Term("csi"),
- one_word_no_offset, word_starts_e, false, nullptr,
- now);
+ one_word_no_offset, word_starts_e, false, now);
EXPECT_LT(scored_e.raw_score, 1400);
// Test that a result with only a mid-term match (i.e., not at a word
// boundary) scores 0.
ScoredHistoryMatch scored_f(row_a, visits_a, std::string(),
ASCIIToUTF16("cd"), Make1Term("cd"),
- one_word_no_offset, word_starts_a, false, nullptr,
- now);
+ one_word_no_offset, word_starts_a, false, now);
EXPECT_EQ(scored_f.raw_score, 0);
}
@@ -214,12 +204,12 @@ TEST_F(ScoredHistoryMatchTest, ScoringBookmarks) {
VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
ScoredHistoryMatch scored(row, visits, std::string(), ASCIIToUTF16("abc"),
Make1Term("abc"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
// Now check that if URL is bookmarked then its score increases.
base::AutoReset<int> reset(&ScoredHistoryMatch::bookmark_value_, 5);
ScoredHistoryMatch scored_with_bookmark(
row, visits, std::string(), ASCIIToUTF16("abc"), Make1Term("abc"),
- one_word_no_offset, word_starts, true, nullptr, now);
+ one_word_no_offset, word_starts, true, now);
EXPECT_GT(scored_with_bookmark.raw_score, scored.raw_score);
}
@@ -238,15 +228,14 @@ TEST_F(ScoredHistoryMatchTest, ScoringTLD) {
VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
ScoredHistoryMatch scored(row, visits, std::string(), ASCIIToUTF16("fed com"),
Make2Terms("fed", "com"), two_words_no_offsets,
- word_starts, false, nullptr, now);
+ word_starts, false, now);
EXPECT_EQ(0, scored.raw_score);
// Now allow credit for the match in the TLD.
base::AutoReset<bool> reset(&ScoredHistoryMatch::allow_tld_matches_, true);
ScoredHistoryMatch scored_with_tld(
row, visits, std::string(), ASCIIToUTF16("fed com"),
- Make2Terms("fed", "com"), two_words_no_offsets, word_starts, false,
- nullptr, now);
+ Make2Terms("fed", "com"), two_words_no_offsets, word_starts, false, now);
EXPECT_GT(scored_with_tld.raw_score, 0);
}
@@ -265,83 +254,17 @@ TEST_F(ScoredHistoryMatchTest, ScoringScheme) {
VisitInfoVector visits = CreateVisitInfoVector(8, 3, now);
ScoredHistoryMatch scored(row, visits, std::string(),
ASCIIToUTF16("fed http"), Make2Terms("fed", "http"),
- two_words_no_offsets, word_starts, false, nullptr,
- now);
+ two_words_no_offsets, word_starts, false, now);
EXPECT_EQ(0, scored.raw_score);
// Now allow credit for the match in the scheme.
base::AutoReset<bool> reset(&ScoredHistoryMatch::allow_scheme_matches_, true);
ScoredHistoryMatch scored_with_scheme(
row, visits, std::string(), ASCIIToUTF16("fed http"),
- Make2Terms("fed", "http"), two_words_no_offsets, word_starts, false,
- nullptr, now);
+ Make2Terms("fed", "http"), two_words_no_offsets, word_starts, false, now);
EXPECT_GT(scored_with_scheme.raw_score, 0);
}
-TEST_F(ScoredHistoryMatchTest, CullSearchResults) {
- scoped_ptr<TemplateURLService> template_url_service =
- make_scoped_ptr(new TemplateURLService(
- nullptr, make_scoped_ptr(new SearchTermsData), nullptr,
- scoped_ptr<TemplateURLServiceClient>(), nullptr, nullptr,
- base::Closure()));
-
- // We use NowFromSystemTime() because MakeURLRow uses the same function
- // to calculate last visit time when building a row.
- base::Time now = base::Time::NowFromSystemTime();
-
- // Pretend we've visited a search engine query URL, but that it's not
- // associated with the default search engine.
- history::URLRow row(MakeURLRow(
- "http://testsearch.com/thequery", "Test Search Engine", 3, 30, 1));
- RowWordStarts word_starts;
- PopulateWordStarts(row, &word_starts);
- WordStarts one_word_no_offset(1, 0u);
- VisitInfoVector visits = CreateVisitInfoVector(3, 30, now);
- // Mark one visit as typed.
- visits[0].second = ui::PAGE_TRANSITION_TYPED;
-
- // This page should be returned if it's associated with the default search
- // engine.
- ScoredHistoryMatch scored_a(row, visits, std::string(),
- ASCIIToUTF16("thequery"), Make1Term("thequery"),
- one_word_no_offset, word_starts, false,
- template_url_service.get(), now);
- EXPECT_GT(scored_a.raw_score, 0);
-
- // Likewise, it should be returned when typing the engine URL.
- ScoredHistoryMatch scored_b(row, visits, std::string(),
- ASCIIToUTF16("testsearch"),
- Make1Term("testsearch"), one_word_no_offset,
- word_starts, false, template_url_service.get(),
- now);
- EXPECT_GT(scored_b.raw_score, 0);
-
- // Set up a default search engine associated with this URL.
- TemplateURLData data;
- data.SetShortName(ASCIIToUTF16("TestEngine"));
- data.SetKeyword(ASCIIToUTF16("TestEngine"));
- data.SetURL("http://testsearch.com/{searchTerms}");
- TemplateURL* template_url = new TemplateURL(data);
- template_url_service->Add(template_url);
- template_url_service->SetUserSelectedDefaultSearchProvider(template_url);
- template_url_service->Load();
-
- // The search results page should not be returned when typing a query.
- ScoredHistoryMatch scored_c(row, visits, std::string(),
- ASCIIToUTF16("thequery"), Make1Term("thequery"),
- one_word_no_offset, word_starts, false,
- template_url_service.get(), now);
- EXPECT_EQ(0, scored_c.raw_score);
-
- // Likewise, it shouldn't be returned when typing the engine URL.
- ScoredHistoryMatch scored_d(row, visits, std::string(),
- ASCIIToUTF16("testsearch"),
- Make1Term("testsearch"), one_word_no_offset,
- word_starts, false, template_url_service.get(),
- now);
- EXPECT_EQ(0, scored_d.raw_score);
-}
-
TEST_F(ScoredHistoryMatchTest, Inlining) {
// We use NowFromSystemTime() because MakeURLRow uses the same function
// to calculate last visit time when building a row.
@@ -356,19 +279,19 @@ TEST_F(ScoredHistoryMatchTest, Inlining) {
PopulateWordStarts(row, &word_starts);
ScoredHistoryMatch scored_a(row, visits, std::string(), ASCIIToUTF16("g"),
Make1Term("g"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_a.match_in_scheme);
ScoredHistoryMatch scored_b(row, visits, std::string(), ASCIIToUTF16("w"),
Make1Term("w"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_b.match_in_scheme);
ScoredHistoryMatch scored_c(row, visits, std::string(), ASCIIToUTF16("h"),
Make1Term("h"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_TRUE(scored_c.match_in_scheme);
ScoredHistoryMatch scored_d(row, visits, std::string(), ASCIIToUTF16("o"),
Make1Term("o"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_d.match_in_scheme);
}
@@ -377,15 +300,15 @@ TEST_F(ScoredHistoryMatchTest, Inlining) {
PopulateWordStarts(row, &word_starts);
ScoredHistoryMatch scored_a(row, visits, std::string(), ASCIIToUTF16("t"),
Make1Term("t"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_a.match_in_scheme);
ScoredHistoryMatch scored_b(row, visits, std::string(), ASCIIToUTF16("f"),
Make1Term("f"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_b.match_in_scheme);
ScoredHistoryMatch scored_c(row, visits, std::string(), ASCIIToUTF16("o"),
Make1Term("o"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_c.match_in_scheme);
}
@@ -395,15 +318,15 @@ TEST_F(ScoredHistoryMatchTest, Inlining) {
PopulateWordStarts(row, &word_starts);
ScoredHistoryMatch scored_a(row, visits, std::string(), ASCIIToUTF16("t"),
Make1Term("t"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_a.match_in_scheme);
ScoredHistoryMatch scored_b(row, visits, std::string(), ASCIIToUTF16("h"),
Make1Term("h"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_TRUE(scored_b.match_in_scheme);
ScoredHistoryMatch scored_c(row, visits, std::string(), ASCIIToUTF16("w"),
Make1Term("w"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_c.match_in_scheme);
}
@@ -413,15 +336,15 @@ TEST_F(ScoredHistoryMatchTest, Inlining) {
PopulateWordStarts(row, &word_starts);
ScoredHistoryMatch scored_a(row, visits, "zh-CN", ASCIIToUTF16("x"),
Make1Term("x"), one_word_no_offset, word_starts,
- false, nullptr, now);
+ false, now);
EXPECT_FALSE(scored_a.match_in_scheme);
ScoredHistoryMatch scored_b(row, visits, "zh-CN", ASCIIToUTF16("xn"),
Make1Term("xn"), one_word_no_offset,
- word_starts, false, nullptr, now);
+ word_starts, false, now);
EXPECT_FALSE(scored_b.match_in_scheme);
ScoredHistoryMatch scored_c(row, visits, "zh-CN", ASCIIToUTF16("w"),
Make1Term("w"), one_word_no_offset,
- word_starts, false, nullptr, now);
+ word_starts, false, now);
EXPECT_FALSE(scored_c.match_in_scheme);
}
}
diff --git a/components/omnibox/browser/url_index_private_data.cc b/components/omnibox/browser/url_index_private_data.cc
index 0409ea6..4657273 100644
--- a/components/omnibox/browser/url_index_private_data.cc
+++ b/components/omnibox/browser/url_index_private_data.cc
@@ -28,7 +28,6 @@
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_service.h"
#include "components/omnibox/browser/in_memory_url_index.h"
-#include "components/search_engines/template_url_service.h"
#include "components/url_formatter/url_formatter.h"
#if defined(USE_SYSTEM_PROTOBUF)
@@ -157,8 +156,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
size_t cursor_position,
size_t max_matches,
const std::string& languages,
- bookmarks::BookmarkModel* bookmark_model,
- TemplateURLService* template_url_service) {
+ bookmarks::BookmarkModel* bookmark_model) {
// If cursor position is set and useful (not at either end of the
// string), allow the search string to be broken at cursor position.
// We do this by pretending there's a space where the cursor is.
@@ -253,9 +251,8 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
scored_items =
std::for_each(
history_id_set.begin(), history_id_set.end(),
- AddHistoryMatch(bookmark_model, template_url_service, *this,
- languages, lower_raw_string, lower_raw_terms,
- base::Time::Now())).ScoredMatches();
+ AddHistoryMatch(bookmark_model, *this, languages, lower_raw_string,
+ lower_raw_terms, base::Time::Now())).ScoredMatches();
// Select and sort only the top |max_matches| results.
if (scored_items.size() > max_matches) {
@@ -1277,14 +1274,12 @@ URLIndexPrivateData::SearchTermCacheItem::~SearchTermCacheItem() {
URLIndexPrivateData::AddHistoryMatch::AddHistoryMatch(
bookmarks::BookmarkModel* bookmark_model,
- TemplateURLService* template_url_service,
const URLIndexPrivateData& private_data,
const std::string& languages,
const base::string16& lower_string,
const String16Vector& lower_terms,
const base::Time now)
: bookmark_model_(bookmark_model),
- template_url_service_(template_url_service),
private_data_(private_data),
languages_(languages),
lower_string_(lower_string),
@@ -1326,7 +1321,7 @@ void URLIndexPrivateData::AddHistoryMatch::operator()(
hist_item, visits, languages_, lower_string_, lower_terms_,
lower_terms_to_word_starts_offsets_, starts_pos->second,
bookmark_model_ && bookmark_model_->IsBookmarked(hist_item.url()),
- template_url_service_, now_);
+ now_);
if (match.raw_score > 0)
scored_matches_.push_back(match);
}
diff --git a/components/omnibox/browser/url_index_private_data.h b/components/omnibox/browser/url_index_private_data.h
index 9253ee1..90ab171 100644
--- a/components/omnibox/browser/url_index_private_data.h
+++ b/components/omnibox/browser/url_index_private_data.h
@@ -19,7 +19,6 @@
#include "components/omnibox/browser/scored_history_match.h"
class HistoryQuickProviderTest;
-class TemplateURLService;
namespace bookmarks {
class BookmarkModel;
@@ -74,8 +73,7 @@ class URLIndexPrivateData
size_t cursor_position,
size_t max_matches,
const std::string& languages,
- bookmarks::BookmarkModel* bookmark_model,
- TemplateURLService* template_url_service);
+ bookmarks::BookmarkModel* bookmark_model);
// Adds the history item in |row| to the index if it does not already already
// exist and it meets the minimum 'quick' criteria. If the row already exists
@@ -200,7 +198,6 @@ class URLIndexPrivateData
class AddHistoryMatch : public std::unary_function<HistoryID, void> {
public:
AddHistoryMatch(bookmarks::BookmarkModel* bookmark_model,
- TemplateURLService* template_url_service,
const URLIndexPrivateData& private_data,
const std::string& languages,
const base::string16& lower_string,
@@ -216,7 +213,6 @@ class URLIndexPrivateData
friend class InMemoryURLIndexTest;
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, AddHistoryMatch);
bookmarks::BookmarkModel* bookmark_model_;
- TemplateURLService* template_url_service_;
const URLIndexPrivateData& private_data_;
const std::string& languages_;
ScoredHistoryMatches scored_matches_;
diff --git a/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc b/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
index 4ee7417..b9cf90d 100644
--- a/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
+++ b/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
@@ -16,7 +16,6 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/history/history_service_factory.h"
#include "ios/chrome/browser/pref_names.h"
-#include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/web/public/web_thread.h"
@@ -36,7 +35,6 @@ scoped_ptr<KeyedService> BuildInMemoryURLIndex(web::BrowserState* context) {
ios::BookmarkModelFactory::GetForBrowserState(browser_state),
ios::HistoryServiceFactory::GetForBrowserState(
browser_state, ServiceAccessType::IMPLICIT_ACCESS),
- ios::TemplateURLServiceFactory::GetForBrowserState(browser_state),
web::WebThread::GetBlockingPool(), browser_state->GetStatePath(),
browser_state->GetPrefs()->GetString(prefs::kAcceptLanguages),
schemes_to_whilelist));
@@ -64,7 +62,6 @@ InMemoryURLIndexFactory::InMemoryURLIndexFactory()
BrowserStateDependencyManager::GetInstance()) {
DependsOn(ios::BookmarkModelFactory::GetInstance());
DependsOn(ios::HistoryServiceFactory::GetInstance());
- DependsOn(ios::TemplateURLServiceFactory::GetInstance());
}
InMemoryURLIndexFactory::~InMemoryURLIndexFactory() {}