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

Side by Side Diff: components/omnibox/browser/scored_history_match.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
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 "components/omnibox/browser/scored_history_match.h" 5 #include "components/omnibox/browser/scored_history_match.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Default HQP relevance buckets. See GetFinalRelevancyScore() 118 // Default HQP relevance buckets. See GetFinalRelevancyScore()
119 // for more details on these numbers. 119 // for more details on these numbers.
120 char ScoredHistoryMatch::hqp_relevance_buckets_str_[] = 120 char ScoredHistoryMatch::hqp_relevance_buckets_str_[] =
121 "0.0:400,1.5:600,5.0:900,10.5:1203,15.0:1300,20.0:1399"; 121 "0.0:400,1.5:600,5.0:900,10.5:1203,15.0:1300,20.0:1399";
122 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>* 122 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>*
123 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr; 123 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr;
124 124
125 ScoredHistoryMatch::ScoredHistoryMatch() 125 ScoredHistoryMatch::ScoredHistoryMatch()
126 : ScoredHistoryMatch(history::URLRow(), 126 : ScoredHistoryMatch(history::URLRow(),
127 VisitInfoVector(), 127 VisitInfoVector(),
128 std::string(),
129 base::string16(), 128 base::string16(),
130 String16Vector(), 129 String16Vector(),
131 WordStarts(), 130 WordStarts(),
132 RowWordStarts(), 131 RowWordStarts(),
133 false, 132 false,
134 nullptr, 133 nullptr,
135 base::Time::Max()) { 134 base::Time::Max()) {
136 } 135 }
137 136
138 ScoredHistoryMatch::ScoredHistoryMatch( 137 ScoredHistoryMatch::ScoredHistoryMatch(
139 const history::URLRow& row, 138 const history::URLRow& row,
140 const VisitInfoVector& visits, 139 const VisitInfoVector& visits,
141 const std::string& languages,
142 const base::string16& lower_string, 140 const base::string16& lower_string,
143 const String16Vector& terms_vector, 141 const String16Vector& terms_vector,
144 const WordStarts& terms_to_word_starts_offsets, 142 const WordStarts& terms_to_word_starts_offsets,
145 const RowWordStarts& word_starts, 143 const RowWordStarts& word_starts,
146 bool is_url_bookmarked, 144 bool is_url_bookmarked,
147 TemplateURLService* template_url_service, 145 TemplateURLService* template_url_service,
148 base::Time now) 146 base::Time now)
149 : HistoryMatch(row, 0, false, false), raw_score(0) { 147 : HistoryMatch(row, 0, false, false), raw_score(0) {
150 // NOTE: Call Init() before doing any validity checking to ensure that the 148 // NOTE: Call Init() before doing any validity checking to ensure that the
151 // class is always initialized after an instance has been constructed. In 149 // class is always initialized after an instance has been constructed. In
(...skipping 12 matching lines...) Expand all
164 template_url_service->GetDefaultSearchProvider() : nullptr; 162 template_url_service->GetDefaultSearchProvider() : nullptr;
165 if (template_url && 163 if (template_url &&
166 template_url->IsSearchURL(gurl, 164 template_url->IsSearchURL(gurl,
167 template_url_service->search_terms_data())) 165 template_url_service->search_terms_data()))
168 return; 166 return;
169 167
170 // Figure out where each search term appears in the URL and/or page title 168 // Figure out where each search term appears in the URL and/or page title
171 // so that we can score as well as provide autocomplete highlighting. 169 // so that we can score as well as provide autocomplete highlighting.
172 base::OffsetAdjuster::Adjustments adjustments; 170 base::OffsetAdjuster::Adjustments adjustments;
173 base::string16 url = 171 base::string16 url =
174 bookmarks::CleanUpUrlForMatching(gurl, languages, &adjustments); 172 bookmarks::CleanUpUrlForMatching(gurl, &adjustments);
175 base::string16 title = bookmarks::CleanUpTitleForMatching(row.title()); 173 base::string16 title = bookmarks::CleanUpTitleForMatching(row.title());
176 int term_num = 0; 174 int term_num = 0;
177 for (const auto& term : terms_vector) { 175 for (const auto& term : terms_vector) {
178 TermMatches url_term_matches = MatchTermInString(term, url, term_num); 176 TermMatches url_term_matches = MatchTermInString(term, url, term_num);
179 TermMatches title_term_matches = MatchTermInString(term, title, term_num); 177 TermMatches title_term_matches = MatchTermInString(term, title, term_num);
180 if (url_term_matches.empty() && title_term_matches.empty()) { 178 if (url_term_matches.empty() && title_term_matches.empty()) {
181 // A term was not found in either URL or title - reject. 179 // A term was not found in either URL or title - reject.
182 return; 180 return;
183 } 181 }
184 url_matches.insert(url_matches.end(), url_term_matches.begin(), 182 url_matches.insert(url_matches.end(), url_term_matches.begin(),
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 base::StringToDouble(it->first, &bucket.first); 727 base::StringToDouble(it->first, &bucket.first);
730 DCHECK(is_valid_intermediate_score); 728 DCHECK(is_valid_intermediate_score);
731 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); 729 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second);
732 DCHECK(is_valid_hqp_score); 730 DCHECK(is_valid_hqp_score);
733 hqp_buckets->push_back(bucket); 731 hqp_buckets->push_back(bucket);
734 } 732 }
735 return true; 733 return true;
736 } 734 }
737 return false; 735 return false;
738 } 736 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/scored_history_match.h ('k') | components/omnibox/browser/scored_history_match_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698