diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 19:41:22 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 19:41:22 +0000 |
commit | 9ca2d12e82907e3e902c3b51861bb7f0b3dc0116 (patch) | |
tree | d4e8564692fb6d59755a34beae493050e945f659 /chrome/browser/autocomplete | |
parent | c4c4704f83038b07dc024ea38be284edcd8f987e (diff) | |
download | chromium_src-9ca2d12e82907e3e902c3b51861bb7f0b3dc0116.zip chromium_src-9ca2d12e82907e3e902c3b51861bb7f0b3dc0116.tar.gz chromium_src-9ca2d12e82907e3e902c3b51861bb7f0b3dc0116.tar.bz2 |
Misc. small cleanups to minimize TemplateURL refactoring diffs:
Non-functional changes:
* 0 -> TemplateURLRef::NO_SUGGESTIONS_AVAILABLE
* GURL x = GURL(...) -> GURL x(...)
* Infobar -> InfoBar
* AllSources -> AllBrowserContextsAndSources
* Pass a Profile* to SearchProviderInstallData, which it will need for more purposes once UIThreadSearchTermsData takes a Profile*
* Add/modify comments
* "" -> std::string()
* Other trivial changes to minimize diffs
Functional changes:
* TemplateURLFetcher::RequestDelegate::AddSearchProvider() no longer clears the keyword for a newly-added, explicitly-requested TemplateURL that conflicts with a non-replaceable keyword. This means the conflicting keyword will appear in the dialog box and the box will indicate a conflict. This is mostly to avoid giving a TemplateURL an empty keyword, which will later be made illegal.
* TemplateURLFetcher::ScheduleDownload() now expects the provided keyword to be non-NULL for autodetected cases (which was always true already) and ignores the keyword for explicit cases (which only matters to tests, as the actual browser code always passed an empty keyword here anyway).
* TemplateURLService::CanReplaceKeyword() now always sets its outparam. This prevents any possible use-without-set on the caller side.
* Properly order (expected, actual)
* ASSERT -> EXPECT
* Construct the TemplateURL for TemplateURLTableModel::Add() in that function rather than the caller. This will make it easier to change TemplateURLs to require a Profile* later.
* Check all fields at the end of WebDatabaseMigrationTest.MigrateVersion27ToCurrent
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9811022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128270 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider_unittest.cc | 38 |
2 files changed, 25 insertions, 21 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 794c92b..c5c9ff9 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -557,7 +557,7 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match, GetInfoForCurrentText(¤t_match, NULL); const AutocompleteMatch& match = - index == AutocompletePopupModel::kNoMatch ? + (index == AutocompletePopupModel::kNoMatch) ? current_match : result().match_at(index); // Strip the keyword + leading space off the input. @@ -570,10 +570,8 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match, } content::RecordAction(UserMetricsAction("AcceptedKeyword")); - TemplateURLService* template_url_service = - TemplateURLServiceFactory::GetForProfile(profile_); - if (template_url_service) - template_url_service->IncrementUsageCount(template_url); + TemplateURLServiceFactory::GetForProfile(profile_)->IncrementUsageCount( + template_url); } else { DCHECK_EQ(content::PAGE_TRANSITION_GENERATED, match.transition); // NOTE: We purposefully don't increment the usage count of the default diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 0673b1e..0045d6d 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -200,8 +200,8 @@ void SearchProviderTest::QueryForInputAndSetWYTMatch( return; ASSERT_GE(provider_->matches().size(), 1u); EXPECT_TRUE(FindMatchWithDestination(GURL( - default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, text, 0, - string16())), wyt_match)); + default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, text, + TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), wyt_match)); } void SearchProviderTest::TearDown() { @@ -216,7 +216,8 @@ GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, int visit_count) { HistoryService* history = profile_.GetHistoryService(Profile::EXPLICIT_ACCESS); - GURL search(t_url->url()->ReplaceSearchTerms(*t_url, term, 0, string16())); + GURL search(t_url->url()->ReplaceSearchTerms(*t_url, term, + TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); static base::Time last_added_time; last_added_time = std::max(base::Time::Now(), last_added_time + base::TimeDelta::FromMicroseconds(1)); @@ -262,8 +263,9 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) { ASSERT_TRUE(fetcher); // And the URL matches what we expected. - GURL expected_url = GURL(default_t_url_->suggestions_url()-> - ReplaceSearchTerms(*default_t_url_, term, 0, string16())); + GURL expected_url(default_t_url_->suggestions_url()->ReplaceSearchTerms( + *default_t_url_, term, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + string16())); ASSERT_TRUE(fetcher->GetOriginalURL() == expected_url); // Tell the SearchProvider the suggest query is done. @@ -282,9 +284,9 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) { EXPECT_TRUE(term1_match.description.empty()); AutocompleteMatch wyt_match; - EXPECT_TRUE(FindMatchWithDestination(GURL( - default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, term, 0, - string16())), &wyt_match)); + EXPECT_TRUE(FindMatchWithDestination( + GURL(default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, term, + TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), &wyt_match)); EXPECT_TRUE(wyt_match.description.empty()); // The match for term1 should be more relevant than the what you typed result. @@ -322,8 +324,9 @@ TEST_F(SearchProviderTest, QueryKeywordProvider) { ASSERT_TRUE(keyword_fetcher); // And the URL matches what we expected. - GURL expected_url = GURL(keyword_t_url_->suggestions_url()-> - ReplaceSearchTerms(*keyword_t_url_, term, 0, string16())); + GURL expected_url(keyword_t_url_->suggestions_url()->ReplaceSearchTerms( + *keyword_t_url_, term, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + string16())); ASSERT_TRUE(keyword_fetcher->GetOriginalURL() == expected_url); // Tell the SearchProvider the keyword suggest query is done. @@ -391,8 +394,9 @@ TEST_F(SearchProviderTest, FinalizeInstantQuery) { // There should be two matches, one for what you typed, the other for // 'foobar'. EXPECT_EQ(2u, provider_->matches().size()); - GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms( - *default_t_url_, ASCIIToUTF16("foobar"), 0, string16())); + GURL instant_url(default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, + ASCIIToUTF16("foobar"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + string16())); AutocompleteMatch instant_match; EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match)); @@ -401,9 +405,10 @@ TEST_F(SearchProviderTest, FinalizeInstantQuery) { // Make sure the what you typed match has no description. AutocompleteMatch wyt_match; - EXPECT_TRUE(FindMatchWithDestination(GURL( - default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, - ASCIIToUTF16("foo"), 0, string16())), &wyt_match)); + EXPECT_TRUE(FindMatchWithDestination( + GURL(default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, + ASCIIToUTF16("foo"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + string16())), &wyt_match)); EXPECT_TRUE(wyt_match.description.empty()); // The instant search should be more relevant. @@ -425,7 +430,8 @@ TEST_F(SearchProviderTest, RememberInstantQuery) { // 'foobar'. EXPECT_EQ(2u, provider_->matches().size()); GURL instant_url(default_t_url_->url()->ReplaceSearchTerms(*default_t_url_, - ASCIIToUTF16("foobar"), 0, string16())); + ASCIIToUTF16("foobar"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + string16())); AutocompleteMatch instant_match; EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match)); |