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 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
28 #include "components/history/core/browser/history_service.h" | 28 #include "components/history/core/browser/history_service.h" |
29 #include "components/metrics/proto/omnibox_input_type.pb.h" | 29 #include "components/metrics/proto/omnibox_input_type.pb.h" |
30 #include "components/omnibox/autocomplete_input.h" | 30 #include "components/omnibox/autocomplete_input.h" |
31 #include "components/omnibox/autocomplete_match.h" | 31 #include "components/omnibox/autocomplete_match.h" |
32 #include "components/omnibox/autocomplete_result.h" | 32 #include "components/omnibox/autocomplete_result.h" |
33 #include "components/omnibox/omnibox_field_trial.h" | 33 #include "components/omnibox/omnibox_field_trial.h" |
34 #include "components/omnibox/url_prefix.h" | 34 #include "components/omnibox/url_prefix.h" |
35 #include "components/url_fixer/url_fixer.h" | 35 #include "components/url_fixer/url_fixer.h" |
36 #include "url/url_parse.h" | 36 #include "url/third_party/mozilla/url_parse.h" |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 class DestinationURLEqualsURL { | 40 class DestinationURLEqualsURL { |
41 public: | 41 public: |
42 explicit DestinationURLEqualsURL(const GURL& url) : url_(url) {} | 42 explicit DestinationURLEqualsURL(const GURL& url) : url_(url) {} |
43 bool operator()(const AutocompleteMatch& match) const { | 43 bool operator()(const AutocompleteMatch& match) const { |
44 return match.destination_url == url_; | 44 return match.destination_url == url_; |
45 } | 45 } |
46 private: | 46 private: |
(...skipping 354 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. | 401 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
402 const double kMaxDecaySpeedDivisor = 5.0; | 402 const double kMaxDecaySpeedDivisor = 5.0; |
403 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 403 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
404 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 404 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
405 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 405 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
406 kNumUsesPerDecaySpeedDivisorIncrement); | 406 kNumUsesPerDecaySpeedDivisorIncrement); |
407 | 407 |
408 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 408 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
409 0.5); | 409 0.5); |
410 } | 410 } |
OLD | NEW |