| Index: chrome/browser/autocomplete/search_provider.h
|
| diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
|
| index 16f669f3bc095ccbc56d6f9629670011c1f3eece..ef2967b92caed6aefbe801f98505431a83fdfbc0 100644
|
| --- a/chrome/browser/autocomplete/search_provider.h
|
| +++ b/chrome/browser/autocomplete/search_provider.h
|
| @@ -53,12 +53,76 @@ class URLFetcher;
|
| class SearchProvider : public AutocompleteProvider,
|
| public net::URLFetcherDelegate {
|
| public:
|
| + // Manages the providers (TemplateURLs) used by SearchProvider. Two providers
|
| + // may be used:
|
| + // . The default provider. This corresponds to the user's default search
|
| + // engine. This is always used, except for the rare case of no default
|
| + // engine.
|
| + // . The keyword provider. This is used if the user has typed in a keyword.
|
| + class Providers {
|
| + public:
|
| + explicit Providers(TemplateURLService* template_url_service);
|
| +
|
| + // Returns true if the specified providers match the two providers cached
|
| + // by this class.
|
| + bool equal(const string16& default_provider,
|
| + const string16& keyword_provider) const {
|
| + return (default_provider == default_provider_) &&
|
| + (keyword_provider == keyword_provider_);
|
| + }
|
| +
|
| + // Resets the cached providers.
|
| + void set(const string16& default_provider,
|
| + const string16& keyword_provider) {
|
| + default_provider_ = default_provider;
|
| + keyword_provider_ = keyword_provider;
|
| + }
|
| +
|
| + TemplateURLService* template_url_service() { return template_url_service_; }
|
| + const string16& default_provider() const { return default_provider_; }
|
| + const string16& keyword_provider() const { return keyword_provider_; }
|
| +
|
| + // NOTE: These may return NULL even if the provider members are nonempty!
|
| + const TemplateURL* GetDefaultProviderURL() const;
|
| + const TemplateURL* GetKeywordProviderURL() const;
|
| +
|
| + // Returns true if there is a valid keyword provider.
|
| + bool has_keyword_provider() const { return !keyword_provider_.empty(); }
|
| +
|
| + private:
|
| + TemplateURLService* template_url_service_;
|
| +
|
| + // Cached across the life of a query so we behave consistently even if the
|
| + // user changes their default while the query is running.
|
| + string16 default_provider_;
|
| + string16 keyword_provider_;
|
| + };
|
| +
|
| // ID used in creating URLFetcher for default provider's suggest results.
|
| static const int kDefaultProviderURLFetcherID;
|
|
|
| // ID used in creating URLFetcher for keyword provider's suggest results.
|
| static const int kKeywordProviderURLFetcherID;
|
|
|
| + // Returns the default and keyword providers for |profile|. The keyword
|
| + // provider is set only if |keyword_input| is non-NULL. If |keyword_input|
|
| + // represents a valid keyword input, the keyword is stripped.
|
| + static Providers GetProviders(Profile* profile,
|
| + const AutocompleteInput& input,
|
| + AutocompleteInput* keyword_input);
|
| +
|
| + static AutocompleteMatch CreateSearchSuggestion(
|
| + Profile* profile,
|
| + AutocompleteProvider* autocomplete_provider,
|
| + const Providers& search_providers,
|
| + const AutocompleteInput& input,
|
| + const string16& query_string,
|
| + const string16& input_text,
|
| + int relevance,
|
| + AutocompleteMatch::Type type,
|
| + int accepted_suggestion,
|
| + bool is_keyword);
|
| +
|
| SearchProvider(AutocompleteProviderListener* listener, Profile* profile);
|
|
|
| // Marks the instant query as done. If |input_text| is non-empty this changes
|
| @@ -105,53 +169,6 @@ class SearchProvider : public AutocompleteProvider,
|
|
|
| virtual ~SearchProvider();
|
|
|
| - // Manages the providers (TemplateURLs) used by SearchProvider. Two providers
|
| - // may be used:
|
| - // . The default provider. This corresponds to the user's default search
|
| - // engine. This is always used, except for the rare case of no default
|
| - // engine.
|
| - // . The keyword provider. This is used if the user has typed in a keyword.
|
| - class Providers {
|
| - public:
|
| - explicit Providers(TemplateURLService* template_url_service);
|
| -
|
| - // Returns true if the specified providers match the two providers cached
|
| - // by this class.
|
| - bool equal(const string16& default_provider,
|
| - const string16& keyword_provider) const {
|
| - return (default_provider == default_provider_) &&
|
| - (keyword_provider == keyword_provider_);
|
| - }
|
| -
|
| - // Resets the cached providers.
|
| - void set(const string16& default_provider,
|
| - const string16& keyword_provider) {
|
| - default_provider_ = default_provider;
|
| - keyword_provider_ = keyword_provider;
|
| - }
|
| -
|
| - TemplateURLService* template_url_service() { return template_url_service_; }
|
| - const string16& default_provider() const { return default_provider_; }
|
| - const string16& keyword_provider() const { return keyword_provider_; }
|
| -
|
| - // NOTE: These may return NULL even if the provider members are nonempty!
|
| - const TemplateURL* GetDefaultProviderURL() const;
|
| - const TemplateURL* GetKeywordProviderURL() const;
|
| -
|
| - // Returns true if there is a valid keyword provider.
|
| - bool has_keyword_provider() const { return !keyword_provider_.empty(); }
|
| -
|
| - private:
|
| - TemplateURLService* template_url_service_;
|
| -
|
| - // Cached across the life of a query so we behave consistently even if the
|
| - // user changes their default while the query is running.
|
| - string16 default_provider_;
|
| - string16 keyword_provider_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(Providers);
|
| - };
|
| -
|
| // The Result classes are intermediate representations of AutocompleteMatches,
|
| // simply containing relevance-ranked search and navigation suggestions.
|
| // They may be cached to provide some synchronous matches while requests for
|
|
|