summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 18:31:15 +0000
committerjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 18:31:15 +0000
commite1290ee6dbf99adb2d189a81ccaddf0441241d7b (patch)
treebe5baa8c247fa5936ddfc5c7fe19acb3d5e58132
parentc60d2def93b0a4f9bcc51317a9900c2d7e62ac0d (diff)
downloadchromium_src-e1290ee6dbf99adb2d189a81ccaddf0441241d7b.zip
chromium_src-e1290ee6dbf99adb2d189a81ccaddf0441241d7b.tar.gz
chromium_src-e1290ee6dbf99adb2d189a81ccaddf0441241d7b.tar.bz2
Remove Instant hooks from SearchProvider.
Old Instant is gone, and InstantExtended is not cramming its suggestion into autocomplete this way. BUG=251262 TEST=Unit test and manually. Review URL: https://chromiumcodereview.appspot.com/17391005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208741 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/search_provider.cc173
-rw-r--r--chrome/browser/autocomplete/search_provider.h42
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc190
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller.cc45
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller.h4
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc3
-rw-r--r--chrome/browser/ui/search/instant_controller.cc23
-rw-r--r--chrome/browser/ui/search/instant_controller.h4
8 files changed, 8 insertions, 476 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 8727247..eb4f27d 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include <cmath>
-#include "base/auto_reset.h"
#include "base/callback.h"
#include "base/i18n/break_iterator.h"
#include "base/i18n/case_conversion.h"
@@ -250,10 +249,8 @@ SearchProvider::SearchProvider(AutocompleteProviderListener* listener,
AutocompleteProvider::TYPE_SEARCH),
providers_(TemplateURLServiceFactory::GetForProfile(profile)),
suggest_results_pending_(0),
- instant_finalized_(false),
field_trial_triggered_(false),
field_trial_triggered_in_session_(false),
- suppress_search_suggestions_(false),
omnibox_start_margin_(-1) {
}
@@ -373,98 +370,10 @@ void SearchProvider::ResetSession() {
field_trial_triggered_in_session_ = false;
}
-void SearchProvider::FinalizeInstantQuery(const string16& input_text,
- const InstantSuggestion& suggestion) {
- if (done_ || instant_finalized_)
- return;
-
- instant_finalized_ = true;
- UpdateDone();
-
- if (input_text.empty()) {
- // We only need to update the listener if we're actually done.
- if (done_)
- listener_->OnProviderUpdate(false);
- return;
- }
-
- default_provider_suggestion_ = suggestion;
-
- string16 adjusted_input_text(input_text);
- AutocompleteInput::RemoveForcedQueryStringIfNecessary(input_.type(),
- &adjusted_input_text);
-
- const string16 text = adjusted_input_text + suggestion.text;
- bool results_updated = false;
- // Remove any matches that are identical to |text|. We don't use the
- // destination_url for comparison as it varies depending upon the index passed
- // to TemplateURL::ReplaceSearchTerms.
- for (ACMatches::iterator i = matches_.begin(); i != matches_.end();) {
- if (((i->type == AutocompleteMatchType::SEARCH_HISTORY) ||
- (i->type == AutocompleteMatchType::SEARCH_SUGGEST)) &&
- (i->fill_into_edit == text)) {
- i = matches_.erase(i);
- results_updated = true;
- } else {
- ++i;
- }
- }
-
- // Add the new Instant suggest result.
- if (suggestion.type == INSTANT_SUGGESTION_SEARCH) {
- // Instant has a query suggestion. Rank it higher than SEARCH_WHAT_YOU_TYPED
- // so that it gets autocompleted.
- bool relevance_from_server;
- const int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server);
- int did_not_accept_default_suggestion =
- default_results_.suggest_results.empty() ?
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
- TemplateURLRef::NO_SUGGESTION_CHOSEN;
- MatchMap match_map;
- AddMatchToMap(text, adjusted_input_text, verbatim_relevance + 1,
- relevance_from_server, AutocompleteMatchType::SEARCH_SUGGEST,
- did_not_accept_default_suggestion, false, &match_map);
- if (!match_map.empty()) {
- matches_.push_back(match_map.begin()->second);
- results_updated = true;
- }
- } else {
- // Instant has a URL suggestion. Rank it higher than other providers would
- // rank URL_WHAT_YOU_TYPED so it gets autocompleted; use
- // kNonURLVerbatimRelevance rather than |verbatim_relevance| so that the
- // score does not change if the user keeps typing and the input changes from
- // type UNKNOWN to URL.
- matches_.push_back(NavigationToMatch(NavigationResult(
- *this, GURL(UTF16ToUTF8(suggestion.text)), string16(), false,
- kNonURLVerbatimRelevance + 1, false)));
- results_updated = true;
- }
-
- if (results_updated || done_)
- listener_->OnProviderUpdate(results_updated);
-}
-
-void SearchProvider::ClearInstantSuggestion() {
- default_provider_suggestion_ = InstantSuggestion();
- if (done_ || instant_finalized_)
- return;
- instant_finalized_ = true;
- UpdateMatches();
- listener_->OnProviderUpdate(true);
-}
-
-void SearchProvider::SuppressSearchSuggestions() {
- suppress_search_suggestions_ = true;
-}
-
void SearchProvider::SetOmniboxStartMargin(int omnibox_start_margin) {
omnibox_start_margin_ = omnibox_start_margin;
}
-bool SearchProvider::IsNonInstantSearchDone() const {
- return !timer_.IsRunning() && (suggest_results_pending_ == 0);
-}
-
SearchProvider::~SearchProvider() {
}
@@ -542,9 +451,6 @@ int SearchProvider::CalculateRelevanceForKeywordVerbatim(
void SearchProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
- const bool suppress_search_suggestions = suppress_search_suggestions_;
- suppress_search_suggestions_ = false;
-
// Do our best to load the model as early as possible. This will reduce
// odds of having the model not ready when really needed (a non-empty input).
TemplateURLService* model = providers_.template_url_service();
@@ -554,9 +460,6 @@ void SearchProvider::Start(const AutocompleteInput& input,
matches_.clear();
field_trial_triggered_ = false;
- instant_finalized_ =
- (input.matches_requested() != AutocompleteInput::ALL_MATCHES);
-
// Can't return search/suggest results for bogus input or without a profile.
if (!profile_ || (input.type() == AutocompleteInput::INVALID)) {
Stop(false);
@@ -593,23 +496,9 @@ void SearchProvider::Start(const AutocompleteInput& input,
keyword_provider->keyword() : string16());
if (!minimal_changes ||
!providers_.equal(default_provider_keyword, keyword_provider_keyword)) {
- // If Instant has not come back with a suggestion, adjust the previous
- // suggestion if possible. If |instant_finalized| is true, we are looking
- // for synchronous matches only, so the suggestion is cleared.
- if (instant_finalized_)
- default_provider_suggestion_ = InstantSuggestion();
- else
- AdjustDefaultProviderSuggestion(input_.text(), input.text());
-
// Cancel any in-flight suggest requests.
- if (!done_) {
- // The Stop(false) call below clears |default_provider_suggestion_|, but
- // in this instance we do not want to clear cached results, so we
- // restore it.
- base::AutoReset<InstantSuggestion> reset(&default_provider_suggestion_,
- InstantSuggestion());
+ if (!done_)
Stop(false);
- }
}
providers_.set(default_provider_keyword, keyword_provider_keyword);
@@ -632,17 +521,14 @@ void SearchProvider::Start(const AutocompleteInput& input,
input_ = input;
- if (!suppress_search_suggestions) {
- DoHistoryQuery(minimal_changes);
- StartOrStopSuggestQuery(minimal_changes);
- }
+ DoHistoryQuery(minimal_changes);
+ StartOrStopSuggestQuery(minimal_changes);
UpdateMatches();
}
void SearchProvider::Stop(bool clear_cached_results) {
StopSuggest();
done_ = true;
- default_provider_suggestion_ = InstantSuggestion();
if (clear_cached_results)
ClearAllResults();
@@ -905,39 +791,6 @@ void SearchProvider::RemoveAllStaleResults() {
}
}
-void SearchProvider::AdjustDefaultProviderSuggestion(
- const string16& previous_input,
- const string16& current_input) {
- if (default_provider_suggestion_.type == INSTANT_SUGGESTION_URL) {
- // Description and relevance do not matter in the check for staleness.
- NavigationResult result(*this, GURL(default_provider_suggestion_.text),
- string16(), false, 100, false);
- // If navigation suggestion is stale, clear |default_provider_suggestion_|.
- if (!result.IsInlineable(current_input))
- default_provider_suggestion_ = InstantSuggestion();
- } else {
- DCHECK(default_provider_suggestion_.type == INSTANT_SUGGESTION_SEARCH);
- // InstantSuggestion of type SEARCH contain only the suggested text, and not
- // the full text of the query. This looks at the current and previous input
- // to determine if the user is typing forward, and if the new input is
- // contained in |default_provider_suggestion_|. If so, the suggestion is
- // adjusted and can be kept. Otherwise, it is reset.
- if (!previous_input.empty() &&
- StartsWith(current_input, previous_input, false)) {
- // User is typing forward; verify if new input is part of the suggestion.
- const string16 new_text = string16(current_input, previous_input.size());
- if (StartsWith(default_provider_suggestion_.text, new_text, false)) {
- // New input is a prefix to the previous suggestion, adjust the
- // suggestion to strip the prefix.
- default_provider_suggestion_.text.erase(0, new_text.size());
- return;
- }
- }
- // If we are here, the search suggestion is stale; reset it.
- default_provider_suggestion_ = InstantSuggestion();
- }
-}
-
void SearchProvider::ApplyCalculatedRelevance() {
ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results);
ApplyCalculatedSuggestRelevance(&default_results_.suggest_results);
@@ -1131,14 +984,6 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
}
}
}
- if (!default_provider_suggestion_.text.empty() &&
- default_provider_suggestion_.type == INSTANT_SUGGESTION_SEARCH &&
- !input_.prevent_inline_autocomplete())
- AddMatchToMap(input_.text() + default_provider_suggestion_.text,
- input_.text(), verbatim_relevance + 1, relevance_from_server,
- AutocompleteMatchType::SEARCH_SUGGEST,
- did_not_accept_default_suggestion, false, &map);
-
AddHistoryResultsToMap(keyword_history_results_, true,
did_not_accept_keyword_suggestion, &map);
AddHistoryResultsToMap(default_history_results_, false,
@@ -1151,15 +996,6 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i)
matches.push_back(i->second);
- if (!default_provider_suggestion_.text.empty() &&
- default_provider_suggestion_.type == INSTANT_SUGGESTION_URL &&
- !input_.prevent_inline_autocomplete()) {
- // See comment in FinalizeInstantQuery() for why we don't use
- // |verbatim_relevance| here.
- matches.push_back(NavigationToMatch(NavigationResult(
- *this, GURL(UTF16ToUTF8(default_provider_suggestion_.text)), string16(),
- false, kNonURLVerbatimRelevance + 1, false)));
- }
AddNavigationResultsToMatches(keyword_results_.navigation_results, &matches);
AddNavigationResultsToMatches(default_results_.navigation_results, &matches);
@@ -1673,6 +1509,5 @@ void SearchProvider::DemoteKeywordNavigationMatchesPastTopQuery() {
void SearchProvider::UpdateDone() {
// We're done when the timer isn't running, there are no suggest queries
// pending, and we're not waiting on Instant.
- done_ = IsNonInstantSearchDone() &&
- (instant_finalized_ || !chrome::IsInstantEnabled(profile_));
+ done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0);
}
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index 2bf17f5..03bf26c 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -25,7 +25,6 @@
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/common/instant_types.h"
#include "net/url_request/url_fetcher_delegate.h"
class Profile;
@@ -84,34 +83,9 @@ class SearchProvider : public AutocompleteProvider,
virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE;
virtual void ResetSession() OVERRIDE;
- // Marks the instant query as done. If |input_text| is non-empty this changes
- // the 'search what you typed' results text to |input_text| +
- // |suggestion.text|. |input_text| is the text the user input into the edit.
- // |input_text| differs from |input_.text()| if the input contained
- // whitespace.
- //
- // This method also marks the search provider as no longer needing to wait for
- // the instant result.
- void FinalizeInstantQuery(const string16& input_text,
- const InstantSuggestion& suggestion);
- void ClearInstantSuggestion();
-
- // If called, SearchProvider will not fetch any search suggestions for the
- // next call to Start(). Used with InstantExtended where Instant fetches its
- // own search suggestions.
- //
- // Note that this only applies to the next call to Start() and so this must be
- // called repeatedly before Start() if you wish to continually suppress search
- // suggestions.
- void SuppressSearchSuggestions();
-
// Update the omnibox start margin used to generate search suggestion URLs.
void SetOmniboxStartMargin(int omnibox_start_margin);
- // Returns whether the provider is done processing the query with the
- // exception of waiting for Instant to finish.
- bool IsNonInstantSearchDone() const;
-
bool field_trial_triggered_in_session() const {
return field_trial_triggered_in_session_;
}
@@ -370,12 +344,6 @@ class SearchProvider : public AutocompleteProvider,
// on RemoveStaleResults().
void RemoveAllStaleResults();
- // If |default_provider_suggestion_| (which was suggested for
- // |previous_input|) is still applicable given the |current_input|, adjusts it
- // so it can be reused. Otherwise, clears it.
- void AdjustDefaultProviderSuggestion(const string16& previous_input,
- const string16& current_input);
-
// Apply calculated relevance scores to the current results.
void ApplyCalculatedRelevance();
void ApplyCalculatedSuggestRelevance(SuggestResults* list);
@@ -533,12 +501,6 @@ class SearchProvider : public AutocompleteProvider,
Results default_results_;
Results keyword_results_;
- // Has FinalizeInstantQuery been invoked since the last |Start|?
- bool instant_finalized_;
-
- // The |suggestion| parameter passed to FinalizeInstantQuery.
- InstantSuggestion default_provider_suggestion_;
-
// Whether a field trial, if any, has triggered in the most recent
// autocomplete query. This field is set to false in Start() and may be set
// to true if either the default provider or keyword provider has completed
@@ -551,10 +513,6 @@ class SearchProvider : public AutocompleteProvider,
// session.
bool field_trial_triggered_in_session_;
- // If true, suppress search suggestions. Reset to false in Start().
- // See comments for SuppressSearchSuggestions().
- bool suppress_search_suggestions_;
-
// Start margin of the omnibox. Used to construct search URLs.
int omnibox_start_margin_;
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index c7d9e6c..aa8e4be 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/common/instant_types.h"
#include "chrome/common/metrics/entropy_provider.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -286,7 +285,6 @@ void SearchProviderTest::QueryForInputAndSetWYTMatch(
QueryForInput(text, false, false);
profile_.BlockUntilHistoryProcessesPendingRequests();
ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery());
- EXPECT_NE(chrome::IsInstantExtendedAPIEnabled(), provider_->done());
if (!wyt_match)
return;
ASSERT_GE(provider_->matches().size(), 1u);
@@ -510,190 +508,6 @@ TEST_F(SearchProviderTest, DontSendPrivateDataToSuggest) {
}
}
-// Make sure FinalizeInstantQuery works.
-TEST_F(SearchProviderTest, FinalizeInstantQuery) {
- chrome::EnableInstantExtendedAPIForTesting();
-
- ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("foo"),
- NULL));
-
- // Tell the provider Instant is done.
- provider_->FinalizeInstantQuery(ASCIIToUTF16("foo"),
- InstantSuggestion(ASCIIToUTF16("bar"),
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_SEARCH,
- string16(),
- kNoMatchIndex));
-
- // The provider should now be done.
- EXPECT_TRUE(provider_->done());
-
- // There should be two matches, one for what you typed, the other for
- // 'foobar'.
- EXPECT_EQ(2u, provider_->matches().size());
- GURL instant_url(default_t_url_->url_ref().ReplaceSearchTerms(
- TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("foobar"))));
- AutocompleteMatch instant_match;
- EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match));
-
- // And the 'foobar' match should not have a description, it'll be set later.
- EXPECT_TRUE(instant_match.description.empty());
-
- // Make sure the what you typed match has no description.
- AutocompleteMatch wyt_match;
- EXPECT_TRUE(FindMatchWithDestination(
- GURL(default_t_url_->url_ref().ReplaceSearchTerms(
- TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("foo")))),
- &wyt_match));
- EXPECT_TRUE(wyt_match.description.empty());
-
- // Instant search suggestions should be ranked above verbatim matches.
- EXPECT_GT(instant_match.relevance, wyt_match.relevance);
-}
-
-// Make sure FinalizeInstantQuery works with URL suggestions.
-TEST_F(SearchProviderTest, FinalizeInstantURL) {
- chrome::EnableInstantExtendedAPIForTesting();
-
- ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("ex"),
- NULL));
-
- // Tell the provider Instant is done.
- provider_->FinalizeInstantQuery(ASCIIToUTF16("ex"),
- InstantSuggestion(
- ASCIIToUTF16("http://example.com/"),
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_URL,
- string16(),
- kNoMatchIndex));
-
- // The provider should now be done.
- EXPECT_TRUE(provider_->done());
-
- // There should be two matches, one for what you typed, the other for
- // "http://example.com/".
- EXPECT_EQ(2u, provider_->matches().size());
- GURL instant_url("http://example.com");
- AutocompleteMatch instant_match;
- EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match));
-
- // The Instant match should not have a description, it'll be set later.
- EXPECT_TRUE(instant_match.description.empty());
-
- // Make sure the what you typed match has no description.
- AutocompleteMatch wyt_match;
- EXPECT_TRUE(FindMatchWithDestination(
- GURL(default_t_url_->url_ref().ReplaceSearchTerms(
- TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("ex")))),
- &wyt_match));
- EXPECT_TRUE(wyt_match.description.empty());
-
- // The Instant URL should be more relevant.
- EXPECT_GT(instant_match.relevance, wyt_match.relevance);
-}
-
-// An Instant URL suggestion should behave the same way whether the input text
-// is classified as UNKNOWN or as an URL. Otherwise if the user types
-// "example.co" url-what-you-typed will displace the Instant suggestion for
-// "example.com".
-TEST_F(SearchProviderTest, FinalizeInstantURLWithURLText) {
- chrome::EnableInstantExtendedAPIForTesting();
-
- ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(
- ASCIIToUTF16("example.co"), NULL));
-
- // Tell the provider Instant is done.
- provider_->FinalizeInstantQuery(ASCIIToUTF16("example.co"),
- InstantSuggestion(
- ASCIIToUTF16("http://example.com/"),
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_URL,
- string16(),
- kNoMatchIndex));
-
- // The provider should now be done.
- EXPECT_TRUE(provider_->done());
-
- // There should be two matches, one for what you typed, the other for
- // "http://example.com/".
- EXPECT_EQ(2u, provider_->matches().size());
- GURL instant_url("http://example.com");
- AutocompleteMatch instant_match;
- EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match));
-
- // The Instant match should not have a description, it'll be set later.
- EXPECT_TRUE(instant_match.description.empty());
-
- // The Instant URL should be more relevant than a URL_WHAT_YOU_TYPED match.
- EXPECT_GT(instant_match.relevance,
- HistoryURLProvider::kScoreForWhatYouTypedResult);
-}
-
-// Make sure that if FinalizeInstantQuery is invoked before suggest results
-// return, the suggest text from FinalizeInstantQuery is remembered.
-TEST_F(SearchProviderTest, RememberInstantQuery) {
- chrome::EnableInstantExtendedAPIForTesting();
-
- QueryForInput(ASCIIToUTF16("foo"), false, false);
-
- // Finalize the Instant query immediately.
- provider_->FinalizeInstantQuery(ASCIIToUTF16("foo"),
- InstantSuggestion(ASCIIToUTF16("bar"),
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_SEARCH,
- string16(),
- kNoMatchIndex));
-
- // There should be two matches, one for what you typed, the other for
- // 'foobar'.
- EXPECT_EQ(2u, provider_->matches().size());
- GURL instant_url(default_t_url_->url_ref().ReplaceSearchTerms(
- TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("foobar"))));
- AutocompleteMatch instant_match;
- EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match));
-
- // Wait until history and the suggest query complete.
- profile_.BlockUntilHistoryProcessesPendingRequests();
- ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery());
-
- // Provider should be done.
- EXPECT_TRUE(provider_->done());
-
- // There should be two matches, one for what you typed, the other for
- // 'foobar'.
- EXPECT_EQ(2u, provider_->matches().size());
- EXPECT_TRUE(FindMatchWithDestination(instant_url, &instant_match));
-
- // And the 'foobar' match should not have a description, it'll be set later.
- EXPECT_TRUE(instant_match.description.empty());
-}
-
-// Make sure that if trailing whitespace is added to the text supplied to
-// AutocompleteInput the default suggest text is cleared.
-TEST_F(SearchProviderTest, DifferingText) {
- chrome::EnableInstantExtendedAPIForTesting();
-
- ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("foo"),
- NULL));
-
- // Finalize the Instant query immediately.
- provider_->FinalizeInstantQuery(ASCIIToUTF16("foo"),
- InstantSuggestion(ASCIIToUTF16("bar"),
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_SEARCH,
- string16(),
- kNoMatchIndex));
-
- // Query with the same input text, but trailing whitespace.
- AutocompleteMatch instant_match;
- ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("foo "),
- &instant_match));
-
- // There should only one match, for what you typed.
- EXPECT_EQ(1u, provider_->matches().size());
- EXPECT_FALSE(instant_match.destination_url.is_empty());
-}
-
TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) {
AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, &AutocompleteClassifierFactory::BuildInstanceFor);
@@ -1658,8 +1472,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) {
TEST_F(SearchProviderTest, LocalAndRemoteRelevances) {
// Enable Instant Extended in order to allow an increased number of
- // suggestions. Unfortunately this requires us to call FinalizeInstantQuery()
- // every time.
+ // suggestions.
chrome::EnableInstantExtendedAPIForTesting();
// We hardcode the string "term1" below, so ensure that the search term that
@@ -1737,7 +1550,6 @@ TEST_F(SearchProviderTest, LocalAndRemoteRelevances) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
QueryForInput(cases[i].input, false, false);
- provider_->FinalizeInstantQuery(string16(), InstantSuggestion());
net::TestURLFetcher* fetcher = WaitUntilURLFetcherIsReady(
SearchProvider::kDefaultProviderURLFetcherID);
ASSERT_TRUE(fetcher);
diff --git a/chrome/browser/ui/omnibox/omnibox_controller.cc b/chrome/browser/ui/omnibox/omnibox_controller.cc
index fa57f8b..8255044 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller.cc
+++ b/chrome/browser/ui/omnibox/omnibox_controller.cc
@@ -69,17 +69,8 @@ void OmniboxController::StartAutocomplete(
#if defined(HTML_INSTANT_EXTENDED_POPUP)
InstantController* instant_controller = GetInstantController();
- if (instant_controller) {
+ if (instant_controller)
instant_controller->OnAutocompleteStart();
- // If the embedded page for InstantExtended is fetching its own suggestions,
- // suppress search suggestions from SearchProvider. We still need
- // SearchProvider to run for FinalizeInstantQuery.
- // TODO(dcblack): Once we are done refactoring the omnibox so we don't need
- // to use FinalizeInstantQuery anymore, we can take out this check and
- // remove this provider from kInstantExtendedOmniboxProviders.
- if (instant_controller->WillFetchCompletions())
- autocomplete_controller_->search_provider()->SuppressSearchSuggestions();
- }
#endif
if (chrome::IsInstantExtendedAPIEnabled()) {
autocomplete_controller_->search_provider()->
@@ -184,25 +175,6 @@ bool OmniboxController::DoInstant(const AutocompleteMatch& match,
#endif
}
-void OmniboxController::FinalizeInstantQuery(
- const string16& input_text,
- const InstantSuggestion& suggestion) {
-// Should only get called for the HTML popup.
-#if defined(HTML_INSTANT_EXTENDED_POPUP)
- if (!popup_model()->result().empty()) {
- // We need to finalize the instant query in all cases where the
- // |popup_model| holds some result. It is not enough to check whether the
- // popup is open, since when an IME is active the popup may be closed while
- // |popup_model| contains a non-empty result.
- SearchProvider* search_provider =
- autocomplete_controller_->search_provider();
- // There may be no providers during testing; guard against that.
- if (search_provider)
- search_provider->FinalizeInstantQuery(input_text, suggestion);
- }
-#endif
-}
-
void OmniboxController::SetInstantSuggestion(
const InstantSuggestion& suggestion) {
// Should only get called for the HTML popup.
@@ -210,12 +182,8 @@ void OmniboxController::SetInstantSuggestion(
switch (suggestion.behavior) {
case INSTANT_COMPLETE_NOW:
// Set blue suggestion text.
- // TODO(beaudoin): This currently goes to the SearchProvider. Instead we
- // should just create a valid current_match_ and call
- // omnibox_edit_model_->OnCurrentMatchChanged. This way we can get rid of
- // FinalizeInstantQuery entirely.
- if (!suggestion.text.empty())
- FinalizeInstantQuery(omnibox_edit_model_->GetViewText(), suggestion);
+ // TODO(beaudoin): Create a valid current_match_ and call
+ // omnibox_edit_model_->OnCurrentMatchChanged.
return;
case INSTANT_COMPLETE_NEVER: {
@@ -225,13 +193,6 @@ void OmniboxController::SetInstantSuggestion(
// Remove "?" if we're in forced query mode.
gray_suggestion_ = suggestion.text;
- // TODO(beaudoin): The following should no longer be needed once the
- // instant suggestion no longer goes through the search provider.
- SearchProvider* search_provider =
- autocomplete_controller_->search_provider();
- if (search_provider)
- search_provider->ClearInstantSuggestion();
-
omnibox_edit_model_->OnGrayTextChanged();
return;
}
diff --git a/chrome/browser/ui/omnibox/omnibox_controller.h b/chrome/browser/ui/omnibox/omnibox_controller.h
index f3ce3bb..f877d33 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller.h
+++ b/chrome/browser/ui/omnibox/omnibox_controller.h
@@ -67,10 +67,6 @@ class OmniboxController : public AutocompleteControllerDelegate {
bool just_deleted_text,
bool keyword_is_selected);
- // Calls through to SearchProvider::FinalizeInstantQuery.
- void FinalizeInstantQuery(const string16& input_text,
- const InstantSuggestion& suggestion);
-
// Sets the suggestion text.
void SetInstantSuggestion(const InstantSuggestion& suggestion);
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 131bcd8..6f7c1ae 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -304,9 +304,6 @@ void OmniboxEditModel::OnChanged() {
if (!performed_instant) {
// Hide any suggestions we might be showing.
view_->SetInstantSuggestion(string16());
-
- // No need to wait any longer for Instant.
- omnibox_controller_->FinalizeInstantQuery(string16(), InstantSuggestion());
}
switch (recommended_action) {
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index ad7e785..4620242 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -548,13 +548,6 @@ bool InstantController::Update(const AutocompleteMatch& match,
return true;
}
-bool InstantController::WillFetchCompletions() const {
- if (!extended_enabled())
- return false;
-
- return !UsingLocalPage();
-}
-
scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() {
if (!extended_enabled() || !browser_->profile() ||
browser_->profile()->IsOffTheRecord() ||
@@ -624,22 +617,6 @@ void InstantController::HandleAutocompleteResults(
if (omnibox_focus_state_ == OMNIBOX_FOCUS_NONE)
return;
- for (ACProviders::const_iterator provider = providers.begin();
- provider != providers.end(); ++provider) {
- const bool from_search_provider =
- (*provider)->type() == AutocompleteProvider::TYPE_SEARCH;
-
- // TODO(jeremycho): Pass search_provider() as a parameter to this function
- // and remove the static cast.
- const bool provider_done = from_search_provider ?
- static_cast<SearchProvider*>(*provider)->IsNonInstantSearchDone() :
- (*provider)->done();
- if (!provider_done) {
- DVLOG(1) << "Waiting for " << (*provider)->GetName();
- return;
- }
- }
-
DVLOG(1) << "AutocompleteResults:";
std::vector<InstantAutocompleteResult> results;
if (UsingLocalPage()) {
diff --git a/chrome/browser/ui/search/instant_controller.h b/chrome/browser/ui/search/instant_controller.h
index 716f37e..c9ead54 100644
--- a/chrome/browser/ui/search/instant_controller.h
+++ b/chrome/browser/ui/search/instant_controller.h
@@ -110,10 +110,6 @@ class InstantController : public InstantPage::Delegate,
bool escape_pressed,
bool is_keyword_search);
- // Returns whether the Instant page currently being used will fetch its own
- // completions. True for extended mode, unless using a local Instant page.
- bool WillFetchCompletions() const;
-
// Releases and returns the NTP WebContents. May be NULL. Loads a new
// WebContents for the NTP.
scoped_ptr<content::WebContents> ReleaseNTPContents() WARN_UNUSED_RESULT;