1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file contains the Search autocomplete provider. This provider is
6 // responsible for all autocomplete entries that start with "Search <engine>
7 // for ...", including searching for the current input string, search
8 // history, and search suggestions. An instance of it gets created and
9 // managed by the autocomplete controller.
11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
18 #include "base/basictypes.h"
19 #include "base/compiler_specific.h"
20 #include "base/memory/scoped_ptr.h"
21 #include "base/memory/scoped_vector.h"
22 #include "base/time/time.h"
23 #include "base/timer/timer.h"
24 #include "chrome/browser/autocomplete/autocomplete_input.h"
25 #include "chrome/browser/autocomplete/autocomplete_match.h"
26 #include "chrome/browser/autocomplete/autocomplete_provider.h"
27 #include "chrome/browser/history/history_types.h"
28 #include "chrome/browser/search_engines/template_url.h"
29 #include "net/url_request/url_fetcher_delegate.h"
32 class SearchProviderTest
;
33 class SuggestionDeletionHandler
;
34 class TemplateURLService
;
44 // Autocomplete provider for searches and suggestions from a search engine.
46 // After construction, the autocomplete controller repeatedly calls Start()
47 // with some user input, each time expecting to receive a small set of the best
48 // matches (either synchronously or asynchronously).
50 // Initially the provider creates a match that searches for the current input
51 // text. It also starts a task to query the Suggest servers. When that data
52 // comes back, the provider creates and returns matches for the best
54 class SearchProvider
: public AutocompleteProvider
,
55 public net::URLFetcherDelegate
{
57 // ID used in creating URLFetcher for default provider's suggest results.
58 static const int kDefaultProviderURLFetcherID
;
60 // ID used in creating URLFetcher for keyword provider's suggest results.
61 static const int kKeywordProviderURLFetcherID
;
63 // ID used in creating URLFetcher for deleting suggestion results.
64 static const int kDeletionURLFetcherID
;
66 SearchProvider(AutocompleteProviderListener
* listener
, Profile
* profile
);
68 // Returns whether the SearchProvider previously flagged |match| as a query
69 // that should be prefetched.
70 static bool ShouldPrefetch(const AutocompleteMatch
& match
);
72 // Extracts the suggest response metadata which SearchProvider previously
73 // stored for |match|.
74 static std::string
GetSuggestMetadata(const AutocompleteMatch
& match
);
76 // AutocompleteProvider:
77 virtual void AddProviderInfo(ProvidersInfo
* provider_info
) const OVERRIDE
;
78 virtual void DeleteMatch(const AutocompleteMatch
& match
) OVERRIDE
;
79 virtual void ResetSession() OVERRIDE
;
81 bool field_trial_triggered_in_session() const {
82 return field_trial_triggered_in_session_
;
85 // This URL may be sent with suggest requests; see comments on CanSendURL().
86 void set_current_page_url(const GURL
& current_page_url
) {
87 current_page_url_
= current_page_url
;
91 virtual ~SearchProvider();
94 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after
95 // refactoring common code to a new base class.
96 friend class SearchProviderTest
;
97 friend class ZeroSuggestProvider
;
98 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, CanSendURL
);
99 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, NavigationInline
);
100 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, NavigationInlineDomainClassify
);
101 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, NavigationInlineSchemeSubstring
);
102 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, RemoveStaleResultsTest
);
103 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, SuggestRelevanceExperiment
);
104 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest
, TestDeleteMatch
);
105 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest
, GetDestinationURL
);
106 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest
, ClearPrefetchedResults
);
107 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest
, SetPrefetchQuery
);
109 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers
111 // . The default provider. This corresponds to the user's default search
112 // engine. This is always used, except for the rare case of no default
114 // . The keyword provider. This is used if the user has typed in a keyword.
117 explicit Providers(TemplateURLService
* template_url_service
);
119 // Returns true if the specified providers match the two providers cached
121 bool equal(const base::string16
& default_provider
,
122 const base::string16
& keyword_provider
) const {
123 return (default_provider
== default_provider_
) &&
124 (keyword_provider
== keyword_provider_
);
127 // Resets the cached providers.
128 void set(const base::string16
& default_provider
,
129 const base::string16
& keyword_provider
) {
130 default_provider_
= default_provider
;
131 keyword_provider_
= keyword_provider
;
134 TemplateURLService
* template_url_service() { return template_url_service_
; }
135 const base::string16
& default_provider() const { return default_provider_
; }
136 const base::string16
& keyword_provider() const { return keyword_provider_
; }
138 // NOTE: These may return NULL even if the provider members are nonempty!
139 const TemplateURL
* GetDefaultProviderURL() const;
140 const TemplateURL
* GetKeywordProviderURL() const;
142 // Returns true if there is a valid keyword provider.
143 bool has_keyword_provider() const { return !keyword_provider_
.empty(); }
146 TemplateURLService
* template_url_service_
;
148 // Cached across the life of a query so we behave consistently even if the
149 // user changes their default while the query is running.
150 base::string16 default_provider_
;
151 base::string16 keyword_provider_
;
153 DISALLOW_COPY_AND_ASSIGN(Providers
);
156 // The Result classes are intermediate representations of AutocompleteMatches,
157 // simply containing relevance-ranked search and navigation suggestions.
158 // They may be cached to provide some synchronous matches while requests for
159 // new suggestions from updated input are in flight.
160 // TODO(msw) Extend these classes to generate their corresponding matches and
161 // other requisite data, in order to consolidate and simplify the
162 // highly fragmented SearchProvider logic for each Result type.
165 Result(bool from_keyword_provider
,
167 bool relevance_from_server
);
170 bool from_keyword_provider() const { return from_keyword_provider_
; }
172 const base::string16
& match_contents() const { return match_contents_
; }
173 const ACMatchClassifications
& match_contents_class() const {
174 return match_contents_class_
;
177 int relevance() const { return relevance_
; }
178 void set_relevance(int relevance
) { relevance_
= relevance
; }
180 bool relevance_from_server() const { return relevance_from_server_
; }
181 void set_relevance_from_server(bool relevance_from_server
) {
182 relevance_from_server_
= relevance_from_server
;
185 // Returns if this result is inlineable against the current input |input|.
186 // Non-inlineable results are stale.
187 virtual bool IsInlineable(const base::string16
& input
) const = 0;
189 // Returns the default relevance value for this result (which may
190 // be left over from a previous omnibox input) given the current
191 // input and whether the current input caused a keyword provider
193 virtual int CalculateRelevance(const AutocompleteInput
& input
,
194 bool keyword_provider_requested
) const = 0;
197 // The contents to be displayed and its style info.
198 base::string16 match_contents_
;
199 ACMatchClassifications match_contents_class_
;
201 // True if the result came from the keyword provider.
202 bool from_keyword_provider_
;
204 // The relevance score.
208 // Whether this result's relevance score was fully or partly calculated
209 // based on server information, and thus is assumed to be more accurate.
210 // This is ultimately used in
211 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments
213 bool relevance_from_server_
;
216 class SuggestResult
: public Result
{
218 SuggestResult(const base::string16
& suggestion
,
219 AutocompleteMatchType::Type type
,
220 const base::string16
& match_contents
,
221 const base::string16
& annotation
,
222 const std::string
& suggest_query_params
,
223 const std::string
& deletion_url
,
224 bool from_keyword_provider
,
226 bool relevance_from_server
,
227 bool should_prefetch
,
228 const base::string16
& input_text
);
229 virtual ~SuggestResult();
231 const base::string16
& suggestion() const { return suggestion_
; }
232 AutocompleteMatchType::Type
type() const { return type_
; }
233 const base::string16
& annotation() const { return annotation_
; }
234 const std::string
& suggest_query_params() const {
235 return suggest_query_params_
;
237 const std::string
& deletion_url() const { return deletion_url_
; }
238 bool should_prefetch() const { return should_prefetch_
; }
240 // Fills in |match_contents_class_| to reflect how |match_contents_| should
241 // be displayed and bolded against the current |input_text|. If
242 // |allow_bolding_all| is false and |match_contents_class_| would have all
243 // of |match_contents_| bolded, do nothing.
244 void ClassifyMatchContents(const bool allow_bolding_all
,
245 const base::string16
& input_text
);
248 virtual bool IsInlineable(const base::string16
& input
) const OVERRIDE
;
249 virtual int CalculateRelevance(
250 const AutocompleteInput
& input
,
251 bool keyword_provider_requested
) const OVERRIDE
;
254 // The search terms to be used for this suggestion.
255 base::string16 suggestion_
;
257 AutocompleteMatchType::Type type_
;
259 // Optional annotation for the |match_contents_| for disambiguation.
260 // This may be displayed in the autocomplete match contents, but is defined
261 // separately to facilitate different formatting.
262 base::string16 annotation_
;
264 // Optional additional parameters to be added to the search URL.
265 std::string suggest_query_params_
;
267 // Optional deletion URL provided with suggestions. Fetching this URL
268 // should result in some reasonable deletion behaviour on the server,
269 // e.g. deleting this term out of a user's server-side search history.
270 std::string deletion_url_
;
272 // Should this result be prefetched?
273 bool should_prefetch_
;
276 class NavigationResult
: public Result
{
278 // |provider| is necessary to use StringForURLDisplay() in order to
279 // compute |formatted_url_|.
280 NavigationResult(const AutocompleteProvider
& provider
,
282 const base::string16
& description
,
283 bool from_keyword_provider
,
285 bool relevance_from_server
,
286 const base::string16
& input_text
,
287 const std::string
& languages
);
288 virtual ~NavigationResult();
290 const GURL
& url() const { return url_
; }
291 const base::string16
& description() const { return description_
; }
292 const base::string16
& formatted_url() const { return formatted_url_
; }
294 // Fills in |match_contents_| and |match_contents_class_| to reflect how
295 // the URL should be displayed and bolded against the current |input_text|
296 // and user |languages|. If |allow_bolding_nothing| is false and
297 // |match_contents_class_| would result in an entirely unbolded
298 // |match_contents_|, do nothing.
299 void CalculateAndClassifyMatchContents(const bool allow_bolding_nothing
,
300 const base::string16
& input_text
,
301 const std::string
& languages
);
304 virtual bool IsInlineable(const base::string16
& input
) const OVERRIDE
;
305 virtual int CalculateRelevance(
306 const AutocompleteInput
& input
,
307 bool keyword_provider_requested
) const OVERRIDE
;
310 // The suggested url for navigation.
313 // The properly formatted ("fixed up") URL string with equivalent meaning
314 // to the one in |url_|.
315 base::string16 formatted_url_
;
317 // The suggested navigational result description; generally the site name.
318 base::string16 description_
;
321 class CompareScoredResults
;
323 typedef std::vector
<SuggestResult
> SuggestResults
;
324 typedef std::vector
<NavigationResult
> NavigationResults
;
325 typedef std::vector
<history::KeywordSearchTermVisit
> HistoryResults
;
326 typedef std::pair
<base::string16
, std::string
> MatchKey
;
327 typedef std::map
<MatchKey
, AutocompleteMatch
> MatchMap
;
328 typedef ScopedVector
<SuggestionDeletionHandler
> SuggestionDeletionHandlers
;
330 // A simple structure bundling most of the information (including
331 // both SuggestResults and NavigationResults) returned by a call to
332 // the suggest server.
334 // This has to be declared after the typedefs since it relies on some of them.
339 // Clears |suggest_results| and |navigation_results| and resets
340 // |verbatim_relevance| to -1 (implies unset).
343 // Returns whether any of the results (including verbatim) have
344 // server-provided scores.
345 bool HasServerProvidedScores() const;
347 // Query suggestions sorted by relevance score.
348 SuggestResults suggest_results
;
350 // Navigational suggestions sorted by relevance score.
351 NavigationResults navigation_results
;
353 // The server supplied verbatim relevance scores. Negative values
354 // indicate that there is no suggested score; a value of 0
355 // suppresses the verbatim result.
356 int verbatim_relevance
;
358 // The JSON metadata associated with this server response.
359 std::string metadata
;
362 DISALLOW_COPY_AND_ASSIGN(Results
);
365 // Returns an AutocompleteMatch with the given |autocomplete_provider|
366 // for the search |suggestion|, which represents a search via |template_url|.
367 // If |template_url| is NULL, returns a match with an invalid destination URL.
369 // |input_text| is the original user input. This is used to highlight
370 // portions of the match contents to distinguish locally-typed text from
373 // |input| is necessary for various other details, like whether we should
374 // allow inline autocompletion and what the transition type should be.
375 // |accepted_suggestion| and |omnibox_start_margin| are used along with
376 // |input_text| to generate Assisted Query Stats.
377 // |append_extra_query_params| should be set if |template_url| is the default
378 // search engine, so the destination URL will contain any
379 // command-line-specified query params.
380 static AutocompleteMatch
CreateSearchSuggestion(
381 AutocompleteProvider
* autocomplete_provider
,
382 const AutocompleteInput
& input
,
383 const base::string16
& input_text
,
384 const SuggestResult
& suggestion
,
385 const TemplateURL
* template_url
,
386 int accepted_suggestion
,
387 int omnibox_start_margin
,
388 bool append_extra_query_params
);
390 // Removes non-inlineable results until either the top result can inline
391 // autocomplete the current input or verbatim outscores the top result.
392 static void RemoveStaleResults(const base::string16
& input
,
393 int verbatim_relevance
,
394 SuggestResults
* suggest_results
,
395 NavigationResults
* navigation_results
);
397 // Recalculates the match contents class of |results| to better display
398 // against the current input and user's language.
399 void UpdateMatchContentsClass(const base::string16
& input_text
,
402 // Calculates the relevance score for the keyword verbatim result (if the
403 // input matches one of the profile's keyword).
404 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type
,
405 bool prefer_keyword
);
407 // AutocompleteProvider:
408 virtual void Start(const AutocompleteInput
& input
,
409 bool minimal_changes
) OVERRIDE
;
410 virtual void Stop(bool clear_cached_results
) OVERRIDE
;
412 // net::URLFetcherDelegate:
413 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) OVERRIDE
;
415 // This gets called when we have requested a suggestion deletion from the
416 // server to handle the results of the deletion.
417 void OnDeletionComplete(bool success
,
418 SuggestionDeletionHandler
* handler
);
420 // Records in UMA whether the deletion request resulted in success.
421 // This is virtual so test code can override it to check that we
422 // correctly handle the request result.
423 virtual void RecordDeletionResult(bool success
);
425 // Removes the deleted match from the list of |matches_|.
426 void DeleteMatchFromMatches(const AutocompleteMatch
& match
);
428 // Called when timer_ expires.
431 // Runs the history query, if necessary. The history query is synchronous.
432 // This does not update |done_|.
433 void DoHistoryQuery(bool minimal_changes
);
435 // Determines whether an asynchronous subcomponent query should run for the
436 // current input. If so, starts it if necessary; otherwise stops it.
437 // NOTE: This function does not update |done_|. Callers must do so.
438 void StartOrStopSuggestQuery(bool minimal_changes
);
440 // Returns true when the current query can be sent to the Suggest service.
441 // This will be false e.g. when Suggest is disabled, the query contains
442 // potentially private data, etc.
443 bool IsQuerySuitableForSuggest() const;
445 // Stops the suggest query.
446 // NOTE: This does not update |done_|. Callers must do so.
449 // Clears the current results.
450 void ClearAllResults();
452 // Removes stale results for both default and keyword providers. See comments
453 // on RemoveStaleResults().
454 void RemoveAllStaleResults();
456 // Apply calculated relevance scores to the current results.
457 void ApplyCalculatedRelevance();
458 void ApplyCalculatedSuggestRelevance(SuggestResults
* list
);
459 void ApplyCalculatedNavigationRelevance(NavigationResults
* list
);
461 // Starts a new URLFetcher requesting suggest results from |template_url|;
462 // callers own the returned URLFetcher, which is NULL for invalid providers.
463 net::URLFetcher
* CreateSuggestFetcher(int id
,
464 const TemplateURL
* template_url
,
465 const AutocompleteInput
& input
);
467 // Parses JSON response received from the provider, stripping XSSI
468 // protection if needed. Returns the parsed data if successful, NULL
470 static scoped_ptr
<base::Value
> DeserializeJsonData(std::string json_data
);
472 // Parses results from the suggest server and updates the appropriate suggest
473 // and navigation result lists, depending on whether |is_keyword| is true.
474 // Returns whether the appropriate result list members were updated.
475 bool ParseSuggestResults(base::Value
* root_val
, bool is_keyword
);
477 // Converts the parsed results to a set of AutocompleteMatches, |matches_|.
478 void ConvertResultsToAutocompleteMatches();
480 // Returns an iterator to the first match in |matches_| which might
481 // be chosen as default. If
482 // |autocomplete_result_will_reorder_for_default_match| is false,
483 // this simply means the first match; otherwise, it means the first
484 // match for which the |allowed_to_be_default_match| member is true.
485 ACMatches::const_iterator
FindTopMatch(
486 bool autocomplete_result_will_reorder_for_default_match
) const;
488 // Checks if suggested relevances violate certain expected constraints.
489 // See UpdateMatches() for the use and explanation of these constraints.
490 bool IsTopMatchNavigationInKeywordMode(
491 bool autocomplete_result_will_reorder_for_default_match
) const;
492 bool HasKeywordDefaultMatchInKeywordMode() const;
493 bool IsTopMatchScoreTooLow(
494 bool autocomplete_result_will_reorder_for_default_match
) const;
495 bool IsTopMatchSearchWithURLInput(
496 bool autocomplete_result_will_reorder_for_default_match
) const;
497 bool HasValidDefaultMatch(
498 bool autocomplete_result_will_reorder_for_default_match
) const;
500 // Updates |matches_| from the latest results; applies calculated relevances
501 // if suggested relevances cause undesriable behavior. Updates |done_|.
502 void UpdateMatches();
504 // Converts an appropriate number of navigation results in
505 // |navigation_results| to matches and adds them to |matches|.
506 void AddNavigationResultsToMatches(
507 const NavigationResults
& navigation_results
,
510 // Adds a match for each result in |results| to |map|. |is_keyword| indicates
511 // whether the results correspond to the keyword provider or default provider.
512 void AddHistoryResultsToMap(const HistoryResults
& results
,
514 int did_not_accept_suggestion
,
517 // Calculates relevance scores for all |results|.
518 SuggestResults
ScoreHistoryResults(const HistoryResults
& results
,
519 bool base_prevent_inline_autocomplete
,
520 bool input_multiple_words
,
521 const base::string16
& input_text
,
524 // Adds matches for |results| to |map|.
525 void AddSuggestResultsToMap(const SuggestResults
& results
,
526 const std::string
& metadata
,
529 // Gets the relevance score for the verbatim result. This value may be
530 // provided by the suggest server or calculated locally; if
531 // |relevance_from_server| is non-NULL, it will be set to indicate which of
533 int GetVerbatimRelevance(bool* relevance_from_server
) const;
535 // Calculates the relevance score for the verbatim result from the
536 // default search engine. This version takes into account context:
537 // i.e., whether the user has entered a keyword-based search or not.
538 int CalculateRelevanceForVerbatim() const;
540 // Calculates the relevance score for the verbatim result from the default
541 // search engine *ignoring* whether the input is a keyword-based search
542 // or not. This function should only be used to determine the minimum
543 // relevance score that the best result from this provider should have.
544 // For normal use, prefer the above function.
545 int CalculateRelevanceForVerbatimIgnoringKeywordModeState() const;
547 // Gets the relevance score for the keyword verbatim result.
548 // |relevance_from_server| is handled as in GetVerbatimRelevance().
549 // TODO(mpearson): Refactor so this duplication isn't necessary or
550 // restructure so one static function takes all the parameters it needs
551 // (rather than looking at internal state).
552 int GetKeywordVerbatimRelevance(bool* relevance_from_server
) const;
554 // |time| is the time at which this query was last seen. |is_keyword|
555 // indicates whether the results correspond to the keyword provider or default
556 // provider. |use_aggressive_method| says whether this function can use a
557 // method that gives high scores (1200+) rather than one that gives lower
558 // scores. When using the aggressive method, scores may exceed 1300
559 // unless |prevent_search_history_inlining| is set.
560 int CalculateRelevanceForHistory(const base::Time
& time
,
562 bool use_aggressive_method
,
563 bool prevent_search_history_inlining
) const;
565 // Creates an AutocompleteMatch for "Search <engine> for |query_string|" with
566 // the supplied details. Adds this match to |map|; if such a match already
567 // exists, whichever one has lower relevance is eliminated.
568 void AddMatchToMap(const SuggestResult
& result
,
569 const base::string16
& input_text
,
570 const std::string
& metadata
,
571 int accepted_suggestion
,
574 // Returns an AutocompleteMatch for a navigational suggestion.
575 AutocompleteMatch
NavigationToMatch(const NavigationResult
& navigation
);
577 // Resets the scores of all |keyword_navigation_results_| matches to
578 // be below that of the top keyword query match (the verbatim match
579 // as expressed by |keyword_verbatim_relevance_| or keyword query
580 // suggestions stored in |keyword_suggest_results_|). If there
581 // are no keyword suggestions and keyword verbatim is suppressed,
582 // then drops the suggested relevance scores for the navsuggestions
583 // and drops the request to suppress verbatim, thereby introducing the
584 // keyword verbatim match which will naturally outscore the navsuggestions.
585 void DemoteKeywordNavigationMatchesPastTopQuery();
587 // Updates the value of |done_| from the internal state.
590 // Returns whether we can send the URL of the current page in any suggest
591 // requests. Doing this requires that all the following hold:
592 // * The user has suggest enabled in their settings and is not in incognito
593 // mode. (Incognito disables suggest entirely.)
594 // * The current URL is HTTP, or HTTPS with the same domain as the suggest
595 // server. Non-HTTP[S] URLs (e.g. FTP/file URLs) may contain sensitive
596 // information. HTTPS URLs may also contain sensitive information, but if
597 // they're on the same domain as the suggest server, then the relevant
598 // entity could have already seen/logged this data.
599 // * The suggest request is sent over HTTPS. This avoids leaking the current
600 // page URL in world-readable network traffic.
601 // * The user's suggest provider is Google. We might want to allow other
602 // providers to see this data someday, but for now this has only been
603 // implemented for Google. Also see next bullet.
604 // * The user is OK in principle with sending URLs of current pages to their
605 // provider. Today, there is no explicit setting that controls this, but if
606 // the user has tab sync enabled and tab sync is unencrypted, then they're
607 // already sending this data to Google for sync purposes. Thus we use this
608 // setting as a proxy for "it's OK to send such data". In the future,
609 // especially if we want to support suggest providers other than Google, we
610 // may change this to be a standalone setting or part of some explicit
612 static bool CanSendURL(
613 const GURL
& current_page_url
,
614 const GURL
& suggest_url
,
615 const TemplateURL
* template_url
,
616 AutocompleteInput::PageClassification page_classification
,
619 // The amount of time to wait before sending a new suggest request after the
620 // previous one. Non-const because some unittests modify this value.
621 static int kMinimumTimeBetweenSuggestQueriesMs
;
623 // The following keys are used to record additional information on matches.
625 // We annotate our AutocompleteMatches with whether their relevance scores
626 // were server-provided using this key in the |additional_info| field.
627 static const char kRelevanceFromServerKey
[];
629 // Indicates whether the server said a match should be prefetched.
630 static const char kShouldPrefetchKey
[];
632 // Used to store metadata from the server response, which is needed for
634 static const char kSuggestMetadataKey
[];
636 // Used to store a deletion request url for server-provided suggestions.
637 static const char kDeletionUrlKey
[];
639 // These are the values for the above keys.
640 static const char kTrue
[];
641 static const char kFalse
[];
643 // Maintains the TemplateURLs used.
644 Providers providers_
;
647 AutocompleteInput input_
;
649 // Input when searching against the keyword provider.
650 AutocompleteInput keyword_input_
;
652 // Searches in the user's history that begin with the input text.
653 HistoryResults keyword_history_results_
;
654 HistoryResults default_history_results_
;
656 // Number of suggest results that haven't yet arrived. If greater than 0 it
657 // indicates one of the URLFetchers is still running.
658 int suggest_results_pending_
;
660 // A timer to start a query to the suggest server after the user has stopped
661 // typing for long enough.
662 base::OneShotTimer
<SearchProvider
> timer_
;
664 // The time at which we sent a query to the suggest server.
665 base::TimeTicks time_suggest_request_sent_
;
667 // Fetchers used to retrieve results for the keyword and default providers.
668 scoped_ptr
<net::URLFetcher
> keyword_fetcher_
;
669 scoped_ptr
<net::URLFetcher
> default_fetcher_
;
671 // Results from the default and keyword search providers.
672 Results default_results_
;
673 Results keyword_results_
;
675 // Each deletion handler in this vector corresponds to an outstanding request
676 // that a server delete a personalized suggestion. Making this a ScopedVector
677 // causes us to auto-cancel all such requests on shutdown.
678 SuggestionDeletionHandlers deletion_handlers_
;
680 // Whether a field trial, if any, has triggered in the most recent
681 // autocomplete query. This field is set to false in Start() and may be set
682 // to true if either the default provider or keyword provider has completed
683 // and their corresponding suggest response contained
684 // '"google:fieldtrialtriggered":true'.
685 // If the autocomplete query has not returned, this field is set to false.
686 bool field_trial_triggered_
;
688 // Same as above except that it is maintained across the current Omnibox
690 bool field_trial_triggered_in_session_
;
692 // If true, search history query suggestions will score low enough that
693 // they will not be inlined.
694 bool prevent_search_history_inlining_
;
696 GURL current_page_url_
;
698 DISALLOW_COPY_AND_ASSIGN(SearchProvider
);
701 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_