OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains the Search autocomplete provider. This provider is | 5 // This file contains the Search autocomplete provider. This provider is |
6 // responsible for all autocomplete entries that start with "Search <engine> | 6 // responsible for all autocomplete entries that start with "Search <engine> |
7 // for ...", including searching for the current input string, search | 7 // for ...", including searching for the current input string, search |
8 // history, and search suggestions. An instance of it gets created and | 8 // history, and search suggestions. An instance of it gets created and |
9 // managed by the autocomplete controller. | 9 // managed by the autocomplete controller. |
10 | 10 |
11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
19 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/memory/scoped_vector.h" | |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
23 #include "chrome/browser/autocomplete/autocomplete_input.h" | 24 #include "chrome/browser/autocomplete/autocomplete_input.h" |
24 #include "chrome/browser/autocomplete/autocomplete_match.h" | 25 #include "chrome/browser/autocomplete/autocomplete_match.h" |
25 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 26 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
26 #include "chrome/browser/history/history_types.h" | 27 #include "chrome/browser/history/history_types.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
28 #include "net/url_request/url_fetcher_delegate.h" | 29 #include "net/url_request/url_fetcher_delegate.h" |
29 | 30 |
30 class Profile; | 31 class Profile; |
31 class SearchProviderTest; | 32 class SearchProviderTest; |
33 class SuggestionDeletionHandler; | |
32 class TemplateURLService; | 34 class TemplateURLService; |
33 | 35 |
34 namespace base { | 36 namespace base { |
35 class Value; | 37 class Value; |
36 } | 38 } |
37 | 39 |
38 namespace net { | 40 namespace net { |
39 class URLFetcher; | 41 class URLFetcher; |
40 } | 42 } |
41 | 43 |
42 // Autocomplete provider for searches and suggestions from a search engine. | 44 // Autocomplete provider for searches and suggestions from a search engine. |
43 // | 45 // |
44 // After construction, the autocomplete controller repeatedly calls Start() | 46 // After construction, the autocomplete controller repeatedly calls Start() |
45 // with some user input, each time expecting to receive a small set of the best | 47 // with some user input, each time expecting to receive a small set of the best |
46 // matches (either synchronously or asynchronously). | 48 // matches (either synchronously or asynchronously). |
47 // | 49 // |
48 // Initially the provider creates a match that searches for the current input | 50 // Initially the provider creates a match that searches for the current input |
49 // text. It also starts a task to query the Suggest servers. When that data | 51 // text. It also starts a task to query the Suggest servers. When that data |
50 // comes back, the provider creates and returns matches for the best | 52 // comes back, the provider creates and returns matches for the best |
51 // suggestions. | 53 // suggestions. |
52 class SearchProvider : public AutocompleteProvider, | 54 class SearchProvider : public AutocompleteProvider, |
53 public net::URLFetcherDelegate { | 55 public net::URLFetcherDelegate { |
54 public: | 56 public: |
55 // ID used in creating URLFetcher for default provider's suggest results. | 57 // ID used in creating URLFetcher for default provider's suggest results. |
56 static const int kDefaultProviderURLFetcherID; | 58 static const int kDefaultProviderURLFetcherID; |
57 | 59 |
58 // ID used in creating URLFetcher for keyword provider's suggest results. | 60 // ID used in creating URLFetcher for keyword provider's suggest results. |
59 static const int kKeywordProviderURLFetcherID; | 61 static const int kKeywordProviderURLFetcherID; |
60 | 62 |
63 // ID used in creating URLFetcher for deleting suggestion results. | |
64 static const int kDeletionURLFetcherID; | |
65 | |
61 SearchProvider(AutocompleteProviderListener* listener, Profile* profile); | 66 SearchProvider(AutocompleteProviderListener* listener, Profile* profile); |
62 | 67 |
63 // Returns an AutocompleteMatch with the given |autocomplete_provider|, | 68 // Returns an AutocompleteMatch with the given |autocomplete_provider|, |
64 // |relevance|, and |type|, which represents a search via |template_url| for | 69 // |relevance|, and |type|, which represents a search via |template_url| for |
65 // |query_string|. If |template_url| is NULL, returns a match with an invalid | 70 // |query_string|. If |template_url| is NULL, returns a match with an invalid |
66 // destination URL. | 71 // destination URL. |
67 // | 72 // |
68 // |input_text| is the original user input, which may differ from | 73 // |input_text| is the original user input, which may differ from |
69 // |query_string|; e.g. the user typed "foo" and got a search suggestion of | 74 // |query_string|; e.g. the user typed "foo" and got a search suggestion of |
70 // "food", which we're now marking up. This is used to highlight portions of | 75 // "food", which we're now marking up. This is used to highlight portions of |
(...skipping 25 matching lines...) Expand all Loading... | |
96 // Returns whether the SearchProvider previously flagged |match| as a query | 101 // Returns whether the SearchProvider previously flagged |match| as a query |
97 // that should be prefetched. | 102 // that should be prefetched. |
98 static bool ShouldPrefetch(const AutocompleteMatch& match); | 103 static bool ShouldPrefetch(const AutocompleteMatch& match); |
99 | 104 |
100 // Extracts the suggest response metadata which SearchProvider previously | 105 // Extracts the suggest response metadata which SearchProvider previously |
101 // stored for |match|. | 106 // stored for |match|. |
102 static std::string GetSuggestMetadata(const AutocompleteMatch& match); | 107 static std::string GetSuggestMetadata(const AutocompleteMatch& match); |
103 | 108 |
104 // AutocompleteProvider: | 109 // AutocompleteProvider: |
105 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 110 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
111 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | |
106 virtual void ResetSession() OVERRIDE; | 112 virtual void ResetSession() OVERRIDE; |
107 | 113 |
108 bool field_trial_triggered_in_session() const { | 114 bool field_trial_triggered_in_session() const { |
109 return field_trial_triggered_in_session_; | 115 return field_trial_triggered_in_session_; |
110 } | 116 } |
111 | 117 |
112 // This URL may be sent with suggest requests; see comments on CanSendURL(). | 118 // This URL may be sent with suggest requests; see comments on CanSendURL(). |
113 void set_current_page_url(const GURL& current_page_url) { | 119 void set_current_page_url(const GURL& current_page_url) { |
114 current_page_url_ = current_page_url; | 120 current_page_url_ = current_page_url; |
115 } | 121 } |
116 | 122 |
123 protected: | |
124 virtual ~SearchProvider(); | |
125 | |
117 private: | 126 private: |
118 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after | 127 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after |
119 // refactoring common code to a new base class. | 128 // refactoring common code to a new base class. |
120 friend class SearchProviderTest; | 129 friend class SearchProviderTest; |
121 friend class ZeroSuggestProvider; | 130 friend class ZeroSuggestProvider; |
122 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL); | 131 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL); |
123 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 132 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
124 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 133 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
125 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 134 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
126 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); | 135 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
127 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 136 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
137 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, | |
138 TestDeleteMatch_HasDeletionUrlSuccess); | |
139 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, | |
140 TestDeleteMatch_HasDeletionUrlFailure); | |
128 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); | 141 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
129 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); | 142 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); |
130 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); | 143 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); |
131 | 144 |
132 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 145 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
133 // may be used: | 146 // may be used: |
134 // . The default provider. This corresponds to the user's default search | 147 // . The default provider. This corresponds to the user's default search |
135 // engine. This is always used, except for the rare case of no default | 148 // engine. This is always used, except for the rare case of no default |
136 // engine. | 149 // engine. |
137 // . The keyword provider. This is used if the user has typed in a keyword. | 150 // . The keyword provider. This is used if the user has typed in a keyword. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 // there. | 239 // there. |
227 bool relevance_from_server_; | 240 bool relevance_from_server_; |
228 }; | 241 }; |
229 | 242 |
230 class SuggestResult : public Result { | 243 class SuggestResult : public Result { |
231 public: | 244 public: |
232 SuggestResult(const string16& suggestion, | 245 SuggestResult(const string16& suggestion, |
233 const string16& match_contents, | 246 const string16& match_contents, |
234 const string16& annotation, | 247 const string16& annotation, |
235 const std::string& suggest_query_params, | 248 const std::string& suggest_query_params, |
249 const std::string& deletion_url, | |
236 bool from_keyword_provider, | 250 bool from_keyword_provider, |
237 int relevance, | 251 int relevance, |
238 bool relevance_from_server, | 252 bool relevance_from_server, |
239 bool should_prefetch); | 253 bool should_prefetch); |
240 virtual ~SuggestResult(); | 254 virtual ~SuggestResult(); |
241 | 255 |
242 const string16& suggestion() const { return suggestion_; } | 256 const string16& suggestion() const { return suggestion_; } |
243 const string16& match_contents() const { return match_contents_; } | 257 const string16& match_contents() const { return match_contents_; } |
244 const string16& annotation() const { return annotation_; } | 258 const string16& annotation() const { return annotation_; } |
245 const std::string& suggest_query_params() const { | 259 const std::string& suggest_query_params() const { |
246 return suggest_query_params_; | 260 return suggest_query_params_; |
247 } | 261 } |
262 const std::string& deletion_url() const { return deletion_url_; } | |
248 bool should_prefetch() const { return should_prefetch_; } | 263 bool should_prefetch() const { return should_prefetch_; } |
249 | 264 |
250 // Result: | 265 // Result: |
251 virtual bool IsInlineable(const string16& input) const OVERRIDE; | 266 virtual bool IsInlineable(const string16& input) const OVERRIDE; |
252 virtual int CalculateRelevance( | 267 virtual int CalculateRelevance( |
253 const AutocompleteInput& input, | 268 const AutocompleteInput& input, |
254 bool keyword_provider_requested) const OVERRIDE; | 269 bool keyword_provider_requested) const OVERRIDE; |
255 | 270 |
256 private: | 271 private: |
257 // The search terms to be used for this suggestion. | 272 // The search terms to be used for this suggestion. |
258 string16 suggestion_; | 273 string16 suggestion_; |
259 | 274 |
260 // The contents to be displayed in the autocomplete match. | 275 // The contents to be displayed in the autocomplete match. |
261 string16 match_contents_; | 276 string16 match_contents_; |
262 | 277 |
263 // Optional annotation for the |match_contents_| for disambiguation. | 278 // Optional annotation for the |match_contents_| for disambiguation. |
264 // This may be displayed in the autocomplete match contents, but is defined | 279 // This may be displayed in the autocomplete match contents, but is defined |
265 // separately to facilitate different formatting. | 280 // separately to facilitate different formatting. |
266 string16 annotation_; | 281 string16 annotation_; |
267 | 282 |
268 // Optional additional parameters to be added to the search URL. | 283 // Optional additional parameters to be added to the search URL. |
269 std::string suggest_query_params_; | 284 std::string suggest_query_params_; |
270 | 285 |
286 // Optional deletion URL provided with suggestions. Fetching this URL | |
287 // should result in some reasonable deletion behaviour on the server, | |
288 // e.g. deleting this term out of a user's server-side search history. | |
289 std::string deletion_url_; | |
290 | |
271 // Should this result be prefetched? | 291 // Should this result be prefetched? |
272 bool should_prefetch_; | 292 bool should_prefetch_; |
273 }; | 293 }; |
274 | 294 |
275 class NavigationResult : public Result { | 295 class NavigationResult : public Result { |
276 public: | 296 public: |
277 // |provider| is necessary to use StringForURLDisplay() in order to | 297 // |provider| is necessary to use StringForURLDisplay() in order to |
278 // compute |formatted_url_|. | 298 // compute |formatted_url_|. |
279 NavigationResult(const AutocompleteProvider& provider, | 299 NavigationResult(const AutocompleteProvider& provider, |
280 const GURL& url, | 300 const GURL& url, |
(...skipping 25 matching lines...) Expand all Loading... | |
306 string16 description_; | 326 string16 description_; |
307 }; | 327 }; |
308 | 328 |
309 class CompareScoredResults; | 329 class CompareScoredResults; |
310 | 330 |
311 typedef std::vector<SuggestResult> SuggestResults; | 331 typedef std::vector<SuggestResult> SuggestResults; |
312 typedef std::vector<NavigationResult> NavigationResults; | 332 typedef std::vector<NavigationResult> NavigationResults; |
313 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; | 333 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; |
314 typedef std::pair<string16, std::string> MatchKey; | 334 typedef std::pair<string16, std::string> MatchKey; |
315 typedef std::map<MatchKey, AutocompleteMatch> MatchMap; | 335 typedef std::map<MatchKey, AutocompleteMatch> MatchMap; |
336 typedef ScopedVector<SuggestionDeletionHandler> SuggestionDeletionHandlers; | |
316 | 337 |
317 // A simple structure bundling most of the information (including | 338 // A simple structure bundling most of the information (including |
318 // both SuggestResults and NavigationResults) returned by a call to | 339 // both SuggestResults and NavigationResults) returned by a call to |
319 // the suggest server. | 340 // the suggest server. |
320 // | 341 // |
321 // This has to be declared after the typedefs since it relies on some of them. | 342 // This has to be declared after the typedefs since it relies on some of them. |
322 struct Results { | 343 struct Results { |
323 Results(); | 344 Results(); |
324 ~Results(); | 345 ~Results(); |
325 | 346 |
(...skipping 16 matching lines...) Expand all Loading... | |
342 // suppresses the verbatim result. | 363 // suppresses the verbatim result. |
343 int verbatim_relevance; | 364 int verbatim_relevance; |
344 | 365 |
345 // The JSON metadata associated with this server response. | 366 // The JSON metadata associated with this server response. |
346 std::string metadata; | 367 std::string metadata; |
347 | 368 |
348 private: | 369 private: |
349 DISALLOW_COPY_AND_ASSIGN(Results); | 370 DISALLOW_COPY_AND_ASSIGN(Results); |
350 }; | 371 }; |
351 | 372 |
352 virtual ~SearchProvider(); | |
353 | |
354 // Removes non-inlineable results until either the top result can inline | 373 // Removes non-inlineable results until either the top result can inline |
355 // autocomplete the current input or verbatim outscores the top result. | 374 // autocomplete the current input or verbatim outscores the top result. |
356 static void RemoveStaleResults(const string16& input, | 375 static void RemoveStaleResults(const string16& input, |
357 int verbatim_relevance, | 376 int verbatim_relevance, |
358 SuggestResults* suggest_results, | 377 SuggestResults* suggest_results, |
359 NavigationResults* navigation_results); | 378 NavigationResults* navigation_results); |
360 | 379 |
361 // Calculates the relevance score for the keyword verbatim result (if the | 380 // Calculates the relevance score for the keyword verbatim result (if the |
362 // input matches one of the profile's keyword). | 381 // input matches one of the profile's keyword). |
363 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, | 382 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, |
364 bool prefer_keyword); | 383 bool prefer_keyword); |
365 | 384 |
366 // AutocompleteProvider: | 385 // AutocompleteProvider: |
367 virtual void Start(const AutocompleteInput& input, | 386 virtual void Start(const AutocompleteInput& input, |
368 bool minimal_changes) OVERRIDE; | 387 bool minimal_changes) OVERRIDE; |
369 virtual void Stop(bool clear_cached_results) OVERRIDE; | 388 virtual void Stop(bool clear_cached_results) OVERRIDE; |
370 | 389 |
371 // net::URLFetcherDelegate: | 390 // net::URLFetcherDelegate: |
372 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 391 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
373 | 392 |
393 // This gets called when we have requested a suggestion deletion from the | |
394 // server to handle the results of the deletion. | |
395 void OnDeletionComplete(bool success, | |
396 SuggestionDeletionHandler* handler); | |
397 | |
398 // Records in UMA whether the deletion request resulted in success. | |
Peter Kasting
2013/12/03 00:33:51
Nit: Maybe add "This is virtual so test code can o
Peter Kasting
2013/12/03 01:47:50
Did you decide this wasn't worth doing?
Maria
2013/12/03 01:55:20
Done.
| |
399 virtual void RecordDeletionResult(bool success); | |
400 | |
401 // Removes the deleted match from the list of |matches_|. | |
402 void DeleteMatchFromMatches(const AutocompleteMatch& match); | |
403 | |
374 // Called when timer_ expires. | 404 // Called when timer_ expires. |
375 void Run(); | 405 void Run(); |
376 | 406 |
377 // Runs the history query, if necessary. The history query is synchronous. | 407 // Runs the history query, if necessary. The history query is synchronous. |
378 // This does not update |done_|. | 408 // This does not update |done_|. |
379 void DoHistoryQuery(bool minimal_changes); | 409 void DoHistoryQuery(bool minimal_changes); |
380 | 410 |
381 // Determines whether an asynchronous subcomponent query should run for the | 411 // Determines whether an asynchronous subcomponent query should run for the |
382 // current input. If so, starts it if necessary; otherwise stops it. | 412 // current input. If so, starts it if necessary; otherwise stops it. |
383 // NOTE: This function does not update |done_|. Callers must do so. | 413 // NOTE: This function does not update |done_|. Callers must do so. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 | 510 |
481 // Calculates the relevance score for the verbatim result from the default | 511 // Calculates the relevance score for the verbatim result from the default |
482 // search engine *ignoring* whether the input is a keyword-based search | 512 // search engine *ignoring* whether the input is a keyword-based search |
483 // or not. This function should only be used to determine the minimum | 513 // or not. This function should only be used to determine the minimum |
484 // relevance score that the best result from this provider should have. | 514 // relevance score that the best result from this provider should have. |
485 // For normal use, prefer the above function. | 515 // For normal use, prefer the above function. |
486 int CalculateRelevanceForVerbatimIgnoringKeywordModeState() const; | 516 int CalculateRelevanceForVerbatimIgnoringKeywordModeState() const; |
487 | 517 |
488 // Gets the relevance score for the keyword verbatim result. | 518 // Gets the relevance score for the keyword verbatim result. |
489 // |relevance_from_server| is handled as in GetVerbatimRelevance(). | 519 // |relevance_from_server| is handled as in GetVerbatimRelevance(). |
490 // TODO(mpearson): Refactor so this duplication isn't necesary or | 520 // TODO(mpearson): Refactor so this duplication isn't necessary or |
491 // restructure so one static function takes all the parameters it needs | 521 // restructure so one static function takes all the parameters it needs |
492 // (rather than looking at internal state). | 522 // (rather than looking at internal state). |
493 int GetKeywordVerbatimRelevance(bool* relevance_from_server) const; | 523 int GetKeywordVerbatimRelevance(bool* relevance_from_server) const; |
494 | 524 |
495 // |time| is the time at which this query was last seen. |is_keyword| | 525 // |time| is the time at which this query was last seen. |is_keyword| |
496 // indicates whether the results correspond to the keyword provider or default | 526 // indicates whether the results correspond to the keyword provider or default |
497 // provider. |use_aggressive_method| says whether this function can use a | 527 // provider. |use_aggressive_method| says whether this function can use a |
498 // method that gives high scores (1200+) rather than one that gives lower | 528 // method that gives high scores (1200+) rather than one that gives lower |
499 // scores. When using the aggressive method, scores may exceed 1300 | 529 // scores. When using the aggressive method, scores may exceed 1300 |
500 // unless |prevent_search_history_inlining| is set. | 530 // unless |prevent_search_history_inlining| is set. |
(...skipping 10 matching lines...) Expand all Loading... | |
511 bool relevance_from_server, | 541 bool relevance_from_server, |
512 bool should_prefetch, | 542 bool should_prefetch, |
513 const std::string& metadata, | 543 const std::string& metadata, |
514 AutocompleteMatch::Type type, | 544 AutocompleteMatch::Type type, |
515 bool is_keyword, | 545 bool is_keyword, |
516 const string16& match_contents, | 546 const string16& match_contents, |
517 const string16& annotation, | 547 const string16& annotation, |
518 const string16& query_string, | 548 const string16& query_string, |
519 int accepted_suggestion, | 549 int accepted_suggestion, |
520 const std::string& suggest_query_params, | 550 const std::string& suggest_query_params, |
551 const std::string& deletion_url, | |
521 MatchMap* map); | 552 MatchMap* map); |
522 | 553 |
523 // Returns an AutocompleteMatch for a navigational suggestion. | 554 // Returns an AutocompleteMatch for a navigational suggestion. |
524 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); | 555 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); |
525 | 556 |
526 // Resets the scores of all |keyword_navigation_results_| matches to | 557 // Resets the scores of all |keyword_navigation_results_| matches to |
527 // be below that of the top keyword query match (the verbatim match | 558 // be below that of the top keyword query match (the verbatim match |
528 // as expressed by |keyword_verbatim_relevance_| or keyword query | 559 // as expressed by |keyword_verbatim_relevance_| or keyword query |
529 // suggestions stored in |keyword_suggest_results_|). If there | 560 // suggestions stored in |keyword_suggest_results_|). If there |
530 // are no keyword suggestions and keyword verbatim is suppressed, | 561 // are no keyword suggestions and keyword verbatim is suppressed, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 // were server-provided using this key in the |additional_info| field. | 606 // were server-provided using this key in the |additional_info| field. |
576 static const char kRelevanceFromServerKey[]; | 607 static const char kRelevanceFromServerKey[]; |
577 | 608 |
578 // Indicates whether the server said a match should be prefetched. | 609 // Indicates whether the server said a match should be prefetched. |
579 static const char kShouldPrefetchKey[]; | 610 static const char kShouldPrefetchKey[]; |
580 | 611 |
581 // Used to store metadata from the server response, which is needed for | 612 // Used to store metadata from the server response, which is needed for |
582 // prefetching. | 613 // prefetching. |
583 static const char kSuggestMetadataKey[]; | 614 static const char kSuggestMetadataKey[]; |
584 | 615 |
616 // Used to store a deletion request url for server-provided suggestions. | |
617 static const char kDeletionUrlKey[]; | |
618 | |
585 // These are the values for the above keys. | 619 // These are the values for the above keys. |
586 static const char kTrue[]; | 620 static const char kTrue[]; |
587 static const char kFalse[]; | 621 static const char kFalse[]; |
588 | 622 |
589 // Maintains the TemplateURLs used. | 623 // Maintains the TemplateURLs used. |
590 Providers providers_; | 624 Providers providers_; |
591 | 625 |
592 // The user's input. | 626 // The user's input. |
593 AutocompleteInput input_; | 627 AutocompleteInput input_; |
594 | 628 |
(...skipping 16 matching lines...) Expand all Loading... | |
611 base::TimeTicks time_suggest_request_sent_; | 645 base::TimeTicks time_suggest_request_sent_; |
612 | 646 |
613 // Fetchers used to retrieve results for the keyword and default providers. | 647 // Fetchers used to retrieve results for the keyword and default providers. |
614 scoped_ptr<net::URLFetcher> keyword_fetcher_; | 648 scoped_ptr<net::URLFetcher> keyword_fetcher_; |
615 scoped_ptr<net::URLFetcher> default_fetcher_; | 649 scoped_ptr<net::URLFetcher> default_fetcher_; |
616 | 650 |
617 // Results from the default and keyword search providers. | 651 // Results from the default and keyword search providers. |
618 Results default_results_; | 652 Results default_results_; |
619 Results keyword_results_; | 653 Results keyword_results_; |
620 | 654 |
655 // Each deletion handler in this vector corresponds to an outstanding request | |
656 // that a server delete a personalized suggestion. Making this a ScopedVector | |
657 // causes us to auto-cancel all such requests on shutdown. | |
658 SuggestionDeletionHandlers deletion_handlers_; | |
659 | |
621 // Whether a field trial, if any, has triggered in the most recent | 660 // Whether a field trial, if any, has triggered in the most recent |
622 // autocomplete query. This field is set to false in Start() and may be set | 661 // autocomplete query. This field is set to false in Start() and may be set |
623 // to true if either the default provider or keyword provider has completed | 662 // to true if either the default provider or keyword provider has completed |
624 // and their corresponding suggest response contained | 663 // and their corresponding suggest response contained |
625 // '"google:fieldtrialtriggered":true'. | 664 // '"google:fieldtrialtriggered":true'. |
626 // If the autocomplete query has not returned, this field is set to false. | 665 // If the autocomplete query has not returned, this field is set to false. |
627 bool field_trial_triggered_; | 666 bool field_trial_triggered_; |
628 | 667 |
629 // Same as above except that it is maintained across the current Omnibox | 668 // Same as above except that it is maintained across the current Omnibox |
630 // session. | 669 // session. |
631 bool field_trial_triggered_in_session_; | 670 bool field_trial_triggered_in_session_; |
632 | 671 |
633 // If true, search history query suggestions will score low enough that | 672 // If true, search history query suggestions will score low enough that |
634 // they will not be inlined. | 673 // they will not be inlined. |
635 bool prevent_search_history_inlining_; | 674 bool prevent_search_history_inlining_; |
636 | 675 |
637 GURL current_page_url_; | 676 GURL current_page_url_; |
638 | 677 |
639 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 678 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
640 }; | 679 }; |
641 | 680 |
642 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 681 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |