Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/autocomplete/search_provider.h

Issue 23164011: Omnibox: Reduce Bolding Flicker in SearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish edit case Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
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 {
msw 2014/01/06 21:09:00 nit: consider match_classifications_ or match_clas
Mark P 2014/01/06 22:20:16 I'd prefer to keep the name that corresponds to th
msw 2014/01/06 22:50:21 okay
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,
msw 2014/01/06 21:09:00 nit: consider "Calculate[Match]Classifications".
Mark P 2014/01/06 22:20:16 see comment above.
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 in the autocomplete match, and its style
msw 2014/01/06 21:09:00 nit: remove "in the autocomplete match"
Mark P 2014/01/06 22:20:16 Done.
255 // info.
244 base::string16 match_contents_; 256 base::string16 match_contents_;
257 ACMatchClassifications match_contents_class_;
245 258
246 // Optional annotation for the |match_contents_| for disambiguation. 259 // Optional annotation for the |match_contents_| for disambiguation.
247 // This may be displayed in the autocomplete match contents, but is defined 260 // This may be displayed in the autocomplete match contents, but is defined
248 // separately to facilitate different formatting. 261 // separately to facilitate different formatting.
249 base::string16 annotation_; 262 base::string16 annotation_;
250 263
251 // Optional additional parameters to be added to the search URL. 264 // Optional additional parameters to be added to the search URL.
252 std::string suggest_query_params_; 265 std::string suggest_query_params_;
253 266
254 // Optional deletion URL provided with suggestions. Fetching this URL 267 // Optional deletion URL provided with suggestions. Fetching this URL
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 int omnibox_start_margin, 376 int omnibox_start_margin,
364 bool append_extra_query_params); 377 bool append_extra_query_params);
365 378
366 // Removes non-inlineable results until either the top result can inline 379 // Removes non-inlineable results until either the top result can inline
367 // autocomplete the current input or verbatim outscores the top result. 380 // autocomplete the current input or verbatim outscores the top result.
368 static void RemoveStaleResults(const base::string16& input, 381 static void RemoveStaleResults(const base::string16& input,
369 int verbatim_relevance, 382 int verbatim_relevance,
370 SuggestResults* suggest_results, 383 SuggestResults* suggest_results,
371 NavigationResults* navigation_results); 384 NavigationResults* navigation_results);
372 385
386 // For every result in |suggest_results|, call CalculateContentsClass(),
msw 2014/01/06 21:09:00 nit: consider "Recalculates the match contents and
Mark P 2014/01/06 22:20:16 Shortened it much like you suggested. In the proc
387 // which may replace its contents and bolding to better display against the
388 // current input.
389 static void RecalculateBolding(const base::string16& input_text,
msw 2014/01/06 21:09:00 nit: consider "Recalculate[Match]Classifications"
Mark P 2014/01/06 22:20:16 Good point. Changed to RecalculateMatchContentsCl
390 SuggestResults* suggest_results);
391
373 // Calculates the relevance score for the keyword verbatim result (if the 392 // Calculates the relevance score for the keyword verbatim result (if the
374 // input matches one of the profile's keyword). 393 // input matches one of the profile's keyword).
375 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, 394 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type,
376 bool prefer_keyword); 395 bool prefer_keyword);
377 396
378 // AutocompleteProvider: 397 // AutocompleteProvider:
379 virtual void Start(const AutocompleteInput& input, 398 virtual void Start(const AutocompleteInput& input,
380 bool minimal_changes) OVERRIDE; 399 bool minimal_changes) OVERRIDE;
381 virtual void Stop(bool clear_cached_results) OVERRIDE; 400 virtual void Stop(bool clear_cached_results) OVERRIDE;
382 401
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // If true, search history query suggestions will score low enough that 682 // If true, search history query suggestions will score low enough that
664 // they will not be inlined. 683 // they will not be inlined.
665 bool prevent_search_history_inlining_; 684 bool prevent_search_history_inlining_;
666 685
667 GURL current_page_url_; 686 GURL current_page_url_;
668 687
669 DISALLOW_COPY_AND_ASSIGN(SearchProvider); 688 DISALLOW_COPY_AND_ASSIGN(SearchProvider);
670 }; 689 };
671 690
672 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ 691 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | chrome/browser/autocomplete/search_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698