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 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // based on server information, and thus is assumed to be more accurate. | 233 // based on server information, and thus is assumed to be more accurate. |
234 // This is ultimately used in | 234 // This is ultimately used in |
235 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments | 235 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments |
236 // there. | 236 // there. |
237 bool relevance_from_server_; | 237 bool relevance_from_server_; |
238 }; | 238 }; |
239 | 239 |
240 class SuggestResult : public Result { | 240 class SuggestResult : public Result { |
241 public: | 241 public: |
242 SuggestResult(const base::string16& suggestion, | 242 SuggestResult(const base::string16& suggestion, |
| 243 AutocompleteMatchType::Type type, |
243 const base::string16& match_contents, | 244 const base::string16& match_contents, |
244 const base::string16& annotation, | 245 const base::string16& annotation, |
245 const std::string& suggest_query_params, | 246 const std::string& suggest_query_params, |
246 const std::string& deletion_url, | 247 const std::string& deletion_url, |
247 bool from_keyword_provider, | 248 bool from_keyword_provider, |
248 int relevance, | 249 int relevance, |
249 bool relevance_from_server, | 250 bool relevance_from_server, |
250 bool should_prefetch); | 251 bool should_prefetch); |
251 virtual ~SuggestResult(); | 252 virtual ~SuggestResult(); |
252 | 253 |
253 const base::string16& suggestion() const { return suggestion_; } | 254 const base::string16& suggestion() const { return suggestion_; } |
| 255 AutocompleteMatchType::Type type() const { return type_; } |
254 const base::string16& match_contents() const { return match_contents_; } | 256 const base::string16& match_contents() const { return match_contents_; } |
255 const base::string16& annotation() const { return annotation_; } | 257 const base::string16& annotation() const { return annotation_; } |
256 const std::string& suggest_query_params() const { | 258 const std::string& suggest_query_params() const { |
257 return suggest_query_params_; | 259 return suggest_query_params_; |
258 } | 260 } |
259 const std::string& deletion_url() const { return deletion_url_; } | 261 const std::string& deletion_url() const { return deletion_url_; } |
260 bool should_prefetch() const { return should_prefetch_; } | 262 bool should_prefetch() const { return should_prefetch_; } |
261 | 263 |
262 // Result: | 264 // Result: |
263 virtual bool IsInlineable(const base::string16& input) const OVERRIDE; | 265 virtual bool IsInlineable(const base::string16& input) const OVERRIDE; |
264 virtual int CalculateRelevance( | 266 virtual int CalculateRelevance( |
265 const AutocompleteInput& input, | 267 const AutocompleteInput& input, |
266 bool keyword_provider_requested) const OVERRIDE; | 268 bool keyword_provider_requested) const OVERRIDE; |
267 | 269 |
268 private: | 270 private: |
269 // The search terms to be used for this suggestion. | 271 // The search terms to be used for this suggestion. |
270 base::string16 suggestion_; | 272 base::string16 suggestion_; |
271 | 273 |
| 274 AutocompleteMatchType::Type type_; |
| 275 |
272 // The contents to be displayed in the autocomplete match. | 276 // The contents to be displayed in the autocomplete match. |
273 base::string16 match_contents_; | 277 base::string16 match_contents_; |
274 | 278 |
275 // Optional annotation for the |match_contents_| for disambiguation. | 279 // Optional annotation for the |match_contents_| for disambiguation. |
276 // This may be displayed in the autocomplete match contents, but is defined | 280 // This may be displayed in the autocomplete match contents, but is defined |
277 // separately to facilitate different formatting. | 281 // separately to facilitate different formatting. |
278 base::string16 annotation_; | 282 base::string16 annotation_; |
279 | 283 |
280 // Optional additional parameters to be added to the search URL. | 284 // Optional additional parameters to be added to the search URL. |
281 std::string suggest_query_params_; | 285 std::string suggest_query_params_; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 bool is_keyword, | 540 bool is_keyword, |
537 bool use_aggressive_method, | 541 bool use_aggressive_method, |
538 bool prevent_search_history_inlining) const; | 542 bool prevent_search_history_inlining) const; |
539 | 543 |
540 // Creates an AutocompleteMatch for "Search <engine> for |query_string|" with | 544 // Creates an AutocompleteMatch for "Search <engine> for |query_string|" with |
541 // the supplied details. Adds this match to |map|; if such a match already | 545 // the supplied details. Adds this match to |map|; if such a match already |
542 // exists, whichever one has lower relevance is eliminated. | 546 // exists, whichever one has lower relevance is eliminated. |
543 void AddMatchToMap(const SuggestResult& result, | 547 void AddMatchToMap(const SuggestResult& result, |
544 const base::string16& input_text, | 548 const base::string16& input_text, |
545 const std::string& metadata, | 549 const std::string& metadata, |
546 AutocompleteMatch::Type type, | |
547 int accepted_suggestion, | 550 int accepted_suggestion, |
548 MatchMap* map); | 551 MatchMap* map); |
549 | 552 |
550 // Returns an AutocompleteMatch for a navigational suggestion. | 553 // Returns an AutocompleteMatch for a navigational suggestion. |
551 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); | 554 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); |
552 | 555 |
553 // Resets the scores of all |keyword_navigation_results_| matches to | 556 // Resets the scores of all |keyword_navigation_results_| matches to |
554 // be below that of the top keyword query match (the verbatim match | 557 // be below that of the top keyword query match (the verbatim match |
555 // as expressed by |keyword_verbatim_relevance_| or keyword query | 558 // as expressed by |keyword_verbatim_relevance_| or keyword query |
556 // suggestions stored in |keyword_suggest_results_|). If there | 559 // suggestions stored in |keyword_suggest_results_|). If there |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 // If true, search history query suggestions will score low enough that | 671 // If true, search history query suggestions will score low enough that |
669 // they will not be inlined. | 672 // they will not be inlined. |
670 bool prevent_search_history_inlining_; | 673 bool prevent_search_history_inlining_; |
671 | 674 |
672 GURL current_page_url_; | 675 GURL current_page_url_; |
673 | 676 |
674 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 677 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
675 }; | 678 }; |
676 | 679 |
677 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 680 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |