| Index: chrome/browser/autocomplete/zero_suggest_provider.h
|
| diff --git a/chrome/browser/autocomplete/zero_suggest_provider.h b/chrome/browser/autocomplete/zero_suggest_provider.h
|
| index 41d6b04cc9d1aed44240e7f0910128931e1dfc4d..ecf884f3818018ec8227b2ea34c60aa2784a7439 100644
|
| --- a/chrome/browser/autocomplete/zero_suggest_provider.h
|
| +++ b/chrome/browser/autocomplete/zero_suggest_provider.h
|
| @@ -18,13 +18,11 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| -#include "base/basictypes.h"
|
| -#include "base/compiler_specific.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "base/strings/string16.h"
|
| -#include "chrome/browser/autocomplete/autocomplete_provider.h"
|
| -#include "chrome/browser/autocomplete/search_provider.h"
|
| -#include "net/url_request/url_fetcher_delegate.h"
|
| +#include "chrome/browser/autocomplete/autocomplete_input.h"
|
| +#include "chrome/browser/autocomplete/base_search_provider.h"
|
| +#include "chrome/browser/history/history_types.h"
|
|
|
| class AutocompleteInput;
|
| class GURL;
|
| @@ -49,27 +47,17 @@ class URLFetcher;
|
| // TODO(jered): Consider deleting this class and building this functionality
|
| // into SearchProvider after dogfood and after we break the association between
|
| // omnibox text and suggestions.
|
| -class ZeroSuggestProvider : public AutocompleteProvider,
|
| - public net::URLFetcherDelegate {
|
| +class ZeroSuggestProvider : public BaseSearchProvider {
|
| public:
|
| // Creates and returns an instance of this provider.
|
| static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener,
|
| Profile* profile);
|
|
|
| // AutocompleteProvider:
|
| - virtual void Start(const AutocompleteInput& input,
|
| - bool /*minimal_changes*/) OVERRIDE;
|
| - virtual void Stop(bool clear_cached_results) OVERRIDE;
|
| -
|
| - // Adds provider-specific information to omnibox event logs.
|
| - virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE;
|
|
|
| // Sets |field_trial_triggered_| to false.
|
| virtual void ResetSession() OVERRIDE;
|
|
|
| - // net::URLFetcherDelegate
|
| - virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
|
| -
|
| // Initiates a new fetch for the given |url| of classification
|
| // |page_classification|. |permanent_text| is the omnibox text
|
| // for the current page.
|
| @@ -83,54 +71,48 @@ class ZeroSuggestProvider : public AutocompleteProvider,
|
| }
|
|
|
| private:
|
| + // BaseSearchProvider:
|
| + // Stops the suggest query.
|
| + // NOTE: This does not update |done_|. Callers must do so.
|
| + virtual void StopSuggest() OVERRIDE;
|
| +
|
| + // Clears the current results.
|
| + virtual void ClearAllResults() OVERRIDE;
|
| +
|
| + virtual void LogFetchComplete(const net::URLFetcher* source) OVERRIDE;
|
| +
|
| + virtual bool ShouldSendProviderUpdate(bool results_updated) OVERRIDE;
|
| +
|
| + virtual bool IsValidQuery(const base::string16 query,
|
| + const net::URLFetcher* source) OVERRIDE;
|
| + virtual const base::string16 GetInputText(const net::URLFetcher* source)
|
| + OVERRIDE;
|
| + virtual int GetDefaultRelevance() OVERRIDE;
|
| +
|
| + virtual void UpdateMatches() OVERRIDE;
|
| +
|
| + virtual Results* GetResultsObjectToFill(const net::URLFetcher* source)
|
| + OVERRIDE;
|
| +
|
| + virtual void RecordDeletionResult(bool success) OVERRIDE;
|
| +
|
| ZeroSuggestProvider(AutocompleteProviderListener* listener,
|
| Profile* profile);
|
|
|
| virtual ~ZeroSuggestProvider();
|
|
|
| - // The 4 functions below (that take classes defined in SearchProvider as
|
| - // arguments) were copied and trimmed from SearchProvider.
|
| - // TODO(hfung): Refactor them into a new base class common to both
|
| - // ZeroSuggestProvider and SearchProvider.
|
| -
|
| - // From the OpenSearch formatted response |root_val|, populate query
|
| - // suggestions into |suggest_results|, navigation suggestions into
|
| - // |navigation_results|, and the verbatim relevance score into
|
| - // |verbatim_relevance|.
|
| - void FillResults(const base::Value& root_val,
|
| - int* verbatim_relevance,
|
| - SearchProvider::SuggestResults* suggest_results,
|
| - SearchProvider::NavigationResults* navigation_results);
|
| -
|
| - // Creates AutocompleteMatches to search |template_url| for "<suggestion>" for
|
| - // all suggestions in |results|, and adds them to |map|.
|
| - void AddSuggestResultsToMap(const SearchProvider::SuggestResults& results,
|
| + // Creates AutocompleteMatches to search |template_url| for "<suggestion>"
|
| + // for all suggestions in |results|, and adds them to |map|.
|
| + void AddSuggestResultsToMap(const SuggestResults& results,
|
| const TemplateURL* template_url,
|
| - SearchProvider::MatchMap* map);
|
| -
|
| - // Creates an AutocompleteMatch with the provided |relevance| and |type| to
|
| - // search |template_url| for |query_string|. |accepted_suggestion| will be
|
| - // used to generate Assisted Query Stats.
|
| - //
|
| - // Adds this match to |map|; if such a match already exists, whichever one
|
| - // has lower relevance is eliminated.
|
| - void AddMatchToMap(int relevance,
|
| - AutocompleteMatch::Type type,
|
| - const TemplateURL* template_url,
|
| - const base::string16& query_string,
|
| - int accepted_suggestion,
|
| - SearchProvider::MatchMap* map);
|
| + MatchMap* map);
|
|
|
| // Returns an AutocompleteMatch for a navigational suggestion |navigation|.
|
| - AutocompleteMatch NavigationToMatch(
|
| - const SearchProvider::NavigationResult& navigation);
|
| + AutocompleteMatch NavigationToMatch(const NavigationResult& navigation);
|
|
|
| // Fetches zero-suggest suggestions by sending a request using |suggest_url|.
|
| void Run(const GURL& suggest_url);
|
|
|
| - // Parses results from the zero-suggest server and updates results.
|
| - void ParseSuggestResults(const base::Value& root_val);
|
| -
|
| // Converts the parsed results to a set of AutocompleteMatches and adds them
|
| // to |matches_|. Also update the histograms for how many results were
|
| // received.
|
| @@ -161,17 +143,15 @@ class ZeroSuggestProvider : public AutocompleteProvider,
|
|
|
| // Fetcher used to retrieve results.
|
| scoped_ptr<net::URLFetcher> fetcher_;
|
| - // Whether there's a pending request in flight.
|
| - bool have_pending_request_;
|
|
|
| // Suggestion for the current URL.
|
| AutocompleteMatch current_url_match_;
|
| - // Navigation suggestions for the most recent ZeroSuggest input URL.
|
| - SearchProvider::NavigationResults navigation_results_;
|
| - // Query suggestions for the most recent ZeroSuggest input URL.
|
| - SearchProvider::MatchMap query_matches_map_;
|
| - // The relevance score for the URL of the current page.
|
| - int verbatim_relevance_;
|
| +
|
| + // Suggestions received from the most recent run.
|
| + Results results_;
|
| +
|
| + // Generally an empty string since this is zero-suggest.
|
| + base::string16 input_text_;
|
|
|
| // Whether a field trial, if any, has triggered in the most recent
|
| // autocomplete query. This field is set to true if the last request
|
|
|