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> |
11 | 11 |
12 #include "base/i18n/break_iterator.h" | 12 #include "base/i18n/break_iterator.h" |
13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chrome/browser/autocomplete/history_provider.h" | 21 #include "chrome/browser/autocomplete/history_provider.h" |
22 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 22 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
23 #include "chrome/browser/history/history_notifications.h" | |
24 #include "chrome/browser/history/history_service.h" | 23 #include "chrome/browser/history/history_service.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 24 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 26 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
30 #include "components/metrics/proto/omnibox_input_type.pb.h" | 29 #include "components/metrics/proto/omnibox_input_type.pb.h" |
31 #include "components/omnibox/autocomplete_input.h" | 30 #include "components/omnibox/autocomplete_input.h" |
32 #include "components/omnibox/autocomplete_match.h" | 31 #include "components/omnibox/autocomplete_match.h" |
33 #include "components/omnibox/autocomplete_result.h" | 32 #include "components/omnibox/autocomplete_result.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 400 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
402 const double kMaxDecaySpeedDivisor = 5.0; | 401 const double kMaxDecaySpeedDivisor = 5.0; |
403 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 402 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
404 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 403 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
405 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 404 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
406 kNumUsesPerDecaySpeedDivisorIncrement); | 405 kNumUsesPerDecaySpeedDivisorIncrement); |
407 | 406 |
408 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 407 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
409 0.5); | 408 0.5); |
410 } | 409 } |
OLD | NEW |