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

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: Reply to comments. 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 implicit / inlineable
Peter Kasting 2012/09/11 21:57:48 Nit: a -> an, but maybe this would be clearer as "
Mark P 2012/09/11 22:05:00 I like your suggestion a lot. I took it entirely
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).
107 can_inline = !url_matches.empty() && 105 // |best_prefix| stores the inlineable prefix computed in clause (2) or
108 terms.size() == 1 && 106 // NULL if no such prefix exists. (The URL is not inlineable.)
109 (url_matches[0].offset == 0 || 107 const URLPrefix* best_prefix = (!url_matches.empty()) && (terms.size() == 1) ?
Peter Kasting 2012/09/11 21:57:48 Nit: No need for parens around unary expression --
Mark P 2012/09/11 22:05:00 Rearranged parens.
110 URLPrefix::IsURLPrefix(url.substr(0, url_matches[0].offset))) && 108 URLPrefix::BestURLPrefix(UTF8ToUTF16(gurl.spec()), terms[0]) : NULL;
111 !IsWhitespace(*(lower_string.rbegin())); 109 can_inline = (best_prefix != NULL) && !IsWhitespace(*(lower_string.rbegin()));
112 match_in_scheme = can_inline && url_matches[0].offset == 0; 110 match_in_scheme = can_inline && best_prefix->prefix.empty();
113 111
114 // Determine if the associated URLs is referenced by any bookmarks. 112 // Determine if the associated URLs is referenced by any bookmarks.
115 float bookmark_boost = 113 float bookmark_boost =
116 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0; 114 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0;
117 115
118 if (use_new_scoring) { 116 if (use_new_scoring) {
119 const float topicality_score = GetTopicalityScore( 117 const float topicality_score = GetTopicalityScore(
120 terms.size(), url, url_matches, title_matches, word_starts); 118 terms.size(), url, url_matches, title_matches, word_starts);
121 const float recency_score = GetRecencyScore( 119 const float recency_score = GetRecencyScore(
122 (now - row.last_visit()).InDays()); 120 (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 529 // 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 530 // 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. 531 // a histogram, where the bucket represents the user's new scoring state.
534 UMA_HISTOGRAM_ENUMERATION( 532 UMA_HISTOGRAM_ENUMERATION(
535 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon", 533 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon",
536 new_scoring_option, NUM_OPTIONS); 534 new_scoring_option, NUM_OPTIONS);
537 535
538 } 536 }
539 537
540 } // namespace history 538 } // 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