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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 public: | 208 public: |
209 SuggestResult(const base::string16& suggestion, | 209 SuggestResult(const base::string16& suggestion, |
210 AutocompleteMatchType::Type type, | 210 AutocompleteMatchType::Type type, |
211 const base::string16& match_contents, | 211 const base::string16& match_contents, |
212 const base::string16& annotation, | 212 const base::string16& annotation, |
213 const std::string& suggest_query_params, | 213 const std::string& suggest_query_params, |
214 const std::string& deletion_url, | 214 const std::string& deletion_url, |
215 bool from_keyword_provider, | 215 bool from_keyword_provider, |
216 int relevance, | 216 int relevance, |
217 bool relevance_from_server, | 217 bool relevance_from_server, |
218 bool should_prefetch); | 218 bool should_prefetch, |
219 const base::string16& input_text); | |
Anuj
2014/01/06 23:23:38
I will prefer input_text as the first parameter.
Mark P
2014/01/07 19:10:31
The important thing in SuggestResult is the sugges
| |
219 virtual ~SuggestResult(); | 220 virtual ~SuggestResult(); |
220 | 221 |
221 const base::string16& suggestion() const { return suggestion_; } | 222 const base::string16& suggestion() const { return suggestion_; } |
222 AutocompleteMatchType::Type type() const { return type_; } | 223 AutocompleteMatchType::Type type() const { return type_; } |
223 const base::string16& match_contents() const { return match_contents_; } | 224 const base::string16& match_contents() const { return match_contents_; } |
225 const ACMatchClassifications& match_contents_class() const { | |
226 return match_contents_class_; | |
227 } | |
224 const base::string16& annotation() const { return annotation_; } | 228 const base::string16& annotation() const { return annotation_; } |
225 const std::string& suggest_query_params() const { | 229 const std::string& suggest_query_params() const { |
226 return suggest_query_params_; | 230 return suggest_query_params_; |
227 } | 231 } |
228 const std::string& deletion_url() const { return deletion_url_; } | 232 const std::string& deletion_url() const { return deletion_url_; } |
229 bool should_prefetch() const { return should_prefetch_; } | 233 bool should_prefetch() const { return should_prefetch_; } |
230 | 234 |
235 // Fills in |match_contents_class| to reflect how |match_contents_| should | |
236 // be displayed and bolded against the current |input_text|. If | |
237 // |allow_bolding_all| is false and |match_contents_class_| would have all | |
238 // of |match_contents_| bolded, do nothing. | |
239 void CalculateContentsClass(const bool allow_bolding_all, | |
240 const base::string16& input_text); | |
241 | |
231 // Result: | 242 // Result: |
232 virtual bool IsInlineable(const base::string16& input) const OVERRIDE; | 243 virtual bool IsInlineable(const base::string16& input) const OVERRIDE; |
233 virtual int CalculateRelevance( | 244 virtual int CalculateRelevance( |
234 const AutocompleteInput& input, | 245 const AutocompleteInput& input, |
235 bool keyword_provider_requested) const OVERRIDE; | 246 bool keyword_provider_requested) const OVERRIDE; |
236 | 247 |
237 private: | 248 private: |
238 // The search terms to be used for this suggestion. | 249 // The search terms to be used for this suggestion. |
239 base::string16 suggestion_; | 250 base::string16 suggestion_; |
240 | 251 |
241 AutocompleteMatchType::Type type_; | 252 AutocompleteMatchType::Type type_; |
242 | 253 |
243 // The contents to be displayed in the autocomplete match. | 254 // The contents to be displayed and its style info. |
244 base::string16 match_contents_; | 255 base::string16 match_contents_; |
256 ACMatchClassifications match_contents_class_; | |
245 | 257 |
246 // Optional annotation for the |match_contents_| for disambiguation. | 258 // Optional annotation for the |match_contents_| for disambiguation. |
247 // This may be displayed in the autocomplete match contents, but is defined | 259 // This may be displayed in the autocomplete match contents, but is defined |
248 // separately to facilitate different formatting. | 260 // separately to facilitate different formatting. |
249 base::string16 annotation_; | 261 base::string16 annotation_; |
250 | 262 |
251 // Optional additional parameters to be added to the search URL. | 263 // Optional additional parameters to be added to the search URL. |
252 std::string suggest_query_params_; | 264 std::string suggest_query_params_; |
253 | 265 |
254 // Optional deletion URL provided with suggestions. Fetching this URL | 266 // Optional deletion URL provided with suggestions. Fetching this URL |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 int omnibox_start_margin, | 375 int omnibox_start_margin, |
364 bool append_extra_query_params); | 376 bool append_extra_query_params); |
365 | 377 |
366 // Removes non-inlineable results until either the top result can inline | 378 // Removes non-inlineable results until either the top result can inline |
367 // autocomplete the current input or verbatim outscores the top result. | 379 // autocomplete the current input or verbatim outscores the top result. |
368 static void RemoveStaleResults(const base::string16& input, | 380 static void RemoveStaleResults(const base::string16& input, |
369 int verbatim_relevance, | 381 int verbatim_relevance, |
370 SuggestResults* suggest_results, | 382 SuggestResults* suggest_results, |
371 NavigationResults* navigation_results); | 383 NavigationResults* navigation_results); |
372 | 384 |
385 // Recalculates the match contents class of |suggest_results| to better | |
386 // display against the current input. | |
387 static void RecalculateMatchContentsClass(const base::string16& input_text, | |
Anuj
2014/01/06 23:23:38
Minor suggestion : Rename to UpdateMatchContentsCl
Mark P
2014/01/07 19:10:31
Yeah, that's better. Done.
| |
388 SuggestResults* suggest_results); | |
389 | |
373 // Calculates the relevance score for the keyword verbatim result (if the | 390 // Calculates the relevance score for the keyword verbatim result (if the |
374 // input matches one of the profile's keyword). | 391 // input matches one of the profile's keyword). |
375 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, | 392 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, |
376 bool prefer_keyword); | 393 bool prefer_keyword); |
377 | 394 |
378 // AutocompleteProvider: | 395 // AutocompleteProvider: |
379 virtual void Start(const AutocompleteInput& input, | 396 virtual void Start(const AutocompleteInput& input, |
380 bool minimal_changes) OVERRIDE; | 397 bool minimal_changes) OVERRIDE; |
381 virtual void Stop(bool clear_cached_results) OVERRIDE; | 398 virtual void Stop(bool clear_cached_results) OVERRIDE; |
382 | 399 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 // If true, search history query suggestions will score low enough that | 680 // If true, search history query suggestions will score low enough that |
664 // they will not be inlined. | 681 // they will not be inlined. |
665 bool prevent_search_history_inlining_; | 682 bool prevent_search_history_inlining_; |
666 | 683 |
667 GURL current_page_url_; | 684 GURL current_page_url_; |
668 | 685 |
669 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 686 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
670 }; | 687 }; |
671 | 688 |
672 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 689 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |