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

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: Comments and parens. 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 the match begins immediately after one of the prefixes in
101 // 2a) the first match starts at the beginning of the candidate URL, OR 101 // URLPrefix such as http://www and https:// (note that one of these
102 // 2b) the candidate URL starts with one of the standard URL prefixes with 102 // is the empty prefix, for cases where the user has typed the scheme)
103 // the URL match immediately following that prefix.
104 // 3) AND the search string does not end in whitespace (making it look to 103 // 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 104 // the IMUI as though there is a single search term when actually there
106 // is a second, empty term). 105 // is a second, empty term).
107 can_inline = !url_matches.empty() && 106 // |best_prefix| stores the inlineable prefix computed in clause (2) or
108 terms.size() == 1 && 107 // NULL if no such prefix exists. (The URL is not inlineable.)
109 (url_matches[0].offset == 0 || 108 const URLPrefix* best_prefix = (!url_matches.empty() && (terms.size() == 1)) ?
110 URLPrefix::IsURLPrefix(url.substr(0, url_matches[0].offset))) && 109 URLPrefix::BestURLPrefix(UTF8ToUTF16(gurl.spec()), terms[0]) : NULL;
111 !IsWhitespace(*(lower_string.rbegin())); 110 can_inline = (best_prefix != NULL) && !IsWhitespace(*(lower_string.rbegin()));
112 match_in_scheme = can_inline && url_matches[0].offset == 0; 111 match_in_scheme = can_inline && best_prefix->prefix.empty();
113 112
114 // Determine if the associated URLs is referenced by any bookmarks. 113 // Determine if the associated URLs is referenced by any bookmarks.
115 float bookmark_boost = 114 float bookmark_boost =
116 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0; 115 (bookmark_service && bookmark_service->IsBookmarked(gurl)) ? 10.0 : 0.0;
117 116
118 if (use_new_scoring) { 117 if (use_new_scoring) {
119 const float topicality_score = GetTopicalityScore( 118 const float topicality_score = GetTopicalityScore(
120 terms.size(), url, url_matches, title_matches, word_starts); 119 terms.size(), url, url_matches, title_matches, word_starts);
121 const float recency_score = GetRecencyScore( 120 const float recency_score = GetRecencyScore(
122 (now - row.last_visit()).InDays()); 121 (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 530 // 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 531 // 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. 532 // a histogram, where the bucket represents the user's new scoring state.
534 UMA_HISTOGRAM_ENUMERATION( 533 UMA_HISTOGRAM_ENUMERATION(
535 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon", 534 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon",
536 new_scoring_option, NUM_OPTIONS); 535 new_scoring_option, NUM_OPTIONS);
537 536
538 } 537 }
539 538
540 } // namespace history 539 } // 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