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

Side by Side Diff: chrome/browser/history/scored_history_match.cc

Issue 10907176: Omnibox: Fix HistoryQuick provider can_inline bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revise comment. Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/history/scored_history_match_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/history/scored_history_match.h" 5 #include "chrome/browser/history/scored_history_match.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 #include <numeric> 10 #include <numeric>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // TODO(mpearson): Investigate whether this has any meaningful 90 // TODO(mpearson): Investigate whether this has any meaningful
91 // effect on scoring. (It's necessary at some point: removing 91 // effect on scoring. (It's necessary at some point: removing
92 // overlaps and sorting is needed to decide what to highlight in the 92 // overlaps and sorting is needed to decide what to highlight in the
93 // suggestion string. But this sort and de-overlap doesn't have to 93 // suggestion string. But this sort and de-overlap doesn't have to
94 // be done before scoring.) 94 // be done before scoring.)
95 url_matches = SortAndDeoverlapMatches(url_matches); 95 url_matches = SortAndDeoverlapMatches(url_matches);
96 title_matches = SortAndDeoverlapMatches(title_matches); 96 title_matches = SortAndDeoverlapMatches(title_matches);
97 97
98 // We can inline autocomplete a result if: 98 // We can inline autocomplete a result if:
99 // 1) there is only one search term 99 // 1) there is only one search term
100 // 2) AND EITHER: 100 // 2) AND a match begins immediately after a droppabled (inlineable)
Peter Kasting 2012/09/11 17:52:50 Nit: droppabled?
Mark P 2012/09/11 21:52:17 Not sure if you wanted me to fix the word (drop ty
101 // 2a) the first match starts at the beginning of the candidate URL, OR 101 // prefix such as http://www or https://
102 // 2b) the candidate URL starts with one of the standard URL prefixes with
103 // the URL match immediately following that prefix.
104 // 3) AND the search string does not end in whitespace (making it look to 102 // 3) AND the search string does not end in whitespace (making it look to
105 // the IMUI as though there is a single search term when actually there 103 // the IMUI as though there is a single search term when actually there
106 // is a second, empty term). 104 // is a second, empty term).
105 // |best_prefix| stores the inlineable prefix computed in clause (2) or
106 // NULL if no such prefix exists. (The URL is not inlineable.)
107 const URLPrefix* best_prefix = NULL;
mrossetti 2012/09/11 17:36:10 I'm okay with doing the assignment within the cond
Peter Kasting 2012/09/11 17:52:50 I dislike assignments inside conditionals, so I'm
Mark P 2012/09/11 21:52:17 Took your suggestion (with a bit more explicit log
Mark P 2012/09/11 21:52:17 I don't like them either, but I've seen enough Chr
107 can_inline = !url_matches.empty() && 108 can_inline = !url_matches.empty() &&
108 terms.size() == 1 && 109 terms.size() == 1 &&
109 (url_matches[0].offset == 0 || 110 ((best_prefix = URLPrefix::
110 URLPrefix::IsURLPrefix(url.substr(0, url_matches[0].offset))) && 111 BestURLPrefix(UTF8ToUTF16(gurl.spec()), terms[0])) != NULL) &&
111 !IsWhitespace(*(lower_string.rbegin())); 112 !IsWhitespace(*(lower_string.rbegin()));
112 match_in_scheme = can_inline && url_matches[0].offset == 0; 113 match_in_scheme = can_inline && (best_prefix->prefix.length() == 0);
113 114
114 // Determine if the associated URLs is referenced by any bookmarks. 115 // Determine if the associated URLs is referenced by any bookmarks.
115 float bookmark_boost = 116 float bookmark_boost =
116 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0; 117 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0;
117 118
118 if (use_new_scoring) { 119 if (use_new_scoring) {
119 const float topicality_score = GetTopicalityScore( 120 const float topicality_score = GetTopicalityScore(
120 terms.size(), url, url_matches, title_matches, word_starts); 121 terms.size(), url, url_matches, title_matches, word_starts);
121 const float recency_score = GetRecencyScore( 122 const float recency_score = GetRecencyScore(
122 (now - row.last_visit()).InDays()); 123 (now - row.last_visit()).InDays());
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Add a beacon to the logs that'll allow us to identify later what 532 // Add a beacon to the logs that'll allow us to identify later what
532 // new scoring state a user is in. Do this by incrementing a bucket in 533 // new scoring state a user is in. Do this by incrementing a bucket in
533 // a histogram, where the bucket represents the user's new scoring state. 534 // a histogram, where the bucket represents the user's new scoring state.
534 UMA_HISTOGRAM_ENUMERATION( 535 UMA_HISTOGRAM_ENUMERATION(
535 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon", 536 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon",
536 new_scoring_option, NUM_OPTIONS); 537 new_scoring_option, NUM_OPTIONS);
537 538
538 } 539 }
539 540
540 } // namespace history 541 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/scored_history_match_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698