OLD | NEW |
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/autocomplete/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 match.deletable = true; | 193 match.deletable = true; |
194 match.fill_into_edit = shortcut.match_core.fill_into_edit; | 194 match.fill_into_edit = shortcut.match_core.fill_into_edit; |
195 match.destination_url = shortcut.match_core.destination_url; | 195 match.destination_url = shortcut.match_core.destination_url; |
196 DCHECK(match.destination_url.is_valid()); | 196 DCHECK(match.destination_url.is_valid()); |
197 match.contents = shortcut.match_core.contents; | 197 match.contents = shortcut.match_core.contents; |
198 match.contents_class = AutocompleteMatch::ClassificationsFromString( | 198 match.contents_class = AutocompleteMatch::ClassificationsFromString( |
199 shortcut.match_core.contents_class); | 199 shortcut.match_core.contents_class); |
200 match.description = shortcut.match_core.description; | 200 match.description = shortcut.match_core.description; |
201 match.description_class = AutocompleteMatch::ClassificationsFromString( | 201 match.description_class = AutocompleteMatch::ClassificationsFromString( |
202 shortcut.match_core.description_class); | 202 shortcut.match_core.description_class); |
203 match.transition = | 203 match.transition = ui::PageTransitionFromInt(shortcut.match_core.transition); |
204 static_cast<content::PageTransition>(shortcut.match_core.transition); | |
205 match.type = static_cast<AutocompleteMatch::Type>(shortcut.match_core.type); | 204 match.type = static_cast<AutocompleteMatch::Type>(shortcut.match_core.type); |
206 match.keyword = shortcut.match_core.keyword; | 205 match.keyword = shortcut.match_core.keyword; |
207 match.RecordAdditionalInfo("number of hits", shortcut.number_of_hits); | 206 match.RecordAdditionalInfo("number of hits", shortcut.number_of_hits); |
208 match.RecordAdditionalInfo("last access time", shortcut.last_access_time); | 207 match.RecordAdditionalInfo("last access time", shortcut.last_access_time); |
209 match.RecordAdditionalInfo("original input text", | 208 match.RecordAdditionalInfo("original input text", |
210 base::UTF16ToUTF8(shortcut.text)); | 209 base::UTF16ToUTF8(shortcut.text)); |
211 | 210 |
212 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. | 211 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
213 // If the match is a search query this is easy: simply check whether the | 212 // If the match is a search query this is easy: simply check whether the |
214 // user text is a prefix of the query. If the match is a navigation, we | 213 // user text is a prefix of the query. If the match is a navigation, we |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 403 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
405 const double kMaxDecaySpeedDivisor = 5.0; | 404 const double kMaxDecaySpeedDivisor = 5.0; |
406 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 405 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
407 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 406 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
408 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 407 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
409 kNumUsesPerDecaySpeedDivisorIncrement); | 408 kNumUsesPerDecaySpeedDivisorIncrement); |
410 | 409 |
411 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 410 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
412 0.5); | 411 0.5); |
413 } | 412 } |
OLD | NEW |